diff --git a/bin/release.sh b/bin/release.sh index 9f8244b7..2f99d378 100755 --- a/bin/release.sh +++ b/bin/release.sh @@ -57,6 +57,7 @@ for REMOTE in flasher flasher-laravel flasher-symfony \ flasher-notyf flasher-notyf-laravel flasher-notyf-symfony \ flasher-sweet-alert flasher-sweet-alert-laravel flasher-sweet-alert-symfony \ flasher-pnotify flasher-pnotify-laravel flasher-pnotify-symfony + flasher-noty flasher-noty-laravel flasher-noty-symfony do echo "" echo "" diff --git a/bin/split.sh b/bin/split.sh index ea1b1a54..96bdec99 100755 --- a/bin/split.sh +++ b/bin/split.sh @@ -38,6 +38,10 @@ remote pnotify git@github.com:php-flasher/flasher-pnotify.git remote pnotify-laravel git@github.com:php-flasher/flasher-pnotify-laravel.git remote pnotify-symfony git@github.com:php-flasher/flasher-pnotify-symfony.git +remote noty git@github.com:php-flasher/flasher-noty.git +remote noty-laravel git@github.com:php-flasher/flasher-noty-laravel.git +remote noty-symfony git@github.com:php-flasher/flasher-noty-symfony.git + split 'src/Prime' flasher split 'src/Laravel' laravel split 'src/Symfony' symfony @@ -57,3 +61,7 @@ split 'src/SweetAlert/Symfony' sweet-alert-symfony split 'src/Pnotify/Prime' pnotify split 'src/Pnotify/Laravel' pnotify-laravel split 'src/Pnotify/Symfony' pnotify-symfony + +split 'src/Noty/Prime' noty +split 'src/Noty/Laravel' noty-laravel +split 'src/Noty/Symfony' noty-symfony diff --git a/src/Noty/Laravel/.gitattributes b/src/Noty/Laravel/.gitattributes new file mode 100644 index 00000000..3383d44b --- /dev/null +++ b/src/Noty/Laravel/.gitattributes @@ -0,0 +1,13 @@ + +# Path-based git attributes +# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html + +# Ignore all test and documentation with "export-ignore". +/.gitattributes export-ignore +/.gitignore export-ignore +/.travis.yml export-ignore +/phpunit.xml.dist export-ignore +/.scrutinizer.yml export-ignore +/.styleci.yml export-ignore +/tests export-ignore +/.editorconfig export-ignore diff --git a/src/Noty/Laravel/.github/workflows/tests.yaml b/src/Noty/Laravel/.github/workflows/tests.yaml new file mode 100644 index 00000000..5c733a6b --- /dev/null +++ b/src/Noty/Laravel/.github/workflows/tests.yaml @@ -0,0 +1,119 @@ +name: Running tests + +on: + push: + pull_request: + schedule: + - cron: '0 * * * *' + +jobs: + test: + runs-on: ubuntu-latest + strategy: + fail-fast: true + matrix: + laravel: [8.*, 7.*, 6.*, 5.8.*, 5.7.*, 5.6.*, 5.5.*, 5.4.*, 5.3.*, 5.2.*, 5.1.*, 5.0.*, 4.2.*, 4.1.*, 4.0.*] + dependency-version: [prefer-lowest, prefer-stable] + include: + - laravel: 8.* + testbench: 6.* + php: 7.3 + phpunit: 9.3.* + + - laravel: 7.* + testbench: 5.* + php: 7.3 + phpunit: 8.4.* + + - laravel: 6.* + testbench: 4.* + php: 7.2 + phpunit: 8.3.* + + - laravel: 5.8.* + testbench: 3.8.* + php: 7.1 + phpunit: 7.5.* + + - laravel: 5.7.* + testbench: 3.7.* + php: 7.1 + phpunit: 7.0.* + + - laravel: 5.6.* + testbench: 3.6.* + php: 7.1 + phpunit: 7.0.* + + - laravel: 5.5.* + testbench: 3.5.* + php: 7.0 + phpunit: 6.0.* + + - laravel: 5.4.* + testbench: 3.4.* + php: 5.6 + phpunit: 5.7.* + + - laravel: 5.3.* + testbench: 3.3.* + php: 5.6 + phpunit: 4.8.* + + - laravel: 5.2.* + testbench: 3.2.* + php: 5.5 + phpunit: 4.8.* + + - laravel: 5.1.* + testbench: 3.1.* + php: 5.5 + phpunit: 4.8.* + + - laravel: 5.0.* + testbench: 3.0.* + php: 5.4 + phpunit: 4.8.* + + - laravel: 4.2.* + testbench: 2.2.* + php: 5.4 + phpunit: 4.8.* + + - laravel: 4.1.* + testbench: 2.1.* + php: 5.4 + phpunit: 4.8.* + + - laravel: 4.0.* + testbench: 2.0.* + php: 5.4 + phpunit: 4.8.* + + name: L${{ matrix.laravel }} - P${{ matrix.php }} - ${{ matrix.dependency-version }} + + steps: + - name: Checkout code + uses: actions/checkout@v1 + + - name: Cache dependencies + uses: actions/cache@v1 + with: + path: ~/.composer/cache/files + key: dependencies-laravel-${{ matrix.laravel }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick + # ini-values: memory_limit=-1 + coverage: none + + - name: Install dependencies + run: | + COMPOSER_MEMORY_LIMIT=-1 composer require "laravel/framework:${{ matrix.laravel }}" "phpunit/phpunit:${{ matrix.phpunit }}" "orchestra/testbench:${{ matrix.testbench }}" monolog/monolog --no-interaction --no-update + COMPOSER_MEMORY_LIMIT=-1 composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest + + - name: Execute tests + run: vendor/bin/phpunit diff --git a/src/Noty/Laravel/.gitignore b/src/Noty/Laravel/.gitignore new file mode 100644 index 00000000..409f0e32 --- /dev/null +++ b/src/Noty/Laravel/.gitignore @@ -0,0 +1,5 @@ +.idea/ +vendor/ +composer.lock +.phpunit.result.cache +.phpcs-cache diff --git a/src/Noty/Laravel/.phpcs.xml.dist b/src/Noty/Laravel/.phpcs.xml.dist new file mode 100644 index 00000000..93d245bc --- /dev/null +++ b/src/Noty/Laravel/.phpcs.xml.dist @@ -0,0 +1,625 @@ + + + + + + + + + + + + + src + tests + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + error + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Variable "%s" not allowed in double quoted string; use sprintf() or concatenation instead + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Noty/Laravel/.phpstorm.meta.php b/src/Noty/Laravel/.phpstorm.meta.php new file mode 100644 index 00000000..aa712a5c --- /dev/null +++ b/src/Noty/Laravel/.phpstorm.meta.php @@ -0,0 +1,14 @@ + '@'])); +override(RendererManager::make(''), map(['' => '@'])); +override(PresenterManager::make(''), map(['' => '@'])); diff --git a/src/Noty/Laravel/CHANGELOG.md b/src/Noty/Laravel/CHANGELOG.md new file mode 100644 index 00000000..e69de29b diff --git a/src/Noty/Laravel/FlasherNotyfServiceProvider.php b/src/Noty/Laravel/FlasherNotyfServiceProvider.php new file mode 100644 index 00000000..cb6179a7 --- /dev/null +++ b/src/Noty/Laravel/FlasherNotyfServiceProvider.php @@ -0,0 +1,62 @@ +boot(); + } + + /** + * Register the service provider. + */ + public function register() + { + $manager = new ServiceProviderManager($this); + $manager->register(); + } + + /** + * Get the services provided by the provider. + * + * @return string[] + */ + public function provides() + { + return array( + 'flasher.factory.noty', + 'flasher.renderer.noty', + ); + } + + /** + * @return Container + */ + public function getApplication() + { + return $this->app; + } + + /** + * {@inheritdoc} + */ + public function mergeConfigFrom($path, $key) + { + parent::mergeConfigFrom($path, $key); + } + + /** + * {@inheritdoc} + */ + public function publishes(array $paths, $groups = null) + { + parent::publishes($paths, $groups); + } +} diff --git a/src/Noty/Laravel/README.md b/src/Noty/Laravel/README.md new file mode 100644 index 00000000..cb61cc4d --- /dev/null +++ b/src/Noty/Laravel/README.md @@ -0,0 +1,51 @@ +

