From 8982c1c2630d7489a1662026e2b872629ad55757 Mon Sep 17 00:00:00 2001 From: Khoubza Younes Date: Sun, 6 Dec 2020 17:29:32 +0100 Subject: [PATCH] update namespaces --- src/Laravel/composer.json | 17 ++++---- ...er.php => FlasherNotyfServiceProvider.php} | 3 +- .../ServiceProvider/Providers/Laravel.php | 34 +++++++-------- .../ServiceProvider/Providers/Laravel4.php | 12 +++--- .../ServiceProvider/Providers/Lumen.php | 8 ++-- .../Providers/ServiceProviderInterface.php | 6 +-- .../ServiceProviderManager.php | 6 +-- .../Tests/NotifyNotyfServiceProviderTest.php | 2 +- src/Notyf/Laravel/Tests/TestCase.php | 2 +- src/Notyf/Laravel/composer.json | 21 +++++----- src/Notyf/Prime/Notyf.php | 10 +++++ src/Notyf/Prime/NotyfBuilder.php | 13 ++++++ src/Notyf/Prime/NotyfFactory.php | 32 +++++++++++++++ .../Prime/{Renderer => }/NotyfRenderer.php | 19 ++++++--- src/Notyf/Prime/Producer/NotyfProducer.php | 14 ------- .../tests => Notyf/Prime/Tests}/.gitkeep | 0 src/Notyf/Prime/composer.json | 12 +++--- .../DependencyInjection/Configuration.php | 4 +- ...xtension.php => FlasherNotyfExtension.php} | 12 +++--- ...NotyfBundle.php => FlasherNotyfBundle.php} | 2 +- .../Symfony/Resources/config/config.yaml | 16 ++++++++ .../Symfony/Resources/config/services.yaml | 16 -------- src/Notyf/Symfony/Tests/.gitkeep | 0 src/Notyf/Symfony/composer.json | 16 ++++---- src/Pnotify/Laravel/composer.json | 19 ++++----- src/Pnotify/Prime/Pnotify.php | 10 +++++ src/Pnotify/Prime/PnotifyBuilder.php | 13 ++++++ src/Pnotify/Prime/PnotifyFactory.php | 32 +++++++++++++++ .../Prime/{Renderer => }/PnotifyRenderer.php | 18 +++++--- .../Prime/Producer/PnotifyProducer.php | 24 ----------- src/Pnotify/Prime/Tests/.gitkeep | 0 src/Pnotify/Prime/composer.json | 12 +++--- .../DependencyInjection/Configuration.php | 4 +- ...ension.php => FlasherPnotifyExtension.php} | 10 ++--- ...ifyBundle.php => FlasherPnotifyBundle.php} | 2 +- .../Symfony/Resources/config/config.yaml | 16 ++++++++ .../Symfony/Resources/config/services.yaml | 16 -------- src/Pnotify/Symfony/Tests/.gitkeep | 0 src/Pnotify/Symfony/composer.json | 16 ++++---- src/Prime/composer.json | 3 -- ...p => FlasherSweetAlertServiceProvider.php} | 3 +- .../ServiceProvider/Providers/Laravel.php | 30 +++++++------- .../ServiceProvider/Providers/Laravel4.php | 12 +++--- .../ServiceProvider/Providers/Lumen.php | 8 ++-- .../Providers/ServiceProviderInterface.php | 6 +-- .../ServiceProviderManager.php | 6 +-- src/SweetAlert/Laravel/composer.json | 19 ++++----- .../Prime/Producer/SweetAlertProducer.php | 41 ------------------- src/SweetAlert/Prime/SweetAlert.php | 10 +++++ src/SweetAlert/Prime/SweetAlertBuilder.php | 10 +++++ src/SweetAlert/Prime/SweetAlertFactory.php | 32 +++++++++++++++ .../{Renderer => }/SweetAlertRenderer.php | 18 +++++--- src/SweetAlert/Prime/Tests/.gitkeep | 0 src/SweetAlert/Prime/composer.json | 12 +++--- .../DependencyInjection/Configuration.php | 4 +- ...ion.php => FlasherSweetAlertExtension.php} | 14 +++---- ...Bundle.php => FlasherSweetAlertBundle.php} | 2 +- .../Symfony/Resources/config/config.yaml | 16 ++++++++ .../Symfony/Resources/config/services.yaml | 16 -------- src/SweetAlert/Symfony/composer.json | 16 ++++---- src/Symfony/composer.json | 5 ++- .../Laravel/FlasherToastrServiceProvider.php | 2 +- .../NotifyToastrServiceProviderTest.php | 0 .../Laravel/{tests => Tests}/TestCase.php | 0 src/Toastr/Laravel/composer.json | 9 ++-- src/Toastr/Prime/composer.json | 8 ++-- src/Toastr/Symfony/composer.json | 8 ++-- 67 files changed, 434 insertions(+), 345 deletions(-) rename src/Notyf/Laravel/{NotifyNotyfServiceProvider.php => FlasherNotyfServiceProvider.php} (93%) create mode 100644 src/Notyf/Prime/Notyf.php create mode 100644 src/Notyf/Prime/NotyfBuilder.php create mode 100644 src/Notyf/Prime/NotyfFactory.php rename src/Notyf/Prime/{Renderer => }/NotyfRenderer.php (73%) delete mode 100644 src/Notyf/Prime/Producer/NotyfProducer.php rename src/{Pnotify/Symfony/tests => Notyf/Prime/Tests}/.gitkeep (100%) rename src/Notyf/Symfony/DependencyInjection/{NotifyNotyfExtension.php => FlasherNotyfExtension.php} (72%) rename src/Notyf/Symfony/{NotifyNotyfBundle.php => FlasherNotyfBundle.php} (70%) create mode 100644 src/Notyf/Symfony/Resources/config/config.yaml delete mode 100644 src/Notyf/Symfony/Resources/config/services.yaml create mode 100644 src/Notyf/Symfony/Tests/.gitkeep create mode 100644 src/Pnotify/Prime/Pnotify.php create mode 100644 src/Pnotify/Prime/PnotifyBuilder.php create mode 100644 src/Pnotify/Prime/PnotifyFactory.php rename src/Pnotify/Prime/{Renderer => }/PnotifyRenderer.php (77%) delete mode 100644 src/Pnotify/Prime/Producer/PnotifyProducer.php create mode 100644 src/Pnotify/Prime/Tests/.gitkeep rename src/Pnotify/Symfony/DependencyInjection/{NotifyPnotifyExtension.php => FlasherPnotifyExtension.php} (76%) rename src/Pnotify/Symfony/{NotifyPnotifyBundle.php => FlasherPnotifyBundle.php} (69%) create mode 100644 src/Pnotify/Symfony/Resources/config/config.yaml delete mode 100644 src/Pnotify/Symfony/Resources/config/services.yaml create mode 100644 src/Pnotify/Symfony/Tests/.gitkeep rename src/SweetAlert/Laravel/{NotifySweetAlertServiceProvider.php => FlasherSweetAlertServiceProvider.php} (92%) delete mode 100644 src/SweetAlert/Prime/Producer/SweetAlertProducer.php create mode 100644 src/SweetAlert/Prime/SweetAlert.php create mode 100644 src/SweetAlert/Prime/SweetAlertBuilder.php create mode 100644 src/SweetAlert/Prime/SweetAlertFactory.php rename src/SweetAlert/Prime/{Renderer => }/SweetAlertRenderer.php (74%) create mode 100644 src/SweetAlert/Prime/Tests/.gitkeep rename src/SweetAlert/Symfony/DependencyInjection/{NotifySweetAlertExtension.php => FlasherSweetAlertExtension.php} (71%) rename src/SweetAlert/Symfony/{NotifySweetAlertBundle.php => FlasherSweetAlertBundle.php} (68%) create mode 100644 src/SweetAlert/Symfony/Resources/config/config.yaml delete mode 100644 src/SweetAlert/Symfony/Resources/config/services.yaml rename src/Toastr/Laravel/{tests => Tests}/NotifyToastrServiceProviderTest.php (100%) rename src/Toastr/Laravel/{tests => Tests}/TestCase.php (100%) diff --git a/src/Laravel/composer.json b/src/Laravel/composer.json index 22fdd5a4..9a48098d 100644 --- a/src/Laravel/composer.json +++ b/src/Laravel/composer.json @@ -1,9 +1,10 @@ { "name": "php-flasher/flasher-laravel", - "description": "Laravel Flasher package for php-flasher/flasher", + "description": "Laravel adapter for php-flasher/flasher library", "keywords": [ "yoeunes", "notify", + "flasher", "php", "laravel", "symfony", @@ -31,13 +32,12 @@ "illuminate/support": "^4.0|^5.0|^6.0|^7.0|^8.0", "php-flasher/flasher": "dev-main" }, - "require-dev": { - "phpunit/phpunit": "^4.8|^5.7|^6.0|^7.0|^8.3|^9.0", - "orchestra/testbench": "^2.0|^3.0|^4.0|^5.0|^6.0" - }, "autoload": { "psr-4": { - "Flasher\\Laravel\\": "" + "Flasher\\Laravel\\": "", + "exclude-from-classmap": [ + "/Tests/" + ] }, "files": [ "helpers.php" @@ -52,10 +52,7 @@ "laravel": { "providers": [ "Flasher\\Laravel\\FlasherServiceProvider" - ], - "aliases": { - "Flasher": "Flasher\\Laravel\\Facades\\Flasher" - } + ] } }, "config": { diff --git a/src/Notyf/Laravel/NotifyNotyfServiceProvider.php b/src/Notyf/Laravel/FlasherNotyfServiceProvider.php similarity index 93% rename from src/Notyf/Laravel/NotifyNotyfServiceProvider.php rename to src/Notyf/Laravel/FlasherNotyfServiceProvider.php index cc7e7b48..1de9c0b0 100644 --- a/src/Notyf/Laravel/NotifyNotyfServiceProvider.php +++ b/src/Notyf/Laravel/FlasherNotyfServiceProvider.php @@ -6,7 +6,7 @@ use Illuminate\Contracts\Support\DeferrableProvider; use Illuminate\Support\ServiceProvider; use Flasher\Notyf\Laravel\ServiceProvider\ServiceProviderManager; -class NotifyNotyfServiceProvider extends ServiceProvider +class FlasherNotyfServiceProvider extends ServiceProvider { public function boot() { @@ -31,7 +31,6 @@ class NotifyNotyfServiceProvider extends ServiceProvider public function provides() { return array( - 'flasher.factory', 'flasher.factory.notyf', 'flasher.renderer.notyf', ); diff --git a/src/Notyf/Laravel/ServiceProvider/Providers/Laravel.php b/src/Notyf/Laravel/ServiceProvider/Providers/Laravel.php index a44f0c5d..9bcc658f 100644 --- a/src/Notyf/Laravel/ServiceProvider/Providers/Laravel.php +++ b/src/Notyf/Laravel/ServiceProvider/Providers/Laravel.php @@ -2,9 +2,9 @@ namespace Flasher\Notyf\Laravel\ServiceProvider\Providers; -use Flasher\Notyf\LaravelFlasher\PrimeNotyfServiceProvider; -use Flasher\Notyf\Prime\Factory\NotyfProducer; -use Flasher\Notyf\Prime\Renderer\NotyfRenderer; +use Flasher\Notyf\Laravel\FlasherNotyfServiceProvider; +use Flasher\Notyf\Prime\NotyfFactory; +use Flasher\Notyf\Prime\NotyfRenderer; use Flasher\Prime\Flasher; use Flasher\Prime\Renderer\RendererManager; use Illuminate\Container\Container; @@ -24,36 +24,36 @@ class Laravel implements ServiceProviderInterface return $this->app instanceof Application; } - public function publishConfig(NotifyNotyfServiceProvider $provider) + public function publishConfig(FlasherNotyfServiceProvider $provider) { $source = realpath($raw = __DIR__.'/../../../resources/config/config.php') ?: $raw; - $provider->publishes(array($source => config_path('notify_notyf.php')), 'config'); + $provider->publishes(array($source => config_path('flasher_notyf.php')), 'config'); - $provider->mergeConfigFrom($source, 'notify_notyf'); + $provider->mergeConfigFrom($source, 'flasher_notyf'); } - public function registerNotifyNotyfServices() + public function registerServices() { $this->app->singleton('flasher.factory.notyf', function (Container $app) { - return new NotyfProducer($app['flasher.storage'], $app['flasher.middleware']); + return new NotyfFactory($app['flasher.event_dispatcher']); }); $this->app->singleton('flasher.renderer.notyf', function (Container $app) { return new NotyfRenderer($app['flasher.config']); }); - $this->app->alias('flasher.factory.notyf', 'Flasher\Notyf\Prime\Factory\NotyfProducer'); - $this->app->alias('flasher.renderer.notyf', 'Flasher\Notyf\Prime\Renderer\NotyfRenderer'); + $this->app->alias('flasher.factory.notyf', 'Flasher\Notyf\Prime\NotyfFactory'); + $this->app->alias('flasher.renderer.notyf', 'Flasher\Notyf\Prime\NotyfRenderer'); - $this->app->extend('flasher.factory', function (Flasher $manager, Container $app) { - $manager->addDriver('notyf', $app['flasher.factory.notyf']); + $this->app->extend('flasher', function (Flasher $manager, Container $app) { + $manager->addDriver($app['flasher.factory.notyf']); return $manager; }); - $this->app->extend('flasher.renderer', function (RendererManager $manager, Container $app) { - $manager->addDriver('notyf', $app['flasher.renderer.notyf']); + $this->app->extend('flasher.renderer_manager', function (RendererManager $manager, Container $app) { + $manager->addDriver($app['flasher.renderer.notyf']); return $manager; }); @@ -61,10 +61,10 @@ class Laravel implements ServiceProviderInterface public function mergeConfigFromNotyf() { - $notifyConfig = $this->app['config']->get('flasher.adapters.notyf', array()); + $flasherConfig = $this->app['config']->get('flasher.adapters.notyf', array()); - $notyfConfig = $this->app['config']->get('notify_notyf', array()); + $notyfConfig = $this->app['config']->get('flasher_notyf', array()); - $this->app['config']->set('flasher.adapters.notyf', array_merge($notyfConfig, $notifyConfig)); + $this->app['config']->set('flasher.adapters.notyf', array_merge($notyfConfig, $flasherConfig)); } } diff --git a/src/Notyf/Laravel/ServiceProvider/Providers/Laravel4.php b/src/Notyf/Laravel/ServiceProvider/Providers/Laravel4.php index cb520bf3..5288ac02 100644 --- a/src/Notyf/Laravel/ServiceProvider/Providers/Laravel4.php +++ b/src/Notyf/Laravel/ServiceProvider/Providers/Laravel4.php @@ -2,8 +2,8 @@ namespace Flasher\Notyf\Laravel\ServiceProvider\Providers; +use Flasher\Notyf\Laravel\FlasherNotyfServiceProvider; use Illuminate\Foundation\Application; -use Flasher\Notyf\LaravelFlasher\PrimeNotyfServiceProvider; final class Laravel4 extends Laravel { @@ -12,17 +12,17 @@ final class Laravel4 extends Laravel return $this->app instanceof Application && 0 === strpos(Application::VERSION, '4.'); } - public function publishConfig(NotifyNotyfServiceProvider $provider) + public function publishConfig(FlasherNotyfServiceProvider $provider) { - $provider->package('php-flasher/flasher-laravel-notyf', 'notify_notyf', __DIR__.'/../../../resources'); + $provider->package('php-flasher/flasher-laravel-notyf', 'flasher_notyf', __DIR__.'/../../../resources'); } public function mergeConfigFromNotyf() { - $notifyConfig = $this->app['config']->get('notify::config.adapters.notyf', array()); + $flasherConfig = $this->app['config']->get('flasher::config.adapters.notyf', array()); - $notyfConfig = $this->app['config']->get('notify_notyf::config', array()); + $notyfConfig = $this->app['config']->get('flasher_notyf::config', array()); - $this->app['config']->set('notify::config.adapters.notyf', array_merge($notyfConfig, $notifyConfig)); + $this->app['config']->set('flasher::config.adapters.notyf', array_merge($notyfConfig, $flasherConfig)); } } diff --git a/src/Notyf/Laravel/ServiceProvider/Providers/Lumen.php b/src/Notyf/Laravel/ServiceProvider/Providers/Lumen.php index ad4cbf1c..877edd27 100644 --- a/src/Notyf/Laravel/ServiceProvider/Providers/Lumen.php +++ b/src/Notyf/Laravel/ServiceProvider/Providers/Lumen.php @@ -2,8 +2,8 @@ namespace Flasher\Notyf\Laravel\ServiceProvider\Providers; +use Flasher\Notyf\Laravel\FlasherNotyfServiceProvider; use Laravel\Lumen\Application; -use Flasher\Notyf\LaravelFlasher\PrimeNotyfServiceProvider; final class Lumen extends Laravel { @@ -12,12 +12,12 @@ final class Lumen extends Laravel return $this->app instanceof Application; } - public function publishConfig(NotifyNotyfServiceProvider $provider) + public function publishConfig(FlasherNotyfServiceProvider $provider) { $source = realpath($raw = __DIR__.'/../../../resources/config/config.php') ?: $raw; - $this->app->configure('notify_notyf'); + $this->app->configure('flasher_notyf'); - $provider->mergeConfigFrom($source, 'notify_notyf'); + $provider->mergeConfigFrom($source, 'flasher_notyf'); } } diff --git a/src/Notyf/Laravel/ServiceProvider/Providers/ServiceProviderInterface.php b/src/Notyf/Laravel/ServiceProvider/Providers/ServiceProviderInterface.php index 68a5f0fd..e1856407 100644 --- a/src/Notyf/Laravel/ServiceProvider/Providers/ServiceProviderInterface.php +++ b/src/Notyf/Laravel/ServiceProvider/Providers/ServiceProviderInterface.php @@ -2,15 +2,15 @@ namespace Flasher\Notyf\Laravel\ServiceProvider\Providers; -use Flasher\Notyf\LaravelFlasher\PrimeNotyfServiceProvider; +use Flasher\Notyf\Laravel\FlasherNotyfServiceProvider; interface ServiceProviderInterface { public function shouldBeUsed(); - public function publishConfig(NotifyNotyfServiceProvider $provider); + public function publishConfig(FlasherNotyfServiceProvider $provider); - public function registerNotifyNotyfServices(); + public function registerServices(); public function mergeConfigFromNotyf(); } diff --git a/src/Notyf/Laravel/ServiceProvider/ServiceProviderManager.php b/src/Notyf/Laravel/ServiceProvider/ServiceProviderManager.php index 2e6cae61..2c326093 100644 --- a/src/Notyf/Laravel/ServiceProvider/ServiceProviderManager.php +++ b/src/Notyf/Laravel/ServiceProvider/ServiceProviderManager.php @@ -2,7 +2,7 @@ namespace Flasher\Notyf\Laravel\ServiceProvider; -use Flasher\Notyf\LaravelFlasher\PrimeNotyfServiceProvider; +use Flasher\Notyf\Laravel\FlasherNotyfServiceProvider; use Flasher\Notyf\Laravel\ServiceProvider\Providers\ServiceProviderInterface; final class ServiceProviderManager @@ -20,7 +20,7 @@ final class ServiceProviderManager private $notifyServiceProvider; - public function __construct(NotifyNotyfServiceProvider $notifyServiceProvider) + public function __construct(FlasherNotyfServiceProvider $notifyServiceProvider) { $this->notifyServiceProvider = $notifyServiceProvider; } @@ -36,7 +36,7 @@ final class ServiceProviderManager public function register() { $provider = $this->resolveServiceProvider(); - $provider->registerNotifyNotyfServices(); + $provider->registerServices(); } /** diff --git a/src/Notyf/Laravel/Tests/NotifyNotyfServiceProviderTest.php b/src/Notyf/Laravel/Tests/NotifyNotyfServiceProviderTest.php index cf7ed557..b6aadaf1 100644 --- a/src/Notyf/Laravel/Tests/NotifyNotyfServiceProviderTest.php +++ b/src/Notyf/Laravel/Tests/NotifyNotyfServiceProviderTest.php @@ -2,7 +2,7 @@ namespace Flasher\Notyf\Laravel\Tests; -class NotifyNotyfServiceProviderTest extends TestCase +final class NotifyNotyfServiceProviderTest extends TestCase { public function testContainerContainNotifyServices() { diff --git a/src/Notyf/Laravel/Tests/TestCase.php b/src/Notyf/Laravel/Tests/TestCase.php index fbc2744c..785c70de 100644 --- a/src/Notyf/Laravel/Tests/TestCase.php +++ b/src/Notyf/Laravel/Tests/TestCase.php @@ -9,7 +9,7 @@ use Illuminate\Http\Request; use Illuminate\Support\Facades\Facade; use Orchestra\Testbench\TestCase as Orchestra; -class TestCase extends Orchestra +final class TestCase extends Orchestra { /** * @param \Illuminate\Foundation\Application $app diff --git a/src/Notyf/Laravel/composer.json b/src/Notyf/Laravel/composer.json index 3925ee6d..a05c9146 100644 --- a/src/Notyf/Laravel/composer.json +++ b/src/Notyf/Laravel/composer.json @@ -1,6 +1,6 @@ { - "name": "php-flasher/flasher-laravel-notyf", - "description": "Laravel Flasher adapter package for php-flasher/flasher-notyf", + "name": "php-flasher/flasher-notyf-laravel", + "description": "Laravel adapter for php-flasher/flasher-notyf library", "keywords": [ "yoeunes", "notify", @@ -29,27 +29,26 @@ "license": "MIT", "require": { "php": ">=5.3", - "php-flasher/flasher-laravel": "^1.0.4", - "php-flasher/flasher-notyf": "^1.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.8 || ^5.7 || ^6.0 || ^7.0 || ^8.3 || ^9.0", - "orchestra/testbench": "^2.0 || ^3.0 || ^4.0 || ^5.0 || ^6.0" + "php-flasher/flasher-laravel": "dev-main", + "php-flasher/flasher-notyf": "dev-main" }, "autoload": { "psr-4": { - "Flasher\\Laravel\\Notyf\\": "src/" + "Flasher\\Notyf\\Laravel\\": "", + "exclude-from-classmap": [ + "/Tests/" + ] } }, "autoload-dev": { "psr-4": { - "Flasher\\Laravel\\Notyf\\Tests\\": "tests/" + "Flasher\\Notyf\\Laravel\\Tests\\": "Tests/" } }, "extra": { "laravel": { "providers": [ - "Flasher\\Laravel\\Notyf\Flasher\PrimeNotyfServiceProvider" + "Flasher\\Notyf\\Laravel\\FlasherNotyfServiceProvider" ] } }, diff --git a/src/Notyf/Prime/Notyf.php b/src/Notyf/Prime/Notyf.php new file mode 100644 index 00000000..a905234f --- /dev/null +++ b/src/Notyf/Prime/Notyf.php @@ -0,0 +1,10 @@ +getEventDispatcher(), $this->createNotification(), 'notyf'); + } + + /** + * @inheritDoc + */ + public function supports($name = null, array $context = array()) + { + return in_array($name, array(__CLASS__, 'notyf')); + } +} diff --git a/src/Notyf/Prime/Renderer/NotyfRenderer.php b/src/Notyf/Prime/NotyfRenderer.php similarity index 73% rename from src/Notyf/Prime/Renderer/NotyfRenderer.php rename to src/Notyf/Prime/NotyfRenderer.php index e1779805..c2400891 100644 --- a/src/Notyf/Prime/Renderer/NotyfRenderer.php +++ b/src/Notyf/Prime/NotyfRenderer.php @@ -1,15 +1,15 @@ getContext(); - $options = isset($context['options']) ? $context['options'] : array(); + $options = $envelope->getOptions(); $options['message'] = $envelope->getMessage(); $options['type'] = $envelope->getType(); @@ -73,4 +72,14 @@ class NotyfRenderer implements RendererInterface, HasScriptsInterface, HasStyles { return sprintf('if ("undefined" === typeof notyf) { var notyf = new Notyf(%s); }', json_encode($this->options)); } + + /** + * @inheritDoc + */ + public function supports($name = null, array $context = array()) + { + return in_array($name, array(__CLASS__, 'notyf', 'Flasher\Notyf\Prime\NotyfFactory', + 'Flasher\Notyf\Prime\Pnotify' + )); + } } diff --git a/src/Notyf/Prime/Producer/NotyfProducer.php b/src/Notyf/Prime/Producer/NotyfProducer.php deleted file mode 100644 index 934488a4..00000000 --- a/src/Notyf/Prime/Producer/NotyfProducer.php +++ /dev/null @@ -1,14 +0,0 @@ -=5.3", - "php-flasher/flasher": "^1.0" - }, - "require-dev": { - "phpunit/phpunit": "4.8.36" + "php-flasher/flasher": "dev-main" }, "autoload": { "psr-4": { - "Flasher\\Notyf\\": "src" + "Flasher\\Notyf\\Prime\\": "", + "exclude-from-classmap": [ + "/Tests/" + ] } }, "autoload-dev": { "psr-4": { - "Flasher\\Notyf\\Tests\\": "tests/" + "Flasher\\Notyf\\prime\\Tests\\": "Tests/" } }, "config": { diff --git a/src/Notyf/Symfony/DependencyInjection/Configuration.php b/src/Notyf/Symfony/DependencyInjection/Configuration.php index e2f5d9d7..6eab5cda 100644 --- a/src/Notyf/Symfony/DependencyInjection/Configuration.php +++ b/src/Notyf/Symfony/DependencyInjection/Configuration.php @@ -12,13 +12,13 @@ final class Configuration implements ConfigurationInterface */ public function getConfigTreeBuilder() { - $treeBuilder = new TreeBuilder('notify_notyf'); + $treeBuilder = new TreeBuilder('flasher_notyf'); if (\method_exists($treeBuilder, 'getRootNode')) { $rootNode = $treeBuilder->getRootNode(); } else { // BC layer for symfony/config 4.1 and older - $rootNode = $treeBuilder->root('notify_notyf'); + $rootNode = $treeBuilder->root('flasher_notyf'); } $rootNode diff --git a/src/Notyf/Symfony/DependencyInjection/NotifyNotyfExtension.php b/src/Notyf/Symfony/DependencyInjection/FlasherNotyfExtension.php similarity index 72% rename from src/Notyf/Symfony/DependencyInjection/NotifyNotyfExtension.php rename to src/Notyf/Symfony/DependencyInjection/FlasherNotyfExtension.php index 9e837371..1f6da0e6 100644 --- a/src/Notyf/Symfony/DependencyInjection/NotifyNotyfExtension.php +++ b/src/Notyf/Symfony/DependencyInjection/FlasherNotyfExtension.php @@ -8,7 +8,7 @@ use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; use Symfony\Component\DependencyInjection\Loader; use Symfony\Component\HttpKernel\DependencyInjection\Extension; -final class NotifyNotyfExtension extends Extension implements PrependExtensionInterface +final class FlasherNotyfExtension extends Extension implements PrependExtensionInterface { /** * {@inheritdoc} @@ -18,7 +18,7 @@ final class NotifyNotyfExtension extends Extension implements PrependExtensionIn public function load(array $configs, ContainerBuilder $container) { $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); - $loader->load('services.yaml'); + $loader->load('config.yaml'); $configuration = new Configuration(); $this->processConfiguration($configuration, $configs); @@ -29,16 +29,14 @@ final class NotifyNotyfExtension extends Extension implements PrependExtensionIn */ public function prepend(ContainerBuilder $container) { - if (!$container->hasExtension('notify')) { - throw new \RuntimeException('[Flasher\SymfonyFlasher\PrimeBundle] is not registered'); + if (!$container->hasExtension('flasher')) { + throw new \RuntimeException('[Flasher\Symfony\FlasherBundle] is not registered'); } $configs = $container->getExtensionConfig($this->getAlias()); $config = $this->processConfiguration(new Configuration(), $configs); - $notifyConfig = $container->getExtensionConfig('notify'); - - $container->prependExtensionConfig('notify', array( + $container->prependExtensionConfig('flasher', array( 'adapters' => array( 'notyf' => $config, ), diff --git a/src/Notyf/Symfony/NotifyNotyfBundle.php b/src/Notyf/Symfony/FlasherNotyfBundle.php similarity index 70% rename from src/Notyf/Symfony/NotifyNotyfBundle.php rename to src/Notyf/Symfony/FlasherNotyfBundle.php index 0e907069..168d6335 100644 --- a/src/Notyf/Symfony/NotifyNotyfBundle.php +++ b/src/Notyf/Symfony/FlasherNotyfBundle.php @@ -4,6 +4,6 @@ namespace Flasher\Notyf\Symfony; use Symfony\Component\HttpKernel\Bundle\Bundle; -class NotifyNotyfBundle extends Bundle +class FlasherNotyfBundle extends Bundle { } diff --git a/src/Notyf/Symfony/Resources/config/config.yaml b/src/Notyf/Symfony/Resources/config/config.yaml new file mode 100644 index 00000000..95624abe --- /dev/null +++ b/src/Notyf/Symfony/Resources/config/config.yaml @@ -0,0 +1,16 @@ +services: + flasher.factory.notyf: + parent: 'flasher.abstract_factory' + class: Flasher\Notyf\Prime\NotyfProducer + tags: + - { name: 'flasher.factory' } + + flasher.renderer.notyf: + class: Flasher\Notyf\Prime\NotyfRenderer + arguments: + - '@flasher.config' + tags: + - { name: 'flasher.renderer' } + + Flasher\Notyf\Prime\NotyfProducer: '@flasher.factory.notyf' + Flasher\Notyf\Prime\NotyfRenderer: '@flasher.renderer.notyf' diff --git a/src/Notyf/Symfony/Resources/config/services.yaml b/src/Notyf/Symfony/Resources/config/services.yaml deleted file mode 100644 index 2ee52567..00000000 --- a/src/Notyf/Symfony/Resources/config/services.yaml +++ /dev/null @@ -1,16 +0,0 @@ -services: - flasher.factory.notyf: - parent: 'flasher.factory.abstract' - class: Flasher\Notyf\Prime\Factory\NotyfProducer - tags: - - { name: 'flasher.factory', alias: 'notyf' } - - flasher.renderer.notyf: - class: Flasher\Notyf\Prime\Renderer\NotyfRenderer - arguments: - - '@flasher.config' - tags: - - { name: 'flasher.renderer', alias: 'notyf' } - - Flasher\Notyf\Prime\Factory\NotyfProducer: '@flasher.factory.notyf' - Flasher\Notyf\Prime\Renderer\NotyfRenderer: '@flasher.renderer.notyf' diff --git a/src/Notyf/Symfony/Tests/.gitkeep b/src/Notyf/Symfony/Tests/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/src/Notyf/Symfony/composer.json b/src/Notyf/Symfony/composer.json index d4604617..3825bbaa 100644 --- a/src/Notyf/Symfony/composer.json +++ b/src/Notyf/Symfony/composer.json @@ -1,5 +1,5 @@ { - "name": "php-flasher/flasher-symfony-notyf", + "name": "php-flasher/flasher-notyf-symfony", "type": "symfony-bundle", "description": "Symfony Flasher adapter for Sweet Alert 2 library for php-flasher/flasher-symfony", "keywords": [ @@ -31,20 +31,20 @@ "license": "MIT", "require": { "php": ">=5.3", - "php-flasher/flasher-symfony": "^1.0", - "php-flasher/flasher-notyf": "^1.0" - }, - "require-dev": { - "phpunit/phpunit": "4.8.36" + "php-flasher/flasher-symfony": "dev-main", + "php-flasher/flasher-notyf": "dev-main" }, "autoload": { "psr-4": { - "Flasher\\Symfony\\Notyf\\": "src/" + "Flasher\\Notyf\\Symfony\\": "", + "exclude-from-classmap": [ + "/Tests/" + ] } }, "autoload-dev": { "psr-4": { - "Flasher\\Symfony\\Notyf\\Tests\\": "tests/" + "Flasher\\Notyf\\Symfony\\Tests\\": "Tests/" } }, "config": { diff --git a/src/Pnotify/Laravel/composer.json b/src/Pnotify/Laravel/composer.json index ca83da37..f59792cb 100644 --- a/src/Pnotify/Laravel/composer.json +++ b/src/Pnotify/Laravel/composer.json @@ -1,5 +1,5 @@ { - "name": "php-flasher/flasher-laravel-pnotify", + "name": "php-flasher/flasher-pnotify-laravel", "description": "Laravel Flasher adapter package for php-flasher/flasher-pnotify", "keywords": [ "yoeunes", @@ -28,27 +28,26 @@ "license": "MIT", "require": { "php": ">=5.3", - "php-flasher/flasher-laravel": "^1.0.4", - "php-flasher/flasher-pnotify": "^1.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.8 || ^5.7 || ^6.0 || ^7.0 || ^8.3 || ^9.0", - "orchestra/testbench": "^2.0 || ^3.0 || ^4.0 || ^5.0 || ^6.0" + "php-flasher/flasher-laravel": "dev-main", + "php-flasher/flasher-pnotify": "dev-main" }, "autoload": { "psr-4": { - "Flasher\\Laravel\\Pnotify\\": "src/" + "Flasher\\Pnotify\\Laravel\\": "", + "exclude-from-classmap": [ + "/Tests/" + ] } }, "autoload-dev": { "psr-4": { - "Flasher\\Laravel\\Pnotify\\Tests\\": "tests/" + "Flasher\\Pnotify\\Laravel\\Tests\\": "Tests/" } }, "extra": { "laravel": { "providers": [ - "Flasher\\Laravel\\Pnotify\Flasher\PrimePnotifyServiceProvider" + "Flasher\\Pnotify\\Laravel\\NotifyPnotifyServiceProvider" ] } }, diff --git a/src/Pnotify/Prime/Pnotify.php b/src/Pnotify/Prime/Pnotify.php new file mode 100644 index 00000000..a1827fb4 --- /dev/null +++ b/src/Pnotify/Prime/Pnotify.php @@ -0,0 +1,10 @@ +getEventDispatcher(), $this->createNotification(), 'pnotify'); + } + + /** + * @inheritDoc + */ + public function supports($name = null, array $context = array()) + { + return in_array($name, array(__CLASS__, 'pnotify')); + } +} diff --git a/src/Pnotify/Prime/Renderer/PnotifyRenderer.php b/src/Pnotify/Prime/PnotifyRenderer.php similarity index 77% rename from src/Pnotify/Prime/Renderer/PnotifyRenderer.php rename to src/Pnotify/Prime/PnotifyRenderer.php index da52f080..8c5d997e 100644 --- a/src/Pnotify/Prime/Renderer/PnotifyRenderer.php +++ b/src/Pnotify/Prime/PnotifyRenderer.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['type'] = $envelope->getType(); @@ -74,4 +72,12 @@ class PnotifyRenderer implements RendererInterface, HasScriptsInterface, HasStyl { return sprintf('PNotify.defaults = %s;', json_encode($this->options)); } + + /** + * @inheritDoc + */ + public function supports($name = null, array $context = array()) + { + return in_array($name, array(__CLASS__, 'pnotify', 'Flasher\Pnotify\Prime\PnotifyFactory', 'Flasher\Pnotify\Prime\Pnotify')); + } } diff --git a/src/Pnotify/Prime/Producer/PnotifyProducer.php b/src/Pnotify/Prime/Producer/PnotifyProducer.php deleted file mode 100644 index d4e60d4d..00000000 --- a/src/Pnotify/Prime/Producer/PnotifyProducer.php +++ /dev/null @@ -1,24 +0,0 @@ -render('notice', $message, $title, $context, $stamps); - } -} diff --git a/src/Pnotify/Prime/Tests/.gitkeep b/src/Pnotify/Prime/Tests/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/src/Pnotify/Prime/composer.json b/src/Pnotify/Prime/composer.json index cb37e1aa..1a3fa8e4 100644 --- a/src/Pnotify/Prime/composer.json +++ b/src/Pnotify/Prime/composer.json @@ -26,19 +26,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\\Pnotify\\": "src" + "Flasher\\Pnotify\\": "", + "exclude-from-classmap": [ + "/Tests/" + ] } }, "autoload-dev": { "psr-4": { - "Flasher\\Pnotify\\Tests\\": "tests/" + "Flasher\\Pnotify\\Tests\\": "Tests/" } }, "config": { diff --git a/src/Pnotify/Symfony/DependencyInjection/Configuration.php b/src/Pnotify/Symfony/DependencyInjection/Configuration.php index a3829ed3..6907ce6b 100644 --- a/src/Pnotify/Symfony/DependencyInjection/Configuration.php +++ b/src/Pnotify/Symfony/DependencyInjection/Configuration.php @@ -12,13 +12,13 @@ final class Configuration implements ConfigurationInterface */ public function getConfigTreeBuilder() { - $treeBuilder = new TreeBuilder('notify_pnotify'); + $treeBuilder = new TreeBuilder('flasher_pnotify'); if (\method_exists($treeBuilder, 'getRootNode')) { $rootNode = $treeBuilder->getRootNode(); } else { // BC layer for symfony/config 4.1 and older - $rootNode = $treeBuilder->root('notify_pnotify'); + $rootNode = $treeBuilder->root('flasher_pnotify'); } $rootNode diff --git a/src/Pnotify/Symfony/DependencyInjection/NotifyPnotifyExtension.php b/src/Pnotify/Symfony/DependencyInjection/FlasherPnotifyExtension.php similarity index 76% rename from src/Pnotify/Symfony/DependencyInjection/NotifyPnotifyExtension.php rename to src/Pnotify/Symfony/DependencyInjection/FlasherPnotifyExtension.php index a0f64bf8..065d888d 100644 --- a/src/Pnotify/Symfony/DependencyInjection/NotifyPnotifyExtension.php +++ b/src/Pnotify/Symfony/DependencyInjection/FlasherPnotifyExtension.php @@ -8,7 +8,7 @@ use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; use Symfony\Component\DependencyInjection\Loader; use Symfony\Component\HttpKernel\DependencyInjection\Extension; -final class NotifyPnotifyExtension extends Extension implements PrependExtensionInterface +final class FlasherPnotifyExtension extends Extension implements PrependExtensionInterface { /** * {@inheritdoc} @@ -18,7 +18,7 @@ final class NotifyPnotifyExtension extends Extension implements PrependExtension public function load(array $configs, ContainerBuilder $container) { $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); - $loader->load('services.yaml'); + $loader->load('config.yaml'); $configuration = new Configuration(); $this->processConfiguration($configuration, $configs); @@ -29,14 +29,14 @@ final class NotifyPnotifyExtension extends Extension implements PrependExtension */ public function prepend(ContainerBuilder $container) { - if (!$container->hasExtension('notify')) { - throw new \RuntimeException('[Flasher\SymfonyFlasher\PrimeBundle] is not registered'); + if (!$container->hasExtension('flasher')) { + throw new \RuntimeException('[Flasher\Symfony\FlasherBundle] is not registered'); } $configs = $container->getExtensionConfig($this->getAlias()); $config = $this->processConfiguration(new Configuration(), $configs); - $container->prependExtensionConfig('notify', array( + $container->prependExtensionConfig('flasher', array( 'adapters' => array( 'pnotify' => $config, ), diff --git a/src/Pnotify/Symfony/NotifyPnotifyBundle.php b/src/Pnotify/Symfony/FlasherPnotifyBundle.php similarity index 69% rename from src/Pnotify/Symfony/NotifyPnotifyBundle.php rename to src/Pnotify/Symfony/FlasherPnotifyBundle.php index 567b7c41..3f7bc315 100644 --- a/src/Pnotify/Symfony/NotifyPnotifyBundle.php +++ b/src/Pnotify/Symfony/FlasherPnotifyBundle.php @@ -4,6 +4,6 @@ namespace Flasher\Pnotify\Symfony; use Symfony\Component\HttpKernel\Bundle\Bundle; -class NotifyPnotifyBundle extends Bundle +class FlasherPnotifyBundle extends Bundle { } diff --git a/src/Pnotify/Symfony/Resources/config/config.yaml b/src/Pnotify/Symfony/Resources/config/config.yaml new file mode 100644 index 00000000..3c59e14c --- /dev/null +++ b/src/Pnotify/Symfony/Resources/config/config.yaml @@ -0,0 +1,16 @@ +services: + flasher.factory.pnotify: + parent: 'flasher.abstract_factory' + class: Flasher\Pnotify\Prime\PnotifyFactory + tags: + - { name: 'flasher.factory' } + + flasher.renderer.pnotify: + class: Flasher\PFlasher\Prime\PnotifyRenderer + arguments: + - '@flasher.config' + tags: + - { name: 'flasher.renderer' } + + Flasher\PFlasher\Prime\PnotifyFactory: '@flasher.factory.pnotify' + Flasher\PFlasher\Prime\PnotifyRenderer: '@flasher.renderer.pnotify' diff --git a/src/Pnotify/Symfony/Resources/config/services.yaml b/src/Pnotify/Symfony/Resources/config/services.yaml deleted file mode 100644 index 0fa5a2b2..00000000 --- a/src/Pnotify/Symfony/Resources/config/services.yaml +++ /dev/null @@ -1,16 +0,0 @@ -services: - flasher.factory.pnotify: - parent: 'flasher.factory.abstract' - class: Flasher\PFlasher\Prime\TestsProducer\PnotifyProducer - tags: - - { name: 'flasher.factory', alias: 'pnotify' } - - flasher.renderer.pnotify: - class: Flasher\PFlasher\Prime\Renderer\PnotifyRenderer - arguments: - - '@flasher.config' - tags: - - { name: 'flasher.renderer', alias: 'pnotify' } - - Flasher\PFlasher\Prime\TestsProducer\PnotifyProducer: '@flasher.factory.pnotify' - Flasher\PFlasher\Prime\Renderer\PnotifyRenderer: '@flasher.renderer.pnotify' diff --git a/src/Pnotify/Symfony/Tests/.gitkeep b/src/Pnotify/Symfony/Tests/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/src/Pnotify/Symfony/composer.json b/src/Pnotify/Symfony/composer.json index fc41b173..c5502c1b 100644 --- a/src/Pnotify/Symfony/composer.json +++ b/src/Pnotify/Symfony/composer.json @@ -1,5 +1,5 @@ { - "name": "php-flasher/flasher-symfony-pnotify", + "name": "php-flasher/flasher-pnotify-symfony", "type": "symfony-bundle", "description": "Symfony Flasher adapter for pnotify.js library for php-flasher/flasher-symfony", "keywords": [ @@ -29,20 +29,20 @@ "license": "MIT", "require": { "php": ">=5.3", - "php-flasher/flasher-symfony": "^1.0", - "php-flasher/flasher-pnotify": "^1.0" - }, - "require-dev": { - "phpunit/phpunit": "4.8.36" + "php-flasher/flasher-symfony": "dev-main", + "php-flasher/flasher-pnotify": "dev-main" }, "autoload": { "psr-4": { - "Flasher\\Symfony\\Pnotify\\": "src/" + "Flasher\\Pnotify\\Symfony\\": "", + "exclude-from-classmap": [ + "/Tests/" + ] } }, "autoload-dev": { "psr-4": { - "Flasher\\Symfony\\Pnotify\\Tests\\": "tests/" + "Flasher\\Pnotify\\Symfony\\Tests\\": "Tests/" } }, "config": { diff --git a/src/Prime/composer.json b/src/Prime/composer.json index 24522f01..b42998f6 100644 --- a/src/Prime/composer.json +++ b/src/Prime/composer.json @@ -27,9 +27,6 @@ "require": { "php": ">=5.3" }, - "require-dev": { - "phpunit/phpunit": ">=4.8.36" - }, "autoload": { "psr-4": { "Flasher\\Prime\\": "", diff --git a/src/SweetAlert/Laravel/NotifySweetAlertServiceProvider.php b/src/SweetAlert/Laravel/FlasherSweetAlertServiceProvider.php similarity index 92% rename from src/SweetAlert/Laravel/NotifySweetAlertServiceProvider.php rename to src/SweetAlert/Laravel/FlasherSweetAlertServiceProvider.php index b25b1ef4..e08952e8 100644 --- a/src/SweetAlert/Laravel/NotifySweetAlertServiceProvider.php +++ b/src/SweetAlert/Laravel/FlasherSweetAlertServiceProvider.php @@ -6,7 +6,7 @@ use Illuminate\Contracts\Support\DeferrableProvider; use Illuminate\Support\ServiceProvider; use Flasher\SweetAlert\Laravel\ServiceProvider\ServiceProviderManager; -class NotifySweetAlertServiceProvider extends ServiceProvider +final class FlasherSweetAlertServiceProvider extends ServiceProvider { public function boot() { @@ -31,7 +31,6 @@ class NotifySweetAlertServiceProvider extends ServiceProvider public function provides() { return array( - 'flasher.factory', 'flasher.factory.sweet_alert', 'flasher.renderer.sweet_alert', ); diff --git a/src/SweetAlert/Laravel/ServiceProvider/Providers/Laravel.php b/src/SweetAlert/Laravel/ServiceProvider/Providers/Laravel.php index ae5cf980..57ed86f8 100644 --- a/src/SweetAlert/Laravel/ServiceProvider/Providers/Laravel.php +++ b/src/SweetAlert/Laravel/ServiceProvider/Providers/Laravel.php @@ -4,9 +4,9 @@ namespace Flasher\SweetAlert\Laravel\ServiceProvider\Providers; use Flasher\Prime\Flasher; use Flasher\Prime\Renderer\RendererManager; -use Flasher\SweetAlert\LaravelFlasher\PrimeSweetAlertServiceProvider; -use Flasher\SweetAlert\Prime\Factory\SweetAlertProducer; -use Flasher\SweetAlert\Prime\Renderer\SweetAlertRenderer; +use Flasher\SweetAlert\Laravel\FlasherSweetAlertServiceProvider; +use Flasher\SweetAlert\Prime\SweetAlertFactory; +use Flasher\SweetAlert\Prime\SweetAlertRenderer; use Illuminate\Container\Container; use Illuminate\Foundation\Application; @@ -24,36 +24,36 @@ class Laravel implements ServiceProviderInterface return $this->app instanceof Application; } - public function publishConfig(NotifySweetAlertServiceProvider $provider) + public function publishConfig(FlasherSweetAlertServiceProvider $provider) { $source = realpath($raw = __DIR__.'/../../../resources/config/config.php') ?: $raw; - $provider->publishes(array($source => config_path('notify_sweet_alert.php')), 'config'); + $provider->publishes(array($source => config_path('flasher_sweet_alert.php')), 'config'); - $provider->mergeConfigFrom($source, 'notify_sweet_alert'); + $provider->mergeConfigFrom($source, 'flasher_sweet_alert'); } - public function registerNotifySweetAlertServices() + public function registerServices() { $this->app->singleton('flasher.factory.sweet_alert', function (Container $app) { - return new SweetAlertProducer($app['flasher.storage'], $app['flasher.middleware']); + return new SweetAlertFactory($app['flasher.event_dispatcher']); }); $this->app->singleton('flasher.renderer.sweet_alert', function (Container $app) { return new SweetAlertRenderer($app['flasher.config']); }); - $this->app->alias('flasher.factory.sweet_alert', 'Flasher\SweetAlert\Prime\Factory\SweetAlertProducer'); - $this->app->alias('flasher.renderer.sweet_alert', 'Flasher\SweetAlert\Prime\Renderer\SweetAlertRenderer'); + $this->app->alias('flasher.factory.sweet_alert', 'Flasher\SweetAlert\Prime\SweetAlertFactory'); + $this->app->alias('flasher.renderer.sweet_alert', 'Flasher\SweetAlert\Prime\SweetAlertRenderer'); - $this->app->extend('flasher.factory', function (Flasher $manager, Container $app) { - $manager->addDriver('sweet_alert', $app['flasher.factory.sweet_alert']); + $this->app->extend('flasher', function (Flasher $manager, Container $app) { + $manager->addDriver($app['flasher.factory.sweet_alert']); return $manager; }); - $this->app->extend('flasher.renderer', function (RendererManager $manager, Container $app) { - $manager->addDriver('sweet_alert', $app['flasher.renderer.sweet_alert']); + $this->app->extend('flasher.renderer_manager', function (RendererManager $manager, Container $app) { + $manager->addDriver($app['flasher.renderer.sweet_alert']); return $manager; }); @@ -63,7 +63,7 @@ class Laravel implements ServiceProviderInterface { $notifyConfig = $this->app['config']->get('flasher.adapters.sweet_alert', array()); - $sweetAlertConfig = $this->app['config']->get('notify_sweet_alert', array()); + $sweetAlertConfig = $this->app['config']->get('flasher_sweet_alert', array()); $this->app['config']->set('flasher.adapters.sweet_alert', array_merge($sweetAlertConfig, $notifyConfig)); } diff --git a/src/SweetAlert/Laravel/ServiceProvider/Providers/Laravel4.php b/src/SweetAlert/Laravel/ServiceProvider/Providers/Laravel4.php index 6f5a0dbe..455b0364 100644 --- a/src/SweetAlert/Laravel/ServiceProvider/Providers/Laravel4.php +++ b/src/SweetAlert/Laravel/ServiceProvider/Providers/Laravel4.php @@ -2,8 +2,8 @@ namespace Flasher\SweetAlert\Laravel\ServiceProvider\Providers; +use Flasher\SweetAlert\Laravel\FlasherSweetAlertServiceProvider; use Illuminate\Foundation\Application; -use Flasher\SweetAlert\LaravelFlasher\PrimeSweetAlertServiceProvider; final class Laravel4 extends Laravel { @@ -12,17 +12,17 @@ final class Laravel4 extends Laravel return $this->app instanceof Application && 0 === strpos(Application::VERSION, '4.'); } - public function publishConfig(NotifySweetAlertServiceProvider $provider) + public function publishConfig(FlasherSweetAlertServiceProvider $provider) { - $provider->package('php-flasher/flasher-laravel-sweet_alert', 'notify_sweet_alert', __DIR__.'/../../../resources'); + $provider->package('php-flasher/flasher-laravel-sweet_alert', 'flasher_sweet_alert', __DIR__.'/../../../resources'); } public function mergeConfigFromSweetAlert() { - $notifyConfig = $this->app['config']->get('notify::config.adapters.sweet_alert', array()); + $flasherConfig = $this->app['config']->get('flasher::config.adapters.sweet_alert', array()); - $sweet_alertConfig = $this->app['config']->get('notify_sweet_alert::config', array()); + $sweetAlertConfig = $this->app['config']->get('flasher_sweet_alert::config', array()); - $this->app['config']->set('notify::config.adapters.sweet_alert', array_merge($sweet_alertConfig, $notifyConfig)); + $this->app['config']->set('flasher::config.adapters.sweet_alert', array_merge($sweetAlertConfig, $flasherConfig)); } } diff --git a/src/SweetAlert/Laravel/ServiceProvider/Providers/Lumen.php b/src/SweetAlert/Laravel/ServiceProvider/Providers/Lumen.php index e58587c5..ed9edda2 100644 --- a/src/SweetAlert/Laravel/ServiceProvider/Providers/Lumen.php +++ b/src/SweetAlert/Laravel/ServiceProvider/Providers/Lumen.php @@ -2,8 +2,8 @@ namespace Flasher\SweetAlert\Laravel\ServiceProvider\Providers; +use Flasher\SweetAlert\Laravel\FlasherSweetAlertServiceProvider; use Laravel\Lumen\Application; -use Flasher\SweetAlert\LaravelFlasher\PrimeSweetAlertServiceProvider; final class Lumen extends Laravel { @@ -12,12 +12,12 @@ final class Lumen extends Laravel return $this->app instanceof Application; } - public function publishConfig(NotifySweetAlertServiceProvider $provider) + public function publishConfig(FlasherSweetAlertServiceProvider $provider) { $source = realpath($raw = __DIR__.'/../../../resources/config/config.php') ?: $raw; - $this->app->configure('notify_sweet_alert'); + $this->app->configure('flasher_sweet_alert'); - $provider->mergeConfigFrom($source, 'notify_sweet_alert'); + $provider->mergeConfigFrom($source, 'flasher_sweet_alert'); } } diff --git a/src/SweetAlert/Laravel/ServiceProvider/Providers/ServiceProviderInterface.php b/src/SweetAlert/Laravel/ServiceProvider/Providers/ServiceProviderInterface.php index 2cd261e6..f7d4ea9c 100644 --- a/src/SweetAlert/Laravel/ServiceProvider/Providers/ServiceProviderInterface.php +++ b/src/SweetAlert/Laravel/ServiceProvider/Providers/ServiceProviderInterface.php @@ -2,15 +2,15 @@ namespace Flasher\SweetAlert\Laravel\ServiceProvider\Providers; -use Flasher\SweetAlert\LaravelFlasher\PrimeSweetAlertServiceProvider; +use Flasher\SweetAlert\Laravel\FlasherSweetAlertServiceProvider; interface ServiceProviderInterface { public function shouldBeUsed(); - public function publishConfig(NotifySweetAlertServiceProvider $provider); + public function publishConfig(FlasherSweetAlertServiceProvider $provider); - public function registerNotifySweetAlertServices(); + public function registerServices(); public function mergeConfigFromSweetAlert(); } diff --git a/src/SweetAlert/Laravel/ServiceProvider/ServiceProviderManager.php b/src/SweetAlert/Laravel/ServiceProvider/ServiceProviderManager.php index 91a5bf74..7d482e1a 100644 --- a/src/SweetAlert/Laravel/ServiceProvider/ServiceProviderManager.php +++ b/src/SweetAlert/Laravel/ServiceProvider/ServiceProviderManager.php @@ -2,7 +2,7 @@ namespace Flasher\SweetAlert\Laravel\ServiceProvider; -use Flasher\SweetAlert\LaravelFlasher\PrimeSweetAlertServiceProvider; +use Flasher\SweetAlert\Laravel\FlasherSweetAlertServiceProvider; use Flasher\SweetAlert\Laravel\ServiceProvider\Providers\ServiceProviderInterface; final class ServiceProviderManager @@ -20,7 +20,7 @@ final class ServiceProviderManager private $notifyServiceProvider; - public function __construct(NotifySweetAlertServiceProvider $notifyServiceProvider) + public function __construct(FlasherSweetAlertServiceProvider $notifyServiceProvider) { $this->notifyServiceProvider = $notifyServiceProvider; } @@ -36,7 +36,7 @@ final class ServiceProviderManager public function register() { $provider = $this->resolveServiceProvider(); - $provider->registerNotifySweetAlertServices(); + $provider->registerServices(); } /** diff --git a/src/SweetAlert/Laravel/composer.json b/src/SweetAlert/Laravel/composer.json index e3df1526..06b76dca 100644 --- a/src/SweetAlert/Laravel/composer.json +++ b/src/SweetAlert/Laravel/composer.json @@ -1,5 +1,5 @@ { - "name": "php-flasher/flasher-laravel-sweet-alert", + "name": "php-flasher/flasher-sweet-alert-laravel", "description": "Laravel Flasher adapter package for php-flasher/flasher-sweet-alert", "keywords": [ "yoeunes", @@ -29,27 +29,26 @@ "license": "MIT", "require": { "php": ">=5.3", - "php-flasher/flasher-laravel": "^1.0.4", - "php-flasher/flasher-sweet-alert": "^1.0" - }, - "require-dev": { - "phpunit/phpunit": "^4.8 || ^5.7 || ^6.0 || ^7.0 || ^8.3 || ^9.0", - "orchestra/testbench": "^2.0 || ^3.0 || ^4.0 || ^5.0 || ^6.0" + "php-flasher/flasher-laravel": "dev-main", + "php-flasher/flasher-sweet-alert": "dev-main" }, "autoload": { "psr-4": { - "Flasher\\Laravel\\SweetAlert\\": "src/" + "Flasher\\Laravel\\SweetAlert\\": "", + "exclude-from-classmap": [ + "/Tests/" + ] } }, "autoload-dev": { "psr-4": { - "Flasher\\Laravel\\SweetAlert\\Tests\\": "tests/" + "Flasher\\Laravel\\SweetAlert\\Tests\\": "Tests/" } }, "extra": { "laravel": { "providers": [ - "Flasher\\Laravel\\SweetAlert\Flasher\PrimeSweetAlertServiceProvider" + "Flasher\\SweetAlert\\Laravel\\FlasherSweetAlertServiceProvider" ] } }, diff --git a/src/SweetAlert/Prime/Producer/SweetAlertProducer.php b/src/SweetAlert/Prime/Producer/SweetAlertProducer.php deleted file mode 100644 index 7de4427a..00000000 --- a/src/SweetAlert/Prime/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/src/SweetAlert/Prime/SweetAlert.php b/src/SweetAlert/Prime/SweetAlert.php new file mode 100644 index 00000000..966aa720 --- /dev/null +++ b/src/SweetAlert/Prime/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/src/SweetAlert/Prime/Renderer/SweetAlertRenderer.php b/src/SweetAlert/Prime/SweetAlertRenderer.php similarity index 74% rename from src/SweetAlert/Prime/Renderer/SweetAlertRenderer.php rename to src/SweetAlert/Prime/SweetAlertRenderer.php index 64045649..8f4d4a91 100644 --- a/src/SweetAlert/Prime/Renderer/SweetAlertRenderer.php +++ b/src/SweetAlert/Prime/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/src/SweetAlert/Prime/Tests/.gitkeep b/src/SweetAlert/Prime/Tests/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/src/SweetAlert/Prime/composer.json b/src/SweetAlert/Prime/composer.json index b7d3896e..ce74747a 100644 --- a/src/SweetAlert/Prime/composer.json +++ b/src/SweetAlert/Prime/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": { diff --git a/src/SweetAlert/Symfony/DependencyInjection/Configuration.php b/src/SweetAlert/Symfony/DependencyInjection/Configuration.php index a416b677..ea326e09 100644 --- a/src/SweetAlert/Symfony/DependencyInjection/Configuration.php +++ b/src/SweetAlert/Symfony/DependencyInjection/Configuration.php @@ -12,13 +12,13 @@ final class Configuration implements ConfigurationInterface */ public function getConfigTreeBuilder() { - $treeBuilder = new TreeBuilder('notify_sweet-alert'); + $treeBuilder = new TreeBuilder('flasher_sweet-alert'); if (\method_exists($treeBuilder, 'getRootNode')) { $rootNode = $treeBuilder->getRootNode(); } else { // BC layer for symfony/config 4.1 and older - $rootNode = $treeBuilder->root('notify_sweet_alert'); + $rootNode = $treeBuilder->root('flasher_sweet_alert'); } $rootNode diff --git a/src/SweetAlert/Symfony/DependencyInjection/NotifySweetAlertExtension.php b/src/SweetAlert/Symfony/DependencyInjection/FlasherSweetAlertExtension.php similarity index 71% rename from src/SweetAlert/Symfony/DependencyInjection/NotifySweetAlertExtension.php rename to src/SweetAlert/Symfony/DependencyInjection/FlasherSweetAlertExtension.php index 65717729..05a878c3 100644 --- a/src/SweetAlert/Symfony/DependencyInjection/NotifySweetAlertExtension.php +++ b/src/SweetAlert/Symfony/DependencyInjection/FlasherSweetAlertExtension.php @@ -8,7 +8,7 @@ use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; use Symfony\Component\DependencyInjection\Loader; use Symfony\Component\HttpKernel\DependencyInjection\Extension; -final class NotifySweetAlertExtension extends Extension implements PrependExtensionInterface +final class FlasherSweetAlertExtension extends Extension implements PrependExtensionInterface { /** * {@inheritdoc} @@ -18,7 +18,7 @@ final class NotifySweetAlertExtension extends Extension implements PrependExtens public function load(array $configs, ContainerBuilder $container) { $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config')); - $loader->load('services.yaml'); + $loader->load('config.yaml'); $configuration = new Configuration(); $this->processConfiguration($configuration, $configs); @@ -29,18 +29,14 @@ final class NotifySweetAlertExtension extends Extension implements PrependExtens */ public function prepend(ContainerBuilder $container) { - if (!$container->hasExtension('notify')) { - throw new \RuntimeException('[Flasher\SymfonyFlasher\PrimeBundle] is not registered'); + if (!$container->hasExtension('flasher')) { + throw new \RuntimeException('[Flasher\Symfony\FlasherBundle] is not registered'); } $configs = $container->getExtensionConfig($this->getAlias()); $config = $this->processConfiguration(new Configuration(), $configs); - $notifyConfig = $container->getExtensionConfig('notify'); - -// dd($notifyConfig); - - $container->prependExtensionConfig('notify', array( + $container->prependExtensionConfig('flasher', array( 'adapters' => array( 'sweet_alert' => $config, ), diff --git a/src/SweetAlert/Symfony/NotifySweetAlertBundle.php b/src/SweetAlert/Symfony/FlasherSweetAlertBundle.php similarity index 68% rename from src/SweetAlert/Symfony/NotifySweetAlertBundle.php rename to src/SweetAlert/Symfony/FlasherSweetAlertBundle.php index 30626a10..41cf2944 100644 --- a/src/SweetAlert/Symfony/NotifySweetAlertBundle.php +++ b/src/SweetAlert/Symfony/FlasherSweetAlertBundle.php @@ -4,6 +4,6 @@ namespace Flasher\SweetAlert\Symfony; use Symfony\Component\HttpKernel\Bundle\Bundle; -class NotifySweetAlertBundle extends Bundle +class FlasherSweetAlertBundle extends Bundle { } diff --git a/src/SweetAlert/Symfony/Resources/config/config.yaml b/src/SweetAlert/Symfony/Resources/config/config.yaml new file mode 100644 index 00000000..216a1343 --- /dev/null +++ b/src/SweetAlert/Symfony/Resources/config/config.yaml @@ -0,0 +1,16 @@ +services: + flasher.factory.sweet_alert: + parent: 'flasher.factory.abstract' + class: Flasher\SweetAlert\Prime\SweetAlertFactory + tags: + - { name: 'flasher.factory' } + + flasher.renderer.sweet_alert: + class: Flasher\SweetAlert\Prime\SweetAlertRenderer + arguments: + - '@flasher.config' + tags: + - { name: 'flasher.renderer' } + + Flasher\SweetAlert\Prime\SweetAlertFactory: '@flasher.factory.sweet_alert' + Flasher\SweetAlert\Prime\SweetAlertRenderer: '@flasher.renderer.sweet_alert' diff --git a/src/SweetAlert/Symfony/Resources/config/services.yaml b/src/SweetAlert/Symfony/Resources/config/services.yaml deleted file mode 100644 index 3b846895..00000000 --- a/src/SweetAlert/Symfony/Resources/config/services.yaml +++ /dev/null @@ -1,16 +0,0 @@ -services: - flasher.factory.sweet_alert: - parent: 'flasher.factory.abstract' - class: Flasher\SweetAlert\Prime\Factory\SweetAlertProducer - tags: - - { name: 'flasher.factory', alias: 'sweet_alert' } - - flasher.renderer.sweet_alert: - class: Flasher\SweetAlert\Prime\Renderer\SweetAlertRenderer - arguments: - - '@flasher.config' - tags: - - { name: 'flasher.renderer', alias: 'sweet_alert' } - - Flasher\SweetAlert\Prime\Factory\SweetAlertProducer: '@flasher.factory.sweet_alert' - Flasher\SweetAlert\Prime\Renderer\SweetAlertRenderer: '@flasher.renderer.sweet_alert' diff --git a/src/SweetAlert/Symfony/composer.json b/src/SweetAlert/Symfony/composer.json index 0f03b0a9..9e3a5583 100644 --- a/src/SweetAlert/Symfony/composer.json +++ b/src/SweetAlert/Symfony/composer.json @@ -1,5 +1,5 @@ { - "name": "php-flasher/flasher-symfony-sweet-alert", + "name": "php-flasher/flasher-sweet-alert-symfony", "type": "symfony-bundle", "description": "Symfony Flasher adapter for Sweet Alert 2 library for php-flasher/flasher-symfony", "keywords": [ @@ -30,20 +30,20 @@ "license": "MIT", "require": { "php": ">=5.3", - "php-flasher/flasher-symfony": "^1.0", - "php-flasher/flasher-sweet-alert": "^1.0" - }, - "require-dev": { - "phpunit/phpunit": "4.8.36" + "php-flasher/flasher-symfony": "dev-main", + "php-flasher/flasher-sweet-alert": "dev-main" }, "autoload": { "psr-4": { - "Flasher\\Symfony\\SweetAlert\\": "src/" + "Flasher\\SweetAlert\\Symfony\\": "", + "exclude-from-classmap": [ + "/Tests/" + ] } }, "autoload-dev": { "psr-4": { - "Flasher\\Symfony\\SweetAlert\\Tests\\": "tests/" + "Flasher\\SweetAlert\\Symfony\\Tests\\": "Tests/" } }, "config": { diff --git a/src/Symfony/composer.json b/src/Symfony/composer.json index 17ecef3a..cf6e9d4a 100644 --- a/src/Symfony/composer.json +++ b/src/Symfony/composer.json @@ -44,7 +44,10 @@ }, "autoload": { "psr-4": { - "Flasher\\Symfony\\": "" + "Flasher\\Symfony\\": "", + "exclude-from-classmap": [ + "/Tests/" + ] } }, "autoload-dev": { diff --git a/src/Toastr/Laravel/FlasherToastrServiceProvider.php b/src/Toastr/Laravel/FlasherToastrServiceProvider.php index 2d3022ee..3b03142c 100644 --- a/src/Toastr/Laravel/FlasherToastrServiceProvider.php +++ b/src/Toastr/Laravel/FlasherToastrServiceProvider.php @@ -6,7 +6,7 @@ use Illuminate\Contracts\Support\DeferrableProvider; use Illuminate\Support\ServiceProvider; use Flasher\Toastr\Laravel\ServiceProvider\ServiceProviderManager; -class FlasherToastrServiceProvider extends ServiceProvider +final class FlasherToastrServiceProvider extends ServiceProvider { public function boot() { diff --git a/src/Toastr/Laravel/tests/NotifyToastrServiceProviderTest.php b/src/Toastr/Laravel/Tests/NotifyToastrServiceProviderTest.php similarity index 100% rename from src/Toastr/Laravel/tests/NotifyToastrServiceProviderTest.php rename to src/Toastr/Laravel/Tests/NotifyToastrServiceProviderTest.php diff --git a/src/Toastr/Laravel/tests/TestCase.php b/src/Toastr/Laravel/Tests/TestCase.php similarity index 100% rename from src/Toastr/Laravel/tests/TestCase.php rename to src/Toastr/Laravel/Tests/TestCase.php diff --git a/src/Toastr/Laravel/composer.json b/src/Toastr/Laravel/composer.json index f7ac5694..697a934f 100644 --- a/src/Toastr/Laravel/composer.json +++ b/src/Toastr/Laravel/composer.json @@ -31,13 +31,12 @@ "php-flasher/flasher-laravel": "dev-main", "php-flasher/flasher-toastr": "dev-main" }, - "require-dev": { - "phpunit/phpunit": "^4.8|^5.7|^6.0|^7.0|^8.3|^9.0", - "orchestra/testbench": "^2.0|^3.0|^4.0|^5.0|^6.0" - }, "autoload": { "psr-4": { - "Flasher\\Toastr\\Laravel\\": "" + "Flasher\\Toastr\\Laravel\\": "", + "exclude-from-classmap": [ + "/Tests/" + ] } }, "autoload-dev": { diff --git a/src/Toastr/Prime/composer.json b/src/Toastr/Prime/composer.json index 1c8d5684..f7e763d2 100644 --- a/src/Toastr/Prime/composer.json +++ b/src/Toastr/Prime/composer.json @@ -27,12 +27,12 @@ "php": ">=5.3", "php-flasher/flasher": "dev-main" }, - "require-dev": { - "phpunit/phpunit": "^4.8|^5.7|^6.0|^7.0|^8.3|^9.0" - }, "autoload": { "psr-4": { - "Flasher\\Toastr\\": "" + "Flasher\\Toastr\\Prime\\": "", + "exclude-from-classmap": [ + "/Tests/" + ] } }, "autoload-dev": { diff --git a/src/Toastr/Symfony/composer.json b/src/Toastr/Symfony/composer.json index 41fd84bf..a940013a 100644 --- a/src/Toastr/Symfony/composer.json +++ b/src/Toastr/Symfony/composer.json @@ -32,12 +32,12 @@ "php-flasher/flasher-symfony": "dev-main", "php-flasher/flasher-toastr": "dev-main" }, - "require-dev": { - "phpunit/phpunit": "4.8.36" - }, "autoload": { "psr-4": { - "Flasher\\Toastr\\Symfony\\": "" + "Flasher\\Toastr\\Symfony\\": "", + "exclude-from-classmap": [ + "/Tests/" + ] } }, "autoload-dev": {