From b4506620d3233943e3e7ce3a8d8cf8faf74e7357 Mon Sep 17 00:00:00 2001 From: Khoubza Younes Date: Sun, 6 Dec 2020 17:29:32 +0100 Subject: [PATCH] update namespaces --- Producer/SweetAlertProducer.php | 41 ------------------- SweetAlert.php | 10 +++++ SweetAlertBuilder.php | 10 +++++ SweetAlertFactory.php | 32 +++++++++++++++ ...lertRenderer.php => SweetAlertRenderer.php | 18 +++++--- Tests/.gitkeep | 0 composer.json | 12 +++--- 7 files changed, 70 insertions(+), 53 deletions(-) delete mode 100644 Producer/SweetAlertProducer.php create mode 100644 SweetAlert.php create mode 100644 SweetAlertBuilder.php create mode 100644 SweetAlertFactory.php rename Renderer/SweetAlertRenderer.php => SweetAlertRenderer.php (74%) create mode 100644 Tests/.gitkeep diff --git a/Producer/SweetAlertProducer.php b/Producer/SweetAlertProducer.php deleted file mode 100644 index 7de4427a..00000000 --- a/Producer/SweetAlertProducer.php +++ /dev/null @@ -1,41 +0,0 @@ -render('question', $message, $title, $context, $stamps); - } - - public function image($title = '', $message = '', $imageUrl, $imageWidth = 400, $imageHeight = 200, $imageAlt = '', array $stamps = array()) - { - $context['options']['title'] = $title; - $context['options']['text'] = $message; - $context['options']['imageUrl'] = $imageUrl; - $context['options']['imageWidth'] = $imageWidth; - $context['options']['imageHeight'] = $imageHeight; - - if (!is_null($imageAlt)) { - $context['options']['imageAlt'] = $imageAlt; - } else { - $context['options']['imageAlt'] = $title; - } - - $context['options']['animation'] = false; - - return $this->render('info', $message, $title, $context, $stamps); - } -} diff --git a/SweetAlert.php b/SweetAlert.php new file mode 100644 index 00000000..966aa720 --- /dev/null +++ b/SweetAlert.php @@ -0,0 +1,10 @@ +getEventDispatcher(), $this->createNotification(), 'sweet_alert'); + } + + /** + * @inheritDoc + */ + public function supports($name = null, array $context = array()) + { + return in_array($name, array(__CLASS__, 'sweet_alert')); + } +} diff --git a/Renderer/SweetAlertRenderer.php b/SweetAlertRenderer.php similarity index 74% rename from Renderer/SweetAlertRenderer.php rename to SweetAlertRenderer.php index 64045649..8f4d4a91 100644 --- a/Renderer/SweetAlertRenderer.php +++ b/SweetAlertRenderer.php @@ -1,15 +1,15 @@ getContext(); - $options = isset($context['options']) ? $context['options'] : array(); + $options = $envelope->getOptions(); - $options['title'] = " " . $envelope->getTitle(); $options['text'] = $envelope->getMessage(); $options['icon'] = $envelope->getType(); @@ -78,4 +76,12 @@ class SweetAlertRenderer implements RendererInterface, HasScriptsInterface, HasS { return sprintf('var SwalToast = Swal.mixin(%s);', json_encode($this->options)); } + + /** + * @inheritDoc + */ + public function supports($name = null, array $context = array()) + { + return in_array($name, array(__CLASS__, 'sweet_alert', 'Flasher\SweetAlert\Prime\SweetAlertFactory', 'Flasher\SweetAlert\Prime\SweetAlert')); + } } diff --git a/Tests/.gitkeep b/Tests/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/composer.json b/composer.json index b7d3896e..ce74747a 100644 --- a/composer.json +++ b/composer.json @@ -25,19 +25,19 @@ "license": "MIT", "require": { "php": ">=5.3", - "php-flasher/flasher": "^1.0" - }, - "require-dev": { - "phpunit/phpunit": "4.8.36" + "php-flasher/flasher": "dev-main" }, "autoload": { "psr-4": { - "Flasher\\SweetAlert\\": "src" + "Flasher\\SweetAlert\\prime\\": "", + "exclude-from-classmap": [ + "/Tests/" + ] } }, "autoload-dev": { "psr-4": { - "Flasher\\SweetAlert\\Tests\\": "tests/" + "Flasher\\SweetAlert\\Tests\\": "Tests/" } }, "config": {