notify

+ +

Easy flash notifications for PHP, Laravel, Symfony, Lumen

+ +

:eyes: PHP Flasher library helps you to add flash notifications to your projects. This library was developed with the idea that you should be able to add flash notification to your application with ease and with few lines of code. No application-wide rewrites and no big investments upfront.

+ +

+ + + + + + + + + + + + + + + +

+ +## Introduction + +PHP Flasher library helps you to add flash notifications to your projects. This library was developed with the idea that you should be able to add flash notification to your application with ease and with few lines of code. No application-wide rewrites and no big investments upfront. + +# Why use PHP Flasher ? + +The PHP Flasher project supports a variety of notification libraries : __noty.js__, __sweet alert 2__, __pnotify__ and __notyf__ +and its highly extendable so you can add custom adapters. + +This library is designed, so you can take full control when creating you notifications : + +> * Display multiple notifications +> * Sort and filter notifications +> * Render notification from JSON response with Ajax or Websockets +> * Limit the number of displayed notifications +> * Show notifications from different adapters at the same time +> * implementations for popular frameworks : Symfony and Laravel +> * ...and more + + +## Official Documentation + +Documentation for Valet can be found on the [PHP Flasher website](https://php-flasher.github.io/). + +## License + +PHP Flasher is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT). diff --git a/src/Noty/Laravel/Resources/config/config.php b/src/Noty/Laravel/Resources/config/config.php new file mode 100644 index 00000000..aa583fe7 --- /dev/null +++ b/src/Noty/Laravel/Resources/config/config.php @@ -0,0 +1,31 @@ + array( + 'https://cdnjs.cloudflare.com/ajax/libs/noty/3.1.4/noty.min.js', + ), + 'styles' => array( + 'https://cdnjs.cloudflare.com/ajax/libs/noty/3.1.4/noty.min.css', + ), + 'options' => array( + 'layout' => 'topRight', + 'theme' => 'mint', + 'timeout' => 5000, + 'progressBar' => true, + 'animation.open' => 'noty_effects_open', + 'animation.close' => 'noty_effects_close', + 'sounds.sources' => array(), + 'closeWith' => array('click'), + 'sounds.volume' => 1, + 'sounds.conditions' => array(), + 'docTitle.conditions' => array(), + 'modal' => false, + 'id' => false, + 'force' => false, + 'queue' => 'global', + 'killer' => false, + 'container' => false, + 'buttons' => array(), + 'visibilityControl' => false, + ), +); diff --git a/src/Noty/Laravel/ServiceProvider/Providers/Laravel.php b/src/Noty/Laravel/ServiceProvider/Providers/Laravel.php new file mode 100644 index 00000000..45506e0b --- /dev/null +++ b/src/Noty/Laravel/ServiceProvider/Providers/Laravel.php @@ -0,0 +1,70 @@ +app = $app; + } + + public function shouldBeUsed() + { + return $this->app instanceof Application; + } + + public function publishConfig(FlasherNotyfServiceProvider $provider) + { + $source = realpath($raw = __DIR__.'/../../Resources/config/config.php') ?: $raw; + + $provider->publishes(array($source => config_path('flasher_noty.php')), 'config'); + + $provider->mergeConfigFrom($source, 'flasher_noty'); + } + + public function registerServices() + { + $this->app->singleton('flasher.factory.noty', function (Container $app) { + return new NotyFactory($app['flasher.event_dispatcher']); + }); + + $this->app->singleton('flasher.renderer.noty', function (Container $app) { + return new NotyRenderer($app['flasher.config']); + }); + + $this->app->alias('flasher.factory.noty', 'Flasher\Noty\Prime\NotyFactory'); + $this->app->alias('flasher.renderer.noty', 'Flasher\Noty\Prime\NotyRenderer'); + + $this->app->extend('flasher', function (Flasher $flasher, Container $app) { + $flasher->addDriver($app['flasher.factory.noty']); + + return $flasher; + }); + + $this->app->extend('flasher.renderer_manager', function (RendererManager $manager, Container $app) { + $manager->addDriver($app['flasher.renderer.noty']); + + return $manager; + }); + } + + public function mergeConfigFromNoty() + { + $flasherConfig = $this->app['config']->get('flasher.adapters.noty', array()); + + $notyConfig = $this->app['config']->get('flasher_noty', array()); + + $this->app['config']->set('flasher.adapters.noty', array_merge($notyConfig, $flasherConfig)); + } +} diff --git a/src/Noty/Laravel/ServiceProvider/Providers/Laravel4.php b/src/Noty/Laravel/ServiceProvider/Providers/Laravel4.php new file mode 100644 index 00000000..50cb967f --- /dev/null +++ b/src/Noty/Laravel/ServiceProvider/Providers/Laravel4.php @@ -0,0 +1,28 @@ +app instanceof Application && 0 === strpos(Application::VERSION, '4.'); + } + + public function publishConfig(FlasherNotyfServiceProvider $provider) + { + $provider->package('php-flasher/flasher-noty-laravel', 'flasher_noty', __DIR__.'/../../Resources'); + } + + public function mergeConfigFromNoty() + { + $flasherConfig = $this->app['config']->get('flasher::config.adapters.noty', array()); + + $notyConfig = $this->app['config']->get('flasher_noty::config', array()); + + $this->app['config']->set('flasher::config.adapters.noty', array_merge($notyConfig, $flasherConfig)); + } +} diff --git a/src/Noty/Laravel/ServiceProvider/Providers/Lumen.php b/src/Noty/Laravel/ServiceProvider/Providers/Lumen.php new file mode 100644 index 00000000..bcc9ad47 --- /dev/null +++ b/src/Noty/Laravel/ServiceProvider/Providers/Lumen.php @@ -0,0 +1,23 @@ +app instanceof Application; + } + + public function publishConfig(FlasherNotyfServiceProvider $provider) + { + $source = realpath($raw = __DIR__.'/../../Resources/config/config.php') ?: $raw; + + $this->app->configure('flasher_noty'); + + $provider->mergeConfigFrom($source, 'flasher_noty'); + } +} diff --git a/src/Noty/Laravel/ServiceProvider/Providers/ServiceProviderInterface.php b/src/Noty/Laravel/ServiceProvider/Providers/ServiceProviderInterface.php new file mode 100644 index 00000000..25803880 --- /dev/null +++ b/src/Noty/Laravel/ServiceProvider/Providers/ServiceProviderInterface.php @@ -0,0 +1,16 @@ +notifyServiceProvider = $notifyServiceProvider; + } + + public function boot() + { + $provider = $this->resolveServiceProvider(); + + $provider->publishConfig($this->notifyServiceProvider); + $provider->mergeConfigFromNoty(); + } + + public function register() + { + $provider = $this->resolveServiceProvider(); + $provider->registerServices(); + } + + /** + * @return ServiceProviderInterface + */ + private function resolveServiceProvider() + { + if ($this->provider instanceof ServiceProviderInterface) { + return $this->provider; + } + + foreach ($this->providers as $providerClass) { + $provider = new $providerClass($this->notifyServiceProvider->getApplication()); + + if ($provider->shouldBeUsed()) { + return $this->provider = $provider; + } + } + + throw new \InvalidArgumentException('Service Provider not found.'); + } +} diff --git a/src/Noty/Laravel/Tests/FlasherNotyServiceProviderTest.php b/src/Noty/Laravel/Tests/FlasherNotyServiceProviderTest.php new file mode 100644 index 00000000..24aca4b5 --- /dev/null +++ b/src/Noty/Laravel/Tests/FlasherNotyServiceProviderTest.php @@ -0,0 +1,43 @@ +assertTrue($this->app->bound('flasher')); + $this->assertTrue($this->app->bound('flasher.factory.noty')); + } + + public function testNotifyFactoryIsAddedToExtensionsArray() + { + $flasher = $this->app->make('flasher'); + + $reflection = new \ReflectionClass($flasher); + $property = $reflection->getProperty('drivers'); + $property->setAccessible(true); + + $extensions = $property->getValue($flasher); + + $this->assertCount(1, $extensions); + $this->assertInstanceOf('Flasher\Prime\Factory\FlasherFactoryInterface', $extensions[0]); + } + + public function testConfigNotyInjectedInGlobalNotifyConfig() + { + $flasher = $this->app->make('flasher'); + + $reflection = new \ReflectionClass($flasher); + $property = $reflection->getProperty('config'); + $property->setAccessible(true); + + $config = $property->getValue($flasher); + + $this->assertArrayHasKey('noty', $config->get('adapters')); + + $this->assertEquals(array( + 'noty' => array('scripts' => array('jquery.js'), 'styles' => array('styles.css'), 'options' => array()), + ), $config->get('adapters')); + } +} diff --git a/src/Noty/Laravel/Tests/TestCase.php b/src/Noty/Laravel/Tests/TestCase.php new file mode 100644 index 00000000..99dd7a36 --- /dev/null +++ b/src/Noty/Laravel/Tests/TestCase.php @@ -0,0 +1,94 @@ +isLaravel4() ? '::config' : ''; + + $app['config']->set('session'.$separator.'.driver', 'array'); + $app['config']->set('flasher'.$separator.'.adapters', array( + 'noty' => array('scripts' => array('jquery.js'), 'styles' => array('styles.css'), 'options' => array()), + )); + } + + private function isLaravel4() + { + return 0 === strpos(Application::VERSION, '4.'); + } + + /** + * {@inheritdoc} + */ + public function createApplication() + { + if (0 !== strpos(Application::VERSION, '4.0')) { + return parent::createApplication(); + } + + $app = new Application; + + $app->detectEnvironment(array( + 'local' => array('your-machine-name'), + )); + + $app->bindInstallPaths($this->getApplicationPaths()); + + $app['env'] = 'testing'; + + $app->instance('app', $app); + + Facade::clearResolvedInstances(); + Facade::setFacadeApplication($app); + + $config = new Config($app->getConfigLoader(), $app['env']); + $app->instance('config', $config); + $app->startExceptionHandling(); + + if ($app->runningInConsole()) + { + $app->setRequestForConsoleEnvironment(); + } + + date_default_timezone_set($this->getApplicationTimezone()); + + $aliases = array_merge($this->getApplicationAliases(), $this->getPackageAliases()); + AliasLoader::getInstance($aliases)->register(); + + Request::enableHttpMethodParameterOverride(); + + $providers = array_merge($this->getApplicationProviders(), $this->getPackageProviders()); + $app->getProviderRepository()->load($app, $providers); + + $this->getEnvironmentSetUp($app); + + $app->boot(); + + return $app; + } +} diff --git a/src/Noty/Laravel/UPGRADING.md b/src/Noty/Laravel/UPGRADING.md new file mode 100644 index 00000000..e69de29b diff --git a/src/Noty/Laravel/composer.json b/src/Noty/Laravel/composer.json new file mode 100644 index 00000000..a21e7acb --- /dev/null +++ b/src/Noty/Laravel/composer.json @@ -0,0 +1,63 @@ +{ + "name": "php-flasher/flasher-noty-laravel", + "description": "Laravel Flasher adapter package for php-flasher/flasher-noty", + "keywords": [ + "yoeunes", + "notify", + "php", + "laravel", + "symfony", + "Lumen", + "notifications", + "messages", + "alerts", + "pnotify", + "noty ", + "bundle", + "flex" + ], + "homepage": "https://github.com/php-flasher/flasher-laravel-noty", + "authors": [ + { + "name": "Younes Khoubza", + "email": "younes.khoubza@gmail.com", + "homepage": "https://github.com/yoeunes", + "role": "Developer" + } + ], + "license": "MIT", + "require": { + "php": ">=5.3", + "php-flasher/flasher-laravel": "dev-main", + "php-flasher/flasher-noty": "dev-main" + }, + "require-dev": { + "phpunit/phpunit": "^4.8|^5.0|^6.0|^7.0|^8.0|^9.0", + "orchestra/testbench": "^2.0|^3.0|^4.0|^5.0|^6.0" + }, + "autoload": { + "psr-4": { + "Flasher\\Noty\\Laravel\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "autoload-dev": { + "psr-4": { + "Flasher\\Noty\\Laravel\\Tests\\": "Tests/" + } + }, + "extra": { + "laravel": { + "providers": [ + "FlasherNotyfServiceProvider" + ] + } + }, + "config": { + "sort-packages": true + }, + "minimum-stability": "dev", + "prefer-stable": true +} diff --git a/src/Noty/Laravel/phpunit.xml.dist b/src/Noty/Laravel/phpunit.xml.dist new file mode 100644 index 00000000..3b5c944f --- /dev/null +++ b/src/Noty/Laravel/phpunit.xml.dist @@ -0,0 +1,22 @@ + + + + + Tests + + + + + ./ + + + diff --git a/src/Noty/Prime/.gitattributes b/src/Noty/Prime/.gitattributes new file mode 100644 index 00000000..3383d44b --- /dev/null +++ b/src/Noty/Prime/.gitattributes @@ -0,0 +1,13 @@ + +# Path-based git attributes +# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html + +# Ignore all test and documentation with "export-ignore". +/.gitattributes export-ignore +/.gitignore export-ignore +/.travis.yml export-ignore +/phpunit.xml.dist export-ignore +/.scrutinizer.yml export-ignore +/.styleci.yml export-ignore +/tests export-ignore +/.editorconfig export-ignore diff --git a/src/Noty/Prime/.github/workflows/tests.yaml b/src/Noty/Prime/.github/workflows/tests.yaml new file mode 100644 index 00000000..a8ee59d7 --- /dev/null +++ b/src/Noty/Prime/.github/workflows/tests.yaml @@ -0,0 +1,52 @@ +name: Running tests + +on: + push: + pull_request: + schedule: + - cron: '0 * * * *' + +jobs: + test: + runs-on: ubuntu-latest + strategy: + fail-fast: true + matrix: + php: [ 8.0, 7.4, 7.3, 7.2, 7.1, 7.0, 5.6, 5.5, 5.4 ] + dependency-version: [ prefer-lowest, prefer-stable ] + + name: php ${{ matrix.php }} - ${{ matrix.dependency-version }} + + steps: + - name: Checkout code + uses: actions/checkout@v1 + + - name: Cache dependencies + uses: actions/cache@v1 + with: + path: ~/.composer/cache/files + key: php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + coverage: none + + - name: Require phpunit 4.8 for php <= 5.6 + if: matrix.php <= 5.6 + run: COMPOSER_MEMORY_LIMIT=-1 composer require "phpunit/phpunit:4.8.36" --no-interaction --no-update + + - name: Require phpunit 6 for php >= 7.0 + if: matrix.php >= 7.0 + run: COMPOSER_MEMORY_LIMIT=-1 composer require "phpunit/phpunit:6.*" --no-interaction --no-update + + - name: Require phpunit 9 for php >= 7.3 + if: matrix.php >= 7.3 + run: COMPOSER_MEMORY_LIMIT=-1 composer require "phpunit/phpunit:9.*" --no-interaction --no-update + + - name: Install dependencies + run: COMPOSER_MEMORY_LIMIT=-1 composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest + + - name: Execute tests + run: vendor/bin/phpunit diff --git a/src/Noty/Prime/.gitignore b/src/Noty/Prime/.gitignore new file mode 100644 index 00000000..409f0e32 --- /dev/null +++ b/src/Noty/Prime/.gitignore @@ -0,0 +1,5 @@ +.idea/ +vendor/ +composer.lock +.phpunit.result.cache +.phpcs-cache diff --git a/src/Noty/Prime/.phpcs.xml.dist b/src/Noty/Prime/.phpcs.xml.dist new file mode 100644 index 00000000..93d245bc --- /dev/null +++ b/src/Noty/Prime/.phpcs.xml.dist @@ -0,0 +1,625 @@ + + + + + + + + + + + + + src + tests + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + error + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Variable "%s" not allowed in double quoted string; use sprintf() or concatenation instead + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Noty/Prime/.phpstorm.meta.php b/src/Noty/Prime/.phpstorm.meta.php new file mode 100644 index 00000000..400d7b42 --- /dev/null +++ b/src/Noty/Prime/.phpstorm.meta.php @@ -0,0 +1,9 @@ +getEventDispatcher(), $this->createNotification(), 'noty'); + } + + /** + * @inheritDoc + */ + public function supports($name = null, array $context = array()) + { + return in_array($name, array(__CLASS__, 'noty')); + } +} diff --git a/src/Noty/Prime/NotyRenderer.php b/src/Noty/Prime/NotyRenderer.php new file mode 100644 index 00000000..a3c817e8 --- /dev/null +++ b/src/Noty/Prime/NotyRenderer.php @@ -0,0 +1,84 @@ +config = $config; + $this->scripts = $config->get('adapters.noty.scripts', array()); + $this->styles = $config->get('adapters.noty.styles', array()); + $this->options = $config->get('adapters.noty.options', array()); + } + + /** + * @inheritDoc + */ + public function render(Envelope $envelope) + { + $notification = $envelope->getNotification(); + $options = $envelope->getOptions(); + + $options['message'] = $envelope->getMessage(); + $options['type'] = $envelope->getType(); + + return sprintf("new Noty(%s);", json_encode($options)); + } + + /** + * @inheritDoc + */ + public function getScripts() + { + return $this->scripts; + } + + /** + * @inheritDoc + */ + public function getStyles() + { + return $this->styles; + } + + public function renderOptions() + { + return sprintf('Noty.overrideDefaults(%s);', json_encode($this->options)); + } + + /** + * @inheritDoc + */ + public function supports($name = null, array $context = array()) + { + return in_array($name, array(__CLASS__, 'noty', 'Flasher\Noty\Prime\NotyFactory', 'Flasher\Noty\Prime\Noty')); + } +} diff --git a/src/Noty/Prime/README.md b/src/Noty/Prime/README.md new file mode 100644 index 00000000..cb61cc4d --- /dev/null +++ b/src/Noty/Prime/README.md @@ -0,0 +1,51 @@ +

