From 1bbb748b9e345bdbf5a7cd74d28eb0222d3e9b25 Mon Sep 17 00:00:00 2001 From: Khoubza Younes Date: Mon, 7 Dec 2020 01:01:50 +0100 Subject: [PATCH] fix noty library --- src/Noty/Prime/NotyBuilder.php | 165 ++++++++++++++++++ src/Noty/Prime/NotyRenderer.php | 4 +- .../DependencyInjection/Configuration.php | 2 +- 3 files changed, 168 insertions(+), 3 deletions(-) diff --git a/src/Noty/Prime/NotyBuilder.php b/src/Noty/Prime/NotyBuilder.php index 487b614f..daf9aaf7 100644 --- a/src/Noty/Prime/NotyBuilder.php +++ b/src/Noty/Prime/NotyBuilder.php @@ -6,4 +6,169 @@ use Flasher\Prime\Notification\NotificationBuilder; final class NotyBuilder extends NotificationBuilder { + /** + * @param string $text + * + * @return NotyBuilder + */ + public function text($text) + { + return $this->message($text); + } + + /** + * @param string $message + * @param array $options + * + * @return NotyBuilder + */ + public function alert($message = null, array $options = array()) + { + return $this->type('alert', $message, $options); + } + + /** + * @param string $layout + * + * @return $this + */ + public function layout($layout) + { + $this->option('layout', $layout); + + return $this; + } + + /** + * @param string $theme + * + * @return $this + */ + public function theme($theme) + { + $this->option('theme', $theme); + + return $this; + } + + /** + * @param int|bool $timeout + * + * @return $this + */ + public function timeout($timeout) + { + $this->option('timeout', $timeout); + + return $this; + } + + /** + * @param bool $progressBar + * + * @return $this + */ + public function progressBar($progressBar = false) + { + $this->option('progressBar', $progressBar); + + return $this; + } + + /** + * @param array $closeWith + * + * @return $this + */ + public function closeWith($closeWith) + { + $this->option('closeWith', $closeWith); + + return $this; + } + + /** + * @param string $animation + * @param string $effect + * + * @return $this + */ + public function animation($animation, $effect) + { + $this->option('animation.'.$animation, $effect); + + return $this; + } + + /** + * @param string $option + * + * @return $this + */ + public function sounds($option, $value) + { + $this->option('sounds.'.$option, $value); + + return $this; + } + + /** + * @param bool $modal + * + * @return $this + */ + public function modal($modal = true) + { + $this->option('modal', $modal); + + return $this; + } + + /** + * @param bool $force + * + * @return $this + */ + public function force($force = true) + { + $this->option('force', $force); + + return $this; + } + + /** + * @param string|bool $killer + * + * @return $this + */ + public function killer($killer) + { + $this->option('killer', $killer); + + return $this; + } + + /** + * @param string|bool $container + * + * @return $this + */ + public function container($container) + { + $this->option('container', $container); + + return $this; + } + + /** + * @param array $buttons + * + * @return $this + */ + public function buttons($buttons) + { + $this->option('buttons', $buttons); + + return $this; + } } diff --git a/src/Noty/Prime/NotyRenderer.php b/src/Noty/Prime/NotyRenderer.php index a3c817e8..dde9990d 100644 --- a/src/Noty/Prime/NotyRenderer.php +++ b/src/Noty/Prime/NotyRenderer.php @@ -47,10 +47,10 @@ final class NotyRenderer implements RendererInterface, HasScriptsInterface, HasS $notification = $envelope->getNotification(); $options = $envelope->getOptions(); - $options['message'] = $envelope->getMessage(); + $options['text'] = $envelope->getMessage(); $options['type'] = $envelope->getType(); - return sprintf("new Noty(%s);", json_encode($options)); + return sprintf("new Noty(%s).show();", json_encode($options)); } /** diff --git a/src/Noty/Symfony/DependencyInjection/Configuration.php b/src/Noty/Symfony/DependencyInjection/Configuration.php index ea6cecac..65724950 100644 --- a/src/Noty/Symfony/DependencyInjection/Configuration.php +++ b/src/Noty/Symfony/DependencyInjection/Configuration.php @@ -41,7 +41,7 @@ final class Configuration implements ConfigurationInterface ->defaultValue(array( 'layout' => 'topRight', 'theme' => 'mint', - 'timeout' => 5000, + 'timeout' => false, 'progressBar' => true, 'animation.open' => 'noty_effects_open', 'animation.close' => 'noty_effects_close',