From 2654a62ad93a68ee9abefdff822e7ab8b66c1687 Mon Sep 17 00:00:00 2001 From: Khoubza Younes Date: Sun, 6 Dec 2020 23:36:29 +0100 Subject: [PATCH] add noty library support --- .gitattributes | 13 + .github/workflows/tests.yaml | 104 +++ .gitignore | 5 + .phpcs.xml.dist | 625 +++++++++++++++++++ .phpstorm.meta.php | 14 + CHANGELOG.md | 0 DependencyInjection/Configuration.php | 68 ++ DependencyInjection/FlasherNotyExtension.php | 45 ++ FlasherNotyBundle.php | 9 + README.md | 51 ++ Resources/config/config.yaml | 16 + Tests/.gitkeep | 0 UPGRADING.md | 0 composer.json | 56 ++ phpunit.xml.dist | 22 + 15 files changed, 1028 insertions(+) create mode 100644 .gitattributes create mode 100644 .github/workflows/tests.yaml create mode 100644 .gitignore create mode 100644 .phpcs.xml.dist create mode 100644 .phpstorm.meta.php create mode 100644 CHANGELOG.md create mode 100644 DependencyInjection/Configuration.php create mode 100644 DependencyInjection/FlasherNotyExtension.php create mode 100644 FlasherNotyBundle.php create mode 100644 README.md create mode 100644 Resources/config/config.yaml create mode 100644 Tests/.gitkeep create mode 100644 UPGRADING.md create mode 100644 composer.json create mode 100644 phpunit.xml.dist diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..3383d44b --- /dev/null +++ b/.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/.github/workflows/tests.yaml b/.github/workflows/tests.yaml new file mode 100644 index 00000000..5bd77994 --- /dev/null +++ b/.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/.gitignore b/.gitignore new file mode 100644 index 00000000..409f0e32 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +.idea/ +vendor/ +composer.lock +.phpunit.result.cache +.phpcs-cache diff --git a/.phpcs.xml.dist b/.phpcs.xml.dist new file mode 100644 index 00000000..93d245bc --- /dev/null +++ b/.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/.phpstorm.meta.php b/.phpstorm.meta.php new file mode 100644 index 00000000..aa712a5c --- /dev/null +++ b/.phpstorm.meta.php @@ -0,0 +1,14 @@ + '@'])); +override(RendererManager::make(''), map(['' => '@'])); +override(PresenterManager::make(''), map(['' => '@'])); diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..e69de29b diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php new file mode 100644 index 00000000..ea6cecac --- /dev/null +++ b/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/DependencyInjection/FlasherNotyExtension.php b/DependencyInjection/FlasherNotyExtension.php new file mode 100644 index 00000000..7d1dd5c1 --- /dev/null +++ b/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/FlasherNotyBundle.php b/FlasherNotyBundle.php new file mode 100644 index 00000000..5eca3241 --- /dev/null +++ b/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/Resources/config/config.yaml b/Resources/config/config.yaml new file mode 100644 index 00000000..fd83957e --- /dev/null +++ b/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/Tests/.gitkeep b/Tests/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/UPGRADING.md b/UPGRADING.md new file mode 100644 index 00000000..e69de29b diff --git a/composer.json b/composer.json new file mode 100644 index 00000000..bccb4daa --- /dev/null +++ b/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/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 00000000..3b5c944f --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,22 @@ + + + + + Tests + + + + + ./ + + +