notify

+ +

Easy flash notifications for PHP, Laravel, Symfony, Lumen

+ +

:eyes: PHP Flasher library helps you to add flash notifications to your projects. This library was developed with the idea that you should be able to add flash notification to your application with ease and with few lines of code. No application-wide rewrites and no big investments upfront.

+ +

+ + + + + + + + + + + + + + + +

+ +## Introduction + +PHP Flasher library helps you to add flash notifications to your projects. This library was developed with the idea that you should be able to add flash notification to your application with ease and with few lines of code. No application-wide rewrites and no big investments upfront. + +# Why use PHP Flasher ? + +The PHP Flasher project supports a variety of notification libraries : __noty.js__, __sweet alert 2__, __pnotify__ and __notyf__ +and its highly extendable so you can add custom adapters. + +This library is designed, so you can take full control when creating you notifications : + +> * Display multiple notifications +> * Sort and filter notifications +> * Render notification from JSON response with Ajax or Websockets +> * Limit the number of displayed notifications +> * Show notifications from different adapters at the same time +> * implementations for popular frameworks : Symfony and Laravel +> * ...and more + + +## Official Documentation + +Documentation for Valet can be found on the [PHP Flasher website](https://php-flasher.github.io/). + +## License + +PHP Flasher is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT). diff --git a/src/Noty/Prime/Tests/.gitkeep b/src/Noty/Prime/Tests/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/src/Noty/Prime/UPGRADING.md b/src/Noty/Prime/UPGRADING.md new file mode 100644 index 00000000..e69de29b diff --git a/src/Noty/Prime/composer.json b/src/Noty/Prime/composer.json new file mode 100644 index 00000000..e54c84f6 --- /dev/null +++ b/src/Noty/Prime/composer.json @@ -0,0 +1,51 @@ +{ + "name": "php-flasher/flasher-noty", + "description": "PHP noty adapter for php-flasher/flasher", + "keywords": [ + "notify", + "php", + "laravel", + "symfony", + "Lumen", + "notifications", + "messages", + "alerts", + "pnotify", + "noty " + ], + "homepage": "https://github.com/php-flasher/flasher-noty", + "authors": [ + { + "name": "Younes Khoubza", + "email": "younes.khoubza@gmail.com", + "homepage": "https://github.com/yoeunes", + "role": "Developer" + } + ], + "license": "MIT", + "require": { + "php": ">=5.3", + "php-flasher/flasher": "dev-main" + }, + "require-dev": { + "phpunit/phpunit": "^4.8|^5.0|^6.0|^7.0|^8.0|^9.0" + }, + "autoload": { + "psr-4": { + "Flasher\\Noty\\Prime\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "autoload-dev": { + "psr-4": { + "Flasher\\Noty\\Prime\\Tests\\": "Tests/" + } + }, + "config": { + "sort-packages": true + }, + "minimum-stability": "dev", + "prefer-stable": true +} diff --git a/src/Noty/Prime/phpunit.xml.dist b/src/Noty/Prime/phpunit.xml.dist new file mode 100644 index 00000000..3b5c944f --- /dev/null +++ b/src/Noty/Prime/phpunit.xml.dist @@ -0,0 +1,22 @@ + + + + + Tests + + + + + ./ + + + diff --git a/src/Noty/Symfony/.gitattributes b/src/Noty/Symfony/.gitattributes new file mode 100644 index 00000000..3383d44b --- /dev/null +++ b/src/Noty/Symfony/.gitattributes @@ -0,0 +1,13 @@ + +# Path-based git attributes +# https://www.kernel.org/pub/software/scm/git/docs/gitattributes.html + +# Ignore all test and documentation with "export-ignore". +/.gitattributes export-ignore +/.gitignore export-ignore +/.travis.yml export-ignore +/phpunit.xml.dist export-ignore +/.scrutinizer.yml export-ignore +/.styleci.yml export-ignore +/tests export-ignore +/.editorconfig export-ignore diff --git a/src/Noty/Symfony/.github/workflows/tests.yaml b/src/Noty/Symfony/.github/workflows/tests.yaml new file mode 100644 index 00000000..5bd77994 --- /dev/null +++ b/src/Noty/Symfony/.github/workflows/tests.yaml @@ -0,0 +1,104 @@ +name: Running tests + +on: + push: + pull_request: + schedule: + - cron: '0 * * * *' + +jobs: + test: + runs-on: ubuntu-latest + strategy: + fail-fast: true + matrix: + symfony: [5.2.*, 5.1.*, 5.0.*, 4.4.*, 4.3.*, 4.2.*, 4.1.*, 4.0.*, 3.4.*, 3.3.*, 3.2.*, 3.1.*, 3.0.*, 2.8.*, 2.7.*] + dependency-version: [prefer-lowest, prefer-stable] + include: + - symfony: 5.2.* + php: 7.2 + phpunit: 8.3.* + + - symfony: 5.1.* + php: 7.2 + phpunit: 8.3.* + + - symfony: 5.0.* + php: 7.2 + phpunit: 8.3.* + + - symfony: 4.4.* + php: 7.1 + phpunit: 7.0.* + + - symfony: 4.3.* + php: 7.1 + phpunit: 7.0.* + + - symfony: 4.2.* + php: 7.1 + phpunit: 7.0.* + + - symfony: 4.1.* + php: 7.1 + phpunit: 7.0.* + + - symfony: 4.0.* + php: 7.1 + phpunit: 7.0.* + + - symfony: 3.4.* + php: 5.5 + phpunit: 4.8.36 + + - symfony: 3.3.* + php: 5.5 + phpunit: 4.8.36 + + - symfony: 3.2.* + php: 5.5 + phpunit: 4.8.36 + + - symfony: 3.1.* + php: 5.5 + phpunit: 4.8.36 + + - symfony: 3.0.* + php: 5.5 + phpunit: 4.8.36 + + - symfony: 2.8.* + php: 5.3 + phpunit: 4.8.36 + + - symfony: 2.7.* + php: 5.3 + phpunit: 4.8.36 + + name: S${{ matrix.symfony }} - P${{ matrix.php }} - ${{ matrix.dependency-version }} + + steps: + - name: Checkout code + uses: actions/checkout@v1 + + - name: Cache dependencies + uses: actions/cache@v1 + with: + path: ~/.composer/cache/files + key: dependencies-symfony-${{ matrix.symfony }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick + coverage: none + + - name: Install dependencies + run: | + COMPOSER_MEMORY_LIMIT=-1 composer require "symfony/symfony:${{ matrix.symfony }}" "phpunit/phpunit:${{ matrix.phpunit }}" --no-interaction --no-update + COMPOSER_MEMORY_LIMIT=-1 composer config extra.symfony.require "${{ matrix.symfony }}" + COMPOSER_MEMORY_LIMIT=-1 composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest + + - name: Execute tests + run: vendor/bin/phpunit diff --git a/src/Noty/Symfony/.gitignore b/src/Noty/Symfony/.gitignore new file mode 100644 index 00000000..409f0e32 --- /dev/null +++ b/src/Noty/Symfony/.gitignore @@ -0,0 +1,5 @@ +.idea/ +vendor/ +composer.lock +.phpunit.result.cache +.phpcs-cache diff --git a/src/Noty/Symfony/.phpcs.xml.dist b/src/Noty/Symfony/.phpcs.xml.dist new file mode 100644 index 00000000..93d245bc --- /dev/null +++ b/src/Noty/Symfony/.phpcs.xml.dist @@ -0,0 +1,625 @@ + + + + + + + + + + + + + src + tests + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + error + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Variable "%s" not allowed in double quoted string; use sprintf() or concatenation instead + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Noty/Symfony/.phpstorm.meta.php b/src/Noty/Symfony/.phpstorm.meta.php new file mode 100644 index 00000000..aa712a5c --- /dev/null +++ b/src/Noty/Symfony/.phpstorm.meta.php @@ -0,0 +1,14 @@ + '@'])); +override(RendererManager::make(''), map(['' => '@'])); +override(PresenterManager::make(''), map(['' => '@'])); diff --git a/src/Noty/Symfony/CHANGELOG.md b/src/Noty/Symfony/CHANGELOG.md new file mode 100644 index 00000000..e69de29b diff --git a/src/Noty/Symfony/DependencyInjection/Configuration.php b/src/Noty/Symfony/DependencyInjection/Configuration.php new file mode 100644 index 00000000..ea6cecac --- /dev/null +++ b/src/Noty/Symfony/DependencyInjection/Configuration.php @@ -0,0 +1,68 @@ +getRootNode(); + } else { + // BC layer for symfony/config 4.1 and older + $rootNode = $treeBuilder->root('flasher_noty'); + } + + $rootNode + ->children() + ->arrayNode('scripts') + ->prototype('scalar')->end() + ->defaultValue(array( + 'https://cdnjs.cloudflare.com/ajax/libs/noty/3.1.4/noty.min.js', + )) + ->end() + ->arrayNode('styles') + ->prototype('scalar')->end() + ->defaultValue(array( + 'https://cdnjs.cloudflare.com/ajax/libs/noty/3.1.4/noty.min.css', + )) + ->end() + ->arrayNode('options') + ->prototype('variable')->end() + ->ignoreExtraKeys(false) + ->defaultValue(array( + 'layout' => 'topRight', + 'theme' => 'mint', + 'timeout' => 5000, + 'progressBar' => true, + 'animation.open' => 'noty_effects_open', + 'animation.close' => 'noty_effects_close', + 'sounds.sources' => array(), + 'closeWith' => array('click'), + 'sounds.volume' => 1, + 'sounds.conditions' => array(), + 'docTitle.conditions' => array(), + 'modal' => false, + 'id' => false, + 'force' => false, + 'queue' => 'global', + 'killer' => false, + 'container' => false, + 'buttons' => array(), + 'visibilityControl' => false, + )) + ->end() + ->end() + ; + + return $treeBuilder; + } +} diff --git a/src/Noty/Symfony/DependencyInjection/FlasherNotyExtension.php b/src/Noty/Symfony/DependencyInjection/FlasherNotyExtension.php new file mode 100644 index 00000000..7d1dd5c1 --- /dev/null +++ b/src/Noty/Symfony/DependencyInjection/FlasherNotyExtension.php @@ -0,0 +1,45 @@ +load('config.yaml'); + + $configuration = new Configuration(); + $this->processConfiguration($configuration, $configs); + } + + /** + * {@inheritdoc} + */ + public function prepend(ContainerBuilder $container) + { + if (!$container->hasExtension('flasher')) { + throw new \RuntimeException('[Flasher\SymfonyFlasher\PrimeBundle] is not registered'); + } + + $configs = $container->getExtensionConfig($this->getAlias()); + $config = $this->processConfiguration(new Configuration(), $configs); + + $container->prependExtensionConfig('flasher', array( + 'adapters' => array( + 'noty' => $config, + ), + )); + } +} diff --git a/src/Noty/Symfony/FlasherNotyBundle.php b/src/Noty/Symfony/FlasherNotyBundle.php new file mode 100644 index 00000000..5eca3241 --- /dev/null +++ b/src/Noty/Symfony/FlasherNotyBundle.php @@ -0,0 +1,9 @@ +notify

+ +

Easy flash notifications for PHP, Laravel, Symfony, Lumen

+ +

:eyes: PHP Flasher library helps you to add flash notifications to your projects. This library was developed with the idea that you should be able to add flash notification to your application with ease and with few lines of code. No application-wide rewrites and no big investments upfront.

+ +

+ + + + + + + + + + + + + + + +

+ +## Introduction + +PHP Flasher library helps you to add flash notifications to your projects. This library was developed with the idea that you should be able to add flash notification to your application with ease and with few lines of code. No application-wide rewrites and no big investments upfront. + +# Why use PHP Flasher ? + +The PHP Flasher project supports a variety of notification libraries : __noty.js__, __sweet alert 2__, __pnotify__ and __notyf__ +and its highly extendable so you can add custom adapters. + +This library is designed, so you can take full control when creating you notifications : + +> * Display multiple notifications +> * Sort and filter notifications +> * Render notification from JSON response with Ajax or Websockets +> * Limit the number of displayed notifications +> * Show notifications from different adapters at the same time +> * implementations for popular frameworks : Symfony and Laravel +> * ...and more + + +## Official Documentation + +Documentation for Valet can be found on the [PHP Flasher website](https://php-flasher.github.io/). + +## License + +PHP Flasher is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT). diff --git a/src/Noty/Symfony/Resources/config/config.yaml b/src/Noty/Symfony/Resources/config/config.yaml new file mode 100644 index 00000000..fd83957e --- /dev/null +++ b/src/Noty/Symfony/Resources/config/config.yaml @@ -0,0 +1,16 @@ +services: + flasher.factory.noty: + parent: 'flasher.abstract_factory' + class: Flasher\Noty\Prime\NotyFactory + tags: + - { name: 'flasher.factory' } + + flasher.renderer.noty: + class: Flasher\Noty\Prime\NotyRenderer + arguments: + - '@flasher.config' + tags: + - { name: 'flasher.renderer' } + + Flasher\Noty\Prime\NotyFactory: '@flasher.factory.noty' + Flasher\Noty\Prime\NotyRenderer: '@flasher.renderer.noty' diff --git a/src/Noty/Symfony/Tests/.gitkeep b/src/Noty/Symfony/Tests/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/src/Noty/Symfony/UPGRADING.md b/src/Noty/Symfony/UPGRADING.md new file mode 100644 index 00000000..e69de29b diff --git a/src/Noty/Symfony/composer.json b/src/Noty/Symfony/composer.json new file mode 100644 index 00000000..bccb4daa --- /dev/null +++ b/src/Noty/Symfony/composer.json @@ -0,0 +1,56 @@ +{ + "name": "php-flasher/flasher-noty-symfony", + "type": "symfony-bundle", + "description": "Symfony Flasher adapter for noty.js library for php-flasher/flasher-symfony", + "keywords": [ + "yoeunes", + "notify", + "php", + "laravel", + "symfony", + "Lumen", + "notifications", + "messages", + "alerts", + "pnotify", + "noty ", + "bundle", + "flex" + ], + "homepage": "https://github.com/php-flasher/flasher-symfony-noty", + "authors": [ + { + "name": "Younes Khoubza", + "email": "younes.khoubza@gmail.com", + "homepage": "https://github.com/yoeunes", + "role": "Developer" + } + ], + "license": "MIT", + "require": { + "php": ">=5.3", + "php-flasher/flasher-symfony": "dev-main", + "php-flasher/flasher-noty": "dev-main" + }, + "require-dev": { + "phpunit/phpunit": "^4.8|^5.0|^6.0|^7.0|^8.0|^9.0" + }, + "autoload": { + "psr-4": { + "Flasher\\Noty\\Symfony\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "autoload-dev": { + "psr-4": { + "Flasher\\Noty\\Symfony\\Tests\\": "Tests/" + } + }, + "config": { + "sort-packages": true + }, + "minimum-stability": "dev", + "prefer-stable": true +} diff --git a/src/Noty/Symfony/phpunit.xml.dist b/src/Noty/Symfony/phpunit.xml.dist new file mode 100644 index 00000000..3b5c944f --- /dev/null +++ b/src/Noty/Symfony/phpunit.xml.dist @@ -0,0 +1,22 @@ + + + + + Tests + + + + + ./ + + +