diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
index 5e454f27..7de85ae3 100644
--- a/.github/FUNDING.yml
+++ b/.github/FUNDING.yml
@@ -1,5 +1,3 @@
-# These are supported funding model platforms
-
patreon: yoeunes
ko_fi: yoeunes
open_collective: php-flasher
diff --git a/.github/workflows/laravel.yaml b/.github/workflows/laravel.yaml
index 39facb99..e1a915fb 100644
--- a/.github/workflows/laravel.yaml
+++ b/.github/workflows/laravel.yaml
@@ -1,160 +1,49 @@
-name: Running tests
+name: tests
on:
push:
- pull_request:
- schedule:
- - cron: '* * * * *'
jobs:
test:
- runs-on: ${{ matrix.os }}
+ 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.*
- os:
- - ubuntu-latest
- # - macos-latest
- # - windows-latest
+ laravel: [ 9.*, 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.* ]
include:
- - laravel: 8.*
- testbench: 6.*
- php: 7.3
- phpunit: 9.3.*
+ - { laravel: 9.*, testbench: 7.*, php: 8.0, phpunit: 9.5.* }
+ - { 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.* }
- - 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: ${{ matrix.os }} - L${{ matrix.laravel }} - P${{ matrix.php }}
+ name: laravel[${{ matrix.laravel }}] php[${{ matrix.php }}]
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') }}
+ uses: actions/checkout@v2
- 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 require "laravel/framework:${{ matrix.laravel }}" "phpunit/phpunit:${{ matrix.phpunit }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update
- composer update --prefer-dist --no-interaction --no-suggest
+ composer remove friendsofphp/php-cs-fixer laravel/laravel livewire/livewire phpstan/phpstan symfony/symfony orchestra/testbench phpunit/phpunit --dev
+ composer require "laravel/framework:${{ matrix.laravel }}" "phpunit/phpunit:${{ matrix.phpunit }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction
- name: Execute tests
run: vendor/bin/phpunit --configuration=phpunit-laravel.xml
-
- - name: Install Flasher Depencies
- run: |
- composer require "php-flasher/flasher:^0.9"
- composer require "php-flasher/flasher-laravel:^0.9"
-
- composer require "php-flasher/flasher-cli:^0.9"
- composer require "php-flasher/flasher-cli-laravel:^0.9"
-
- composer require "php-flasher/flasher-toastr:^0.9"
- composer require "php-flasher/flasher-toastr-laravel:^0.9"
-
- composer require "php-flasher/flasher-noty:^0.9"
- composer require "php-flasher/flasher-noty-laravel:^0.9"
-
- composer require "php-flasher/flasher-notyf:^0.9"
- composer require "php-flasher/flasher-notyf-laravel:^0.9"
-
- composer require "php-flasher/flasher-sweet-alert:^0.9"
- composer require "php-flasher/flasher-sweet-alert-laravel:^0.9"
-
- composer require "php-flasher/flasher-pnotify:^0.9"
- composer require "php-flasher/flasher-pnotify-laravel:^0.9"
diff --git a/.github/workflows/split_monorepo.yaml b/.github/workflows/split_monorepo.yaml
new file mode 100644
index 00000000..06bbd3dd
--- /dev/null
+++ b/.github/workflows/split_monorepo.yaml
@@ -0,0 +1,78 @@
+name: Split Monorepo
+
+on:
+ push:
+ branches:
+ - main
+ tags:
+ - '*'
+
+jobs:
+ split_monorepo:
+ runs-on: ubuntu-latest
+ strategy:
+ fail-fast: false
+ matrix:
+ package:
+ - { path: 'src/Prime', repo: 'flasher' }
+ - { path: 'src/Laravel', repo: 'flasher-laravel' }
+ - { path: 'src/Symfony', repo: 'flasher-symfony' }
+
+ - { path: 'src/Cli/Prime', repo: 'flasher-cli' }
+ - { path: 'src/Cli/Laravel', repo: 'flasher-cli-laravel' }
+ - { path: 'src/Cli/Symfony', repo: 'flasher-cli-symfony' }
+
+ - { path: 'src/Noty/Prime', repo: 'flasher-noty' }
+ - { path: 'src/Noty/Laravel', repo: 'flasher-noty-laravel' }
+ - { path: 'src/Noty/Symfony', repo: 'flasher-noty-symfony' }
+
+ - { path: 'src/Notyf/Prime', repo: 'flasher-notyf' }
+ - { path: 'src/Notyf/Laravel', repo: 'flasher-notyf-laravel' }
+ - { path: 'src/Notyf/Symfony', repo: 'flasher-notyf-symfony' }
+
+ - { path: 'src/Pnotify/Prime', repo: 'flasher-pnotify' }
+ - { path: 'src/Pnotify/Laravel', repo: 'flasher-pnotify-laravel' }
+ - { path: 'src/Pnotify/Symfony', repo: 'flasher-pnotify-symfony' }
+
+ - { path: 'src/SweetAlert/Prime', repo: 'flasher-sweetalert' }
+ - { path: 'src/SweetAlert/Laravel', repo: 'flasher-sweetalert-laravel' }
+ - { path: 'src/SweetAlert/Symfony', repo: 'flasher-sweetalert-symfony' }
+
+ - { path: 'src/Toastr/Prime', repo: 'flasher-toastr' }
+ - { path: 'src/Toastr/Laravel', repo: 'flasher-toastr-laravel' }
+ - { path: 'src/Toastr/Symfony', repo: 'flasher-toastr-symfony' }
+
+ - { path: 'packs/php-pack', repo: 'php-pack' }
+ - { path: 'packs/laravel-pack', repo: 'laravel-pack' }
+ - { path: 'packs/symfony-pack', repo: 'symfony-pack' }
+
+ steps:
+ - uses: actions/checkout@v2
+
+ - if: "!startsWith(github.ref, 'refs/tags/')"
+ name: Monorepo Split of ${{ matrix.package }}
+ uses: symplify/github-action-monorepo-split@2.0
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ with:
+ package-directory: '${{ matrix.package.path }}'
+ split-repository-organization: 'php-flasher'
+ split-repository-name: '${{ matrix.package.repo }}'
+ user-name: "Younes KHOUBZA"
+ user-email: "younes.khoubza@gmail.com"
+ branch: main
+
+ - if: "startsWith(github.ref, 'refs/tags/')"
+ name: Monorepo Tagged Split of ${{ matrix.package }}
+ uses: symplify/github-action-monorepo-split@2.0
+ env:
+ GITHUB_TOKEN: ${{ secrets.ACCESS_TOKEN }}
+ with:
+ tag: ${GITHUB_REF#refs/tags/}
+
+ package-directory: 'src/${{ matrix.package.path }}'
+ split-repository-organization: 'php-flasher'
+ split-repository-name: '${{ matrix.package.repo }}'
+ user-name: "Younes KHOUBZA"
+ user-email: "younes.khoubza@gmail.com"
+ branch: main
diff --git a/.github/workflows/symfony.yaml b/.github/workflows/symfony.yaml
index 5c833c92..4747c0d7 100644
--- a/.github/workflows/symfony.yaml
+++ b/.github/workflows/symfony.yaml
@@ -1,191 +1,59 @@
-name: Running tests
+name: tests
on:
push:
- pull_request:
- schedule:
- - cron: '* * * * *'
jobs:
test:
- runs-on: ${{ matrix.os }}
+ runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
- symfony:
- - 5.4.*
- - 5.3.*
- - 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.*
- - 2.6.*
- - 2.5.*
- - 2.4.*
- - 2.3.*
- - 2.2.*
- - 2.1.*
- - 2.0.*
- os:
- - ubuntu-latest
- # - macos-latest
- # - windows-latest
+ symfony: [ 6.0.*, 5.4.*, 5.3.*, 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.*, 2.6.*, 2.5.*, 2.4.*, 2.3.*, 2.2.*, 2.1.*, 2.0.* ]
include:
- - symfony: 5.4.*
- php: 7.2
- phpunit: 8.3.*
+ - { symfony: 6.0.*, php: 8.0, phpunit: 9.5.* }
+ - { symfony: 5.4.*, php: 7.2, phpunit: 8.3.* }
+ - { symfony: 5.3.*, php: 7.2, phpunit: 8.3.* }
+ - { 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 }
+ - { symfony: 2.6.*, php: 5.3, phpunit: 4.8.36 }
+ - { symfony: 2.5.*, php: 5.3, phpunit: 4.8.36 }
+ - { symfony: 2.4.*, php: 5.3, phpunit: 4.8.36 }
+ - { symfony: 2.3.*, php: 5.3, phpunit: 4.8.36 }
+ - { symfony: 2.2.*, php: 5.3, phpunit: 4.8.36 }
+ - { symfony: 2.1.*, php: 5.3, phpunit: 4.8.36 }
+ - { symfony: 2.0.*, php: 5.3, phpunit: 4.8.36 }
- - symfony: 5.3.*
- php: 7.2
- phpunit: 8.3.*
-
- - 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
-
- - symfony: 2.6.*
- php: 5.3
- phpunit: 4.8.36
-
- - symfony: 2.5.*
- php: 5.3
- phpunit: 4.8.36
-
- - symfony: 2.4.*
- php: 5.3
- phpunit: 4.8.36
-
- - symfony: 2.3.*
- php: 5.3
- phpunit: 4.8.36
-
- - symfony: 2.2.*
- php: 5.3
- phpunit: 4.8.36
-
- - symfony: 2.1.*
- php: 5.3
- phpunit: 4.8.36
-
- - symfony: 2.0.*
- php: 5.3
- phpunit: 4.8.36
-
- name: ${{ matrix.os }} - S${{ matrix.symfony }} - P${{ matrix.php }}
+ name: symfony[${{ matrix.symfony }}] php[${{ matrix.php }}]
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') }}
+ uses: actions/checkout@v2
- 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 require "symfony/symfony:${{ matrix.symfony }}" "phpunit/phpunit:${{ matrix.phpunit }}" twig/twig --no-interaction --no-update
+ composer remove friendsofphp/php-cs-fixer laravel/laravel livewire/livewire phpstan/phpstan symfony/symfony orchestra/testbench phpunit/phpunit --dev
composer config extra.symfony.require "${{ matrix.symfony }}"
- composer update --prefer-dist --no-interaction --no-suggest
+ composer require "symfony/symfony:${{ matrix.symfony }}" "phpunit/phpunit:${{ matrix.phpunit }}" --no-interaction
- name: Execute tests
run: vendor/bin/phpunit --configuration=phpunit-symfony.xml
-
- - name: Install Flasher Depencies
- run: |
- composer require "php-flasher/flasher:^0.9"
- composer require "php-flasher/flasher-laravel:^0.9"
- composer require "php-flasher/flasher-symfony:^0.9"
-
- composer require "php-flasher/flasher-cli:^0.9"
- composer require "php-flasher/flasher-cli-symfony:^0.9"
-
- composer require "php-flasher/flasher-toastr:^0.9"
- composer require "php-flasher/flasher-toastr-symfony:^0.9"
-
- composer require "php-flasher/flasher-noty:^0.9"
- composer require "php-flasher/flasher-noty-symfony:^0.9"
-
- composer require "php-flasher/flasher-notyf:^0.9"
- composer require "php-flasher/flasher-notyf-symfony:^0.9"
-
- composer require "php-flasher/flasher-sweet-alert:^0.9"
- composer require "php-flasher/flasher-sweet-alert-symfony:^0.9"
-
- composer require "php-flasher/flasher-pnotify:^0.9"
- composer require "php-flasher/flasher-pnotify-symfony:^0.9"
diff --git a/.gitignore b/.gitignore
index 89d72688..e609f21d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,3 +3,7 @@ vendor
composer.lock
.phpunit.result.cache
.phpcs-cache
+.php-cs-fixer.cache
+
+packs/**/composer.lock
+packs/**/vendor/
diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php
new file mode 100644
index 00000000..cb2a8152
--- /dev/null
+++ b/.php-cs-fixer.dist.php
@@ -0,0 +1,66 @@
+
+ */
+
+if (!file_exists(__DIR__.'/src')) {
+ exit(0);
+}
+
+$header = <<<'EOF'
+This file is part of the PHPFlasher package.
+(c) Younes KHOUBZA
+EOF;
+
+$rules = array(
+ '@PSR12' => true,
+ '@PSR12:risky' => true,
+ '@Symfony' => true,
+ '@Symfony:risky' => true,
+ '@PhpCsFixer' => true,
+ '@PhpCsFixer:risky' => true,
+ 'header_comment' => array('header' => $header),
+ 'array_syntax' => array('syntax' => 'long'),
+ 'ordered_imports' => array(
+ 'sort_algorithm' => 'alpha',
+ 'imports_order' => array('const', 'class', 'function'),
+ ),
+ 'no_extra_blank_lines' => array(
+ 'tokens' => array('case', 'continue', 'curly_brace_block', 'default', 'extra', 'parenthesis_brace_block', 'square_brace_block', 'switch', 'throw'),
+ ),
+ 'function_to_constant' => false,
+ 'visibility_required' => array('elements' => array('property', 'method')),
+ 'self_accessor' => false,
+ 'single_trait_insert_per_statement' => true,
+ 'linebreak_after_opening_tag' => true,
+ 'no_php4_constructor' => true,
+ 'no_unreachable_default_argument_value' => true,
+ 'no_useless_else' => true,
+ 'no_useless_return' => true,
+ 'phpdoc_order' => true,
+ 'strict_comparison' => true,
+ 'strict_param' => true,
+ 'phpdoc_line_span' => true,
+ 'php_unit_internal_class' => false,
+ 'php_unit_test_class_requires_covers' => false,
+ 'multiline_whitespace_before_semicolons' => false,
+ 'method_chaining_indentation' => false,
+ 'phpdoc_no_empty_return' => false,
+ 'phpdoc_types_order' => array('null_adjustment' => 'always_last'),
+ 'php_unit_test_case_static_method_calls' => array('call_type' => 'this'),
+ 'php_unit_strict' => false,
+ 'native_constant_invocation' => array('scope' => 'namespaced'),
+ 'phpdoc_return_self_reference' => true,
+);
+
+$finder = new PhpCsFixer\Finder();
+$finder->in(__DIR__)->exclude(__DIR__.'/vendor');
+
+$config = new PhpCsFixer\Config();
+
+return $config->setFinder($finder)
+ ->setUsingCache(false)
+ ->setRiskyAllowed(true)
+ ->setRules($rules);
diff --git a/.shared/.github/workflows/auto_closer.yaml b/.shared/.github/workflows/auto_closer.yaml
new file mode 100644
index 00000000..f807ac59
--- /dev/null
+++ b/.shared/.github/workflows/auto_closer.yaml
@@ -0,0 +1,22 @@
+name: Auto Closer PR
+
+on:
+ pull_request_target:
+ types: [opened]
+
+jobs:
+ run:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: superbrothers/close-pull-request@v3
+ with:
+ comment: |
+ Hi, thank you for your contribution.
+
+ Unfortunately, this repository is read-only. It's a split from our main monorepo repository.
+
+ We'd like to kindly ask you to move the contribution there - https://github.com/php-flasher/php-flasher.
+
+ We'll check it, review it and give you feed back right way.
+
+ Thank you.
diff --git a/Makefile b/Makefile
new file mode 100644
index 00000000..567e05ca
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,4 @@
+include make/variables.mk
+include make/help.mk
+include make/composer.mk
+include make/lint.mk
diff --git a/README.md b/README.md
index 5714d7d7..70048b42 100644
--- a/README.md
+++ b/README.md
@@ -24,12 +24,6 @@
-
-
-
-
-
-
# Why use PHP Flasher ?
@@ -53,21 +47,7 @@ This library is designed, so you can take full control when creating you notific
## Official Documentation
-Documentation for PHP Flasher can be found on the [PHP Flasher website](https://php-flasher.github.io/).
-
-## Backers && Sponsors
-
-Support this project by becoming a sponsor. Your name will show up in the Contribute page of all PHP Flasher installations as well as here with a link to your website!
-
-Thank you to all our backers and sponsors! 🙏
-
-
-
-
-
-
-
-
+Documentation for PHP Flasher can be found on the [PHP Flasher website](https://php-flasher.io).
### Contact
diff --git a/bin/copy b/bin/copy
new file mode 100755
index 00000000..b3b9d3a4
--- /dev/null
+++ b/bin/copy
@@ -0,0 +1,53 @@
+#!/usr/bin/env php
+getPathname())
+ : $dest .'/'. $file->getFilename();
+
+ if ($file->isDir()) {
+ system('rm -rf -- ' . escapeshellarg($dest));
+ @mkdir(dirname($target), 0777, true);
+ continue;
+ }
+
+ @mkdir(dirname($target), 0777, true);
+ @copy($file->getPathname(), $target);
+ }
+ }
+}
diff --git a/bin/release.sh b/bin/release.sh
deleted file mode 100755
index 5efca36f..00000000
--- a/bin/release.sh
+++ /dev/null
@@ -1,83 +0,0 @@
-#!/usr/bin/env bash
-
-set -e
-
-# Make sure the release tag is provided.
-if (( "$#" != 1 ))
-then
- echo "Tag has to be provided."
-
- exit 1
-fi
-
-RELEASE_BRANCH="main"
-CURRENT_BRANCH=$(git rev-parse --abbrev-ref HEAD)
-VERSION=$1
-
-# Make sure current branch and release branch match.
-if [[ "$RELEASE_BRANCH" != "$CURRENT_BRANCH" ]]
-then
- echo "Release branch ($RELEASE_BRANCH) does not match the current active branch ($CURRENT_BRANCH)."
-
- exit 1
-fi
-
-# Make sure the working directory is clear.
-if [[ ! -z "$(git status --porcelain)" ]]
-then
- echo "Your working directory is dirty. Did you forget to commit your changes?"
-
- exit 1
-fi
-
-# Make sure latest changes are fetched first.
-git fetch origin
-
-# Make sure that release branch is in sync with origin.
-if [[ $(git rev-parse HEAD) != $(git rev-parse origin/$RELEASE_BRANCH) ]]
-then
- echo "Your branch is out of date with its upstream. Did you forget to pull or push any changes before releasing?"
-
- exit 1
-fi
-
-# Always prepend with "v"
-if [[ $VERSION != v* ]]
-then
- VERSION="v$VERSION"
-fi
-
-# Tag PHP Flasher
-git tag "$VERSION"
-git push origin --tags --force
-
-# Tag Repositories
-for REMOTE in flasher flasher-laravel flasher-symfony flasher-livewire \
- flasher-toastr flasher-toastr-laravel flasher-toastr-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 \
- flasher-cli flasher-cli-laravel flasher-cli-symfony \
- laravel-pack livewire-pack php-pack symfony-pack
-do
- echo ""
- echo ""
- echo "Releasing $REMOTE";
-
- TMP_DIR="/tmp/php-flasher"
- REMOTE_URL="git@github.com:php-flasher/$REMOTE.git"
-
- rm -rf $TMP_DIR;
- mkdir $TMP_DIR;
-
- (
- cd $TMP_DIR;
-
- git clone $REMOTE_URL .
- git checkout "$RELEASE_BRANCH";
-
- git tag "$VERSION"
- git push origin --tags
- )
-done
diff --git a/bin/split.sh b/bin/split.sh
deleted file mode 100755
index cd1d2c0c..00000000
--- a/bin/split.sh
+++ /dev/null
@@ -1,84 +0,0 @@
-#!/usr/bin/env bash
-
-set -e
-set -x
-
-CURRENT_BRANCH="main"
-
-function split()
-{
-# git merge --strategy recursive --strategy-option subtree="$1" "$2/$CURRENT_BRANCH" --allow-unrelated-histories -m "Merge remote-tracking branch '$2/$CURRENT_BRANCH'"
- SHA1=$(./bin/splitsh-lite --prefix="$1")
- git push $2 "$SHA1:refs/heads/$CURRENT_BRANCH" -f
-}
-
-function remote()
-{
- git remote add "$1" "$2" || true
-}
-
-git pull origin $CURRENT_BRANCH
-
-remote flasher git@github.com:php-flasher/flasher.git
-remote laravel git@github.com:php-flasher/flasher-laravel.git
-remote symfony git@github.com:php-flasher/flasher-symfony.git
-remote livewire git@github.com:php-flasher/flasher-livewire.git
-
-remote toastr git@github.com:php-flasher/flasher-toastr.git
-remote toastr-laravel git@github.com:php-flasher/flasher-toastr-laravel.git
-remote toastr-symfony git@github.com:php-flasher/flasher-toastr-symfony.git
-
-remote notyf git@github.com:php-flasher/flasher-notyf.git
-remote notyf-laravel git@github.com:php-flasher/flasher-notyf-laravel.git
-remote notyf-symfony git@github.com:php-flasher/flasher-notyf-symfony.git
-
-remote sweet-alert git@github.com:php-flasher/flasher-sweet-alert.git
-remote sweet-alert-laravel git@github.com:php-flasher/flasher-sweet-alert-laravel.git
-remote sweet-alert-symfony git@github.com:php-flasher/flasher-sweet-alert-symfony.git
-
-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
-
-remote cli git@github.com:php-flasher/flasher-cli.git
-remote cli-laravel git@github.com:php-flasher/flasher-cli-laravel.git
-remote cli-symfony git@github.com:php-flasher/flasher-cli-symfony.git
-
-remote laravel-pack git@github.com:php-flasher/laravel-pack.git
-remote livewire-pack git@github.com:php-flasher/livewire-pack.git
-remote php-pack git@github.com:php-flasher/php-pack.git
-remote symfony-pack git@github.com:php-flasher/symfony-pack.git
-
-split 'src/Prime' flasher
-split 'src/Laravel' laravel
-split 'src/Symfony' symfony
-split 'src/Livewire' livewire
-
-split 'src/Toastr/Prime' toastr
-split 'src/Toastr/Laravel' toastr-laravel
-split 'src/Toastr/Symfony' toastr-symfony
-
-split 'src/Notyf/Prime' notyf
-split 'src/Notyf/Laravel' notyf-laravel
-split 'src/Notyf/Symfony' notyf-symfony
-
-split 'src/SweetAlert/Prime' sweet-alert
-split 'src/SweetAlert/Laravel' sweet-alert-laravel
-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
-
-split 'packs/laravel-pack' laravel-pack
-split 'packs/livewire-pack' livewire-pack
-split 'packs/php-pack' php-pack
-split 'packs/symfony-pack' symfony-pack
diff --git a/bin/splitsh-lite b/bin/splitsh-lite
deleted file mode 100755
index ddefe95a..00000000
Binary files a/bin/splitsh-lite and /dev/null differ
diff --git a/composer.json b/composer.json
old mode 100755
new mode 100644
index 5ea3d43e..5db76790
--- a/composer.json
+++ b/composer.json
@@ -1,13 +1,13 @@
{
"name": "php-flasher/php-flasher",
- "description": "All flasher components in one place for easy maintenance with splitsh",
+ "description": "Repository for PHPFlasher development",
"type": "project",
"license": "MIT",
"authors": [
{
- "name": "KHOUBZA Younes",
+ "name": "Younes KHOUBZA",
"email": "younes.khoubza@gmail.com",
- "homepage": "https://github.com/yoeunes",
+ "homepage": "https://www.linkedin.com/in/younes-khoubza",
"role": "Developer"
}
],
@@ -16,25 +16,102 @@
"ext-json": "*",
"ext-mbstring": "*"
},
+ "require-dev": {
+ "friendsofphp/php-cs-fixer": "^3.8",
+ "laravel/laravel": "^9.1",
+ "livewire/livewire": "^2.10",
+ "orchestra/testbench": "^7.5",
+ "phpstan/phpstan": "^1.6",
+ "phpunit/phpunit": "^9.5",
+ "symfony/symfony": "^6.0"
+ },
"autoload": {
- "psr-4": {
- "Flasher\\": "src/"
- },
"files": [
- "src/Prime/helpers.php",
- "src/Laravel/helpers.php",
- "src/Toastr/Laravel/Resources/functions/toastr.php",
- "src/Noty/Laravel/Resources/functions/noty.php",
- "src/Notyf/Laravel/Resources/functions/notyf.php",
- "src/Pnotify/Laravel/Resources/functions/pnotify.php",
- "src/SweetAlert/Laravel/Resources/functions/sweetAlert.php",
- "src/Cli/Laravel/Resources/functions/cli.php"
- ]
+ "src/Cli/Laravel/notify.php",
+ "src/Laravel/flasher.php",
+ "src/Noty/Laravel/noty.php",
+ "src/Notyf/Laravel/notyf.php",
+ "src/Pnotify/Laravel/pnotify.php",
+ "src/SweetAlert/Laravel/sweetalert.php",
+ "src/Toastr/Laravel/toastr.php"
+ ],
+ "psr-4": {
+ "Flasher\\": "src/",
+ "Flasher\\Cli\\Laravel\\": "src/Cli/Laravel/",
+ "Flasher\\Cli\\Prime\\": "src/Cli/Prime/",
+ "Flasher\\Cli\\Symfony\\": "src/Cli/Symfony/",
+ "Flasher\\Laravel\\": "src/Laravel/",
+ "Flasher\\Noty\\Laravel\\": "src/Noty/Laravel/",
+ "Flasher\\Noty\\Prime\\": "src/Noty/Prime/",
+ "Flasher\\Noty\\Symfony\\": "src/Noty/Symfony/",
+ "Flasher\\Notyf\\Laravel\\": "src/Notyf/Laravel/",
+ "Flasher\\Notyf\\Prime\\": "src/Notyf/Prime/",
+ "Flasher\\Notyf\\Symfony\\": "src/Notyf/Symfony/",
+ "Flasher\\Pnotify\\Laravel\\": "src/Pnotify/Laravel/",
+ "Flasher\\Pnotify\\Prime\\": "src/Pnotify/Prime/",
+ "Flasher\\Pnotify\\Symfony\\": "src/Pnotify/Symfony/",
+ "Flasher\\Prime\\": "src/Prime/",
+ "Flasher\\SweetAlert\\Laravel\\": "src/SweetAlert/Laravel/",
+ "Flasher\\SweetAlert\\Prime\\": "src/SweetAlert/Prime/",
+ "Flasher\\SweetAlert\\Symfony\\": "src/SweetAlert/Symfony/",
+ "Flasher\\Symfony\\": "src/Symfony/",
+ "Flasher\\Toastr\\Laravel\\": "src/Toastr/Laravel/",
+ "Flasher\\Toastr\\Prime\\": "src/Toastr/Prime/",
+ "Flasher\\Toastr\\Symfony\\": "src/Toastr/Symfony/"
+ }
},
"autoload-dev": {
"psr-4": {
"Flasher\\Tests\\": "tests/"
}
},
- "minimum-stability": "dev"
+ "extra": {
+ "laravel": {
+ "providers": [
+ "Flasher\\Cli\\Laravel\\FlasherCliServiceProvider",
+ "Flasher\\Toastr\\Laravel\\FlasherToastrServiceProvider",
+ "Flasher\\Laravel\\FlasherServiceProvider",
+ "Flasher\\Noty\\Laravel\\FlasherNotyServiceProvider",
+ "Flasher\\Pnotify\\Laravel\\FlasherPnotifyServiceProvider",
+ "Flasher\\Notyf\\Laravel\\FlasherNotyfServiceProvider",
+ "Flasher\\SweetAlert\\Laravel\\FlasherSweetAlertServiceProvider"
+ ],
+ "aliases": {
+ "Toastr": "Flasher\\Toastr\\Laravel\\Facade\\Toastr",
+ "Flasher": "Flasher\\Laravel\\Facade\\Flasher",
+ "Noty": "Flasher\\Laravel\\Facade\\Flasher",
+ "Pnotify": "Flasher\\Pnotify\\Laravel\\Facade\\Pnotify",
+ "Notyf": "Flasher\\Notyf\\Laravel\\Facade\\Notyf",
+ "SweetAlert": "Flasher\\SweetAlert\\Laravel\\Facade\\SweetAlert"
+ }
+ }
+ },
+ "replace": {
+ "php-flasher/flasher": "self.version",
+ "php-flasher/flasher-cli": "self.version",
+ "php-flasher/flasher-cli-laravel": "self.version",
+ "php-flasher/flasher-cli-symfony": "self.version",
+ "php-flasher/flasher-laravel": "self.version",
+ "php-flasher/flasher-noty": "self.version",
+ "php-flasher/flasher-noty-laravel": "self.version",
+ "php-flasher/flasher-noty-symfony": "self.version",
+ "php-flasher/flasher-notyf": "self.version",
+ "php-flasher/flasher-notyf-laravel": "self.version",
+ "php-flasher/flasher-notyf-symfony": "self.version",
+ "php-flasher/flasher-pnotify": "self.version",
+ "php-flasher/flasher-pnotify-laravel": "self.version",
+ "php-flasher/flasher-pnotify-symfony": "self.version",
+ "php-flasher/flasher-sweetalert": "self.version",
+ "php-flasher/flasher-sweetalert-laravel": "self.version",
+ "php-flasher/flasher-sweetalert-symfony": "self.version",
+ "php-flasher/flasher-symfony": "self.version",
+ "php-flasher/flasher-toastr": "self.version",
+ "php-flasher/flasher-toastr-laravel": "self.version",
+ "php-flasher/flasher-toastr-symfony": "self.version"
+ },
+ "config": {
+ "sort-packages": true
+ },
+ "minimum-stability": "stable",
+ "prefer-stable": true
}
diff --git a/make/composer.mk b/make/composer.mk
new file mode 100644
index 00000000..2aa0b76c
--- /dev/null
+++ b/make/composer.mk
@@ -0,0 +1,9 @@
+.PHONY: install update
+
+## 🧙 Installs the project dependencies and assets
+install: composer.lock
+ $(COMPOSER) install $(COMPOSER_ARGS)
+
+## Upgrades your dependencies to the latest version according to composer.json, and updates the composer.lock file.
+update:
+ $(COMPOSER) update --lock $(COMPOSER_ARGS)
diff --git a/make/help.mk b/make/help.mk
new file mode 100644
index 00000000..36f3c58e
--- /dev/null
+++ b/make/help.mk
@@ -0,0 +1,27 @@
+.PHONY: help
+
+COLOR_RESET = \033[0m
+COLOR_INFO = \033[32m
+COLOR_COMMENT = \033[33m
+
+## Help
+help:
+ @printf "${COLOR_COMMENT}Usage:${COLOR_RESET}\n"
+ @printf " make [target]\n\n"
+ @printf "${COLOR_COMMENT}Available targets:${COLOR_RESET}\n"
+ @awk '/^[a-zA-Z\-\_0-9\.@]+:/ { \
+ helpMessage = match(lastLine, /^## (.*)/); \
+ if (helpMessage) { \
+ helpCommand = substr($$1, 0, index($$1, ":")); \
+ helpMessage = substr(lastLine, RSTART + 3, RLENGTH); \
+ printf " ${COLOR_INFO}%-16s${COLOR_RESET} %s\n", helpCommand, helpMessage; \
+ } \
+ } \
+ { lastLine = $$0 }' $(MAKEFILE_LIST)
+
+check_defined = \
+ $(strip $(foreach 1,$1, \
+ $(call __check_defined,$1,$(strip $(value 2)))))
+__check_defined = \
+ $(if $(value $1),, \
+ $(error Undefined $1$(if $2, ($2))))
diff --git a/make/lint.mk b/make/lint.mk
new file mode 100644
index 00000000..9c4fd691
--- /dev/null
+++ b/make/lint.mk
@@ -0,0 +1,11 @@
+.PHONY: lint fix
+
+## Run code style, linters
+lint:
+ test `find ./src -iname "*.php" | xargs -n1 -P6 php -l | grep -Fv "No syntax errors" | wc -l` -eq 0
+ $(PHP_CS_FIXER) fix --diff --dry-run -v
+ $(COMPOSER) validate --strict
+
+## Fix files with php-cs-fixer
+fix:
+ $(PHP_CS_FIXER) fix --allow-risky=yes
diff --git a/make/variables.mk b/make/variables.mk
new file mode 100644
index 00000000..1feb946d
--- /dev/null
+++ b/make/variables.mk
@@ -0,0 +1,12 @@
+# Executables
+EXEC_PHP = php
+COMPOSER = composer
+
+# Parameters
+COMPOSER_ARGS ?=
+
+# Executables: vendors
+PHP_CS_FIXER = ./vendor/bin/php-cs-fixer
+
+# Misc
+.DEFAULT_GOAL = help
diff --git a/monorepo-builder.php b/monorepo-builder.php
new file mode 100644
index 00000000..bcb9c289
--- /dev/null
+++ b/monorepo-builder.php
@@ -0,0 +1,36 @@
+
+ */
+
+use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
+use Symplify\MonorepoBuilder\Release\ReleaseWorker\AddTagToChangelogReleaseWorker;
+use Symplify\MonorepoBuilder\Release\ReleaseWorker\PushNextDevReleaseWorker;
+use Symplify\MonorepoBuilder\Release\ReleaseWorker\PushTagReleaseWorker;
+use Symplify\MonorepoBuilder\Release\ReleaseWorker\SetCurrentMutualDependenciesReleaseWorker;
+use Symplify\MonorepoBuilder\Release\ReleaseWorker\SetNextMutualDependenciesReleaseWorker;
+use Symplify\MonorepoBuilder\Release\ReleaseWorker\TagVersionReleaseWorker;
+use Symplify\MonorepoBuilder\Release\ReleaseWorker\UpdateBranchAliasReleaseWorker;
+use Symplify\MonorepoBuilder\Release\ReleaseWorker\UpdateReplaceReleaseWorker;
+use Symplify\MonorepoBuilder\ValueObject\Option;
+
+return static function (ContainerConfigurator $containerConfigurator): void {
+ $parameters = $containerConfigurator->parameters();
+ $parameters->set(Option::PACKAGE_DIRECTORIES, array(
+ __DIR__.'/src',
+ ));
+
+ $services = $containerConfigurator->services();
+ $services->set(UpdateReplaceReleaseWorker::class);
+ $services->set(SetCurrentMutualDependenciesReleaseWorker::class);
+ $services->set(AddTagToChangelogReleaseWorker::class);
+ $services->set(TagVersionReleaseWorker::class);
+ $services->set(PushTagReleaseWorker::class);
+ $services->set(SetNextMutualDependenciesReleaseWorker::class);
+ $services->set(UpdateBranchAliasReleaseWorker::class);
+ $services->set(PushNextDevReleaseWorker::class);
+};
diff --git a/src/Livewire/.github/FUNDING.yml b/packs/laravel-pack/.github/FUNDING.yml
similarity index 70%
rename from src/Livewire/.github/FUNDING.yml
rename to packs/laravel-pack/.github/FUNDING.yml
index 5e454f27..7de85ae3 100644
--- a/src/Livewire/.github/FUNDING.yml
+++ b/packs/laravel-pack/.github/FUNDING.yml
@@ -1,5 +1,3 @@
-# These are supported funding model platforms
-
patreon: yoeunes
ko_fi: yoeunes
open_collective: php-flasher
diff --git a/packs/laravel-pack/.github/workflows/auto_closer.yaml b/packs/laravel-pack/.github/workflows/auto_closer.yaml
new file mode 100644
index 00000000..f807ac59
--- /dev/null
+++ b/packs/laravel-pack/.github/workflows/auto_closer.yaml
@@ -0,0 +1,22 @@
+name: Auto Closer PR
+
+on:
+ pull_request_target:
+ types: [opened]
+
+jobs:
+ run:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: superbrothers/close-pull-request@v3
+ with:
+ comment: |
+ Hi, thank you for your contribution.
+
+ Unfortunately, this repository is read-only. It's a split from our main monorepo repository.
+
+ We'd like to kindly ask you to move the contribution there - https://github.com/php-flasher/php-flasher.
+
+ We'll check it, review it and give you feed back right way.
+
+ Thank you.
diff --git a/src/Livewire/README.md b/packs/laravel-pack/README.md
similarity index 74%
rename from src/Livewire/README.md
rename to packs/laravel-pack/README.md
index 5714d7d7..70048b42 100644
--- a/src/Livewire/README.md
+++ b/packs/laravel-pack/README.md
@@ -24,12 +24,6 @@
-
-
-
-
-
-
# Why use PHP Flasher ?
@@ -53,21 +47,7 @@ This library is designed, so you can take full control when creating you notific
## Official Documentation
-Documentation for PHP Flasher can be found on the [PHP Flasher website](https://php-flasher.github.io/).
-
-## Backers && Sponsors
-
-Support this project by becoming a sponsor. Your name will show up in the Contribute page of all PHP Flasher installations as well as here with a link to your website!
-
-Thank you to all our backers and sponsors! 🙏
-
-
-
-
-
-
-
-
+Documentation for PHP Flasher can be found on the [PHP Flasher website](https://php-flasher.io).
### Contact
diff --git a/packs/laravel-pack/composer.json b/packs/laravel-pack/composer.json
index e9b93141..807f5829 100644
--- a/packs/laravel-pack/composer.json
+++ b/packs/laravel-pack/composer.json
@@ -5,9 +5,9 @@
"license": "MIT",
"authors": [
{
- "name": "KHOUBZA Younes",
+ "name": "Younes KHOUBZA",
"email": "younes.khoubza@gmail.com",
- "homepage": "https://github.com/yoeunes",
+ "homepage": "https://www.linkedin.com/in/younes-khoubza",
"role": "Developer"
}
],
@@ -16,7 +16,7 @@
"php-flasher/flasher-noty-laravel": "*",
"php-flasher/flasher-notyf-laravel": "*",
"php-flasher/flasher-pnotify-laravel": "*",
- "php-flasher/flasher-sweet-alert-laravel": "*",
+ "php-flasher/flasher-sweetalert-laravel": "*",
"php-flasher/flasher-toastr-laravel": "*"
}
}
diff --git a/packs/livewire-pack/LICENSE b/packs/livewire-pack/LICENSE
deleted file mode 100644
index 8d26d89b..00000000
--- a/packs/livewire-pack/LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
-MIT License
-
-Copyright (c) 2020 PHP Flasher
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
diff --git a/packs/livewire-pack/composer.json b/packs/livewire-pack/composer.json
deleted file mode 100644
index daa228ff..00000000
--- a/packs/livewire-pack/composer.json
+++ /dev/null
@@ -1,18 +0,0 @@
-{
- "name": "php-flasher/livewire-pack",
- "description": "A pack for Livewire",
- "type": "flasher-pack",
- "license": "MIT",
- "authors": [
- {
- "name": "KHOUBZA Younes",
- "email": "younes.khoubza@gmail.com",
- "homepage": "https://github.com/yoeunes",
- "role": "Developer"
- }
- ],
- "require": {
- "php-flasher/laravel-pack": "*",
- "php-flasher/flasher-livewire": "*"
- }
-}
diff --git a/packs/php-pack/.github/FUNDING.yml b/packs/php-pack/.github/FUNDING.yml
new file mode 100644
index 00000000..7de85ae3
--- /dev/null
+++ b/packs/php-pack/.github/FUNDING.yml
@@ -0,0 +1,4 @@
+patreon: yoeunes
+ko_fi: yoeunes
+open_collective: php-flasher
+custom: ['https://www.paypal.com/paypalme/yoeunes']
diff --git a/packs/php-pack/.github/workflows/auto_closer.yaml b/packs/php-pack/.github/workflows/auto_closer.yaml
new file mode 100644
index 00000000..f807ac59
--- /dev/null
+++ b/packs/php-pack/.github/workflows/auto_closer.yaml
@@ -0,0 +1,22 @@
+name: Auto Closer PR
+
+on:
+ pull_request_target:
+ types: [opened]
+
+jobs:
+ run:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: superbrothers/close-pull-request@v3
+ with:
+ comment: |
+ Hi, thank you for your contribution.
+
+ Unfortunately, this repository is read-only. It's a split from our main monorepo repository.
+
+ We'd like to kindly ask you to move the contribution there - https://github.com/php-flasher/php-flasher.
+
+ We'll check it, review it and give you feed back right way.
+
+ Thank you.
diff --git a/packs/php-pack/README.md b/packs/php-pack/README.md
new file mode 100644
index 00000000..70048b42
--- /dev/null
+++ b/packs/php-pack/README.md
@@ -0,0 +1,67 @@
+
+
+A powerful and flexible flash notifications system for PHP, Laravel, Symfony
+
+
+ :eyes: PHP Flasher helps you to add flash notifications to your PHP 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 many notification libraries : __tailwindcss__, __bootstrap__, __toastr.js__, __sweet alert 2__, __pnotify__, __noty__, and __notyf__
+and its highly extendable so you can add your custom notifications.
+
+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 object
+> * Limit the number of displayed notifications
+> * Show notifications from different libraries at the same time
+> * Framework angostic with integration for : Symfony and Laravel
+> * Support templates
+> * Easy migration from similar libraries.
+> * Very flexible so you can add you own adapters
+> * ...and more
+
+
+## Official Documentation
+
+Documentation for PHP Flasher can be found on the [PHP Flasher website](https://php-flasher.io).
+
+### Contact
+
+PHP Flasher is being actively developed by yoeunes. You can reach out with questions, bug reports, or feature requests
+on any of the following:
+
+- [Github Issues](https://github.com/php-flasher/flasher/issues)
+- [Github](https://github.com/yoeunes)
+- [Twitter](https://twitter.com/yoeunes)
+- [Linkedin](https://www.linkedin.com/in/younes-khoubza/)
+- [Email me directly](mailto:younes.khoubza@gmail.com)
+
+## License
+
+PHP Flasher is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
+
+ Made with ❤️ by Younes KHOUBZA
diff --git a/packs/php-pack/composer.json b/packs/php-pack/composer.json
index beb890be..a3341acc 100644
--- a/packs/php-pack/composer.json
+++ b/packs/php-pack/composer.json
@@ -5,9 +5,9 @@
"license": "MIT",
"authors": [
{
- "name": "KHOUBZA Younes",
+ "name": "Younes KHOUBZA",
"email": "younes.khoubza@gmail.com",
- "homepage": "https://github.com/yoeunes",
+ "homepage": "https://www.linkedin.com/in/younes-khoubza",
"role": "Developer"
}
],
@@ -16,7 +16,7 @@
"php-flasher/flasher-noty": "*",
"php-flasher/flasher-notyf": "*",
"php-flasher/flasher-pnotify": "*",
- "php-flasher/flasher-sweet-alert": "*",
+ "php-flasher/flasher-sweetalert": "*",
"php-flasher/flasher-toastr": "*"
}
}
diff --git a/packs/symfony-pack/.github/FUNDING.yml b/packs/symfony-pack/.github/FUNDING.yml
new file mode 100644
index 00000000..7de85ae3
--- /dev/null
+++ b/packs/symfony-pack/.github/FUNDING.yml
@@ -0,0 +1,4 @@
+patreon: yoeunes
+ko_fi: yoeunes
+open_collective: php-flasher
+custom: ['https://www.paypal.com/paypalme/yoeunes']
diff --git a/packs/symfony-pack/.github/workflows/auto_closer.yaml b/packs/symfony-pack/.github/workflows/auto_closer.yaml
new file mode 100644
index 00000000..f807ac59
--- /dev/null
+++ b/packs/symfony-pack/.github/workflows/auto_closer.yaml
@@ -0,0 +1,22 @@
+name: Auto Closer PR
+
+on:
+ pull_request_target:
+ types: [opened]
+
+jobs:
+ run:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: superbrothers/close-pull-request@v3
+ with:
+ comment: |
+ Hi, thank you for your contribution.
+
+ Unfortunately, this repository is read-only. It's a split from our main monorepo repository.
+
+ We'd like to kindly ask you to move the contribution there - https://github.com/php-flasher/php-flasher.
+
+ We'll check it, review it and give you feed back right way.
+
+ Thank you.
diff --git a/packs/symfony-pack/README.md b/packs/symfony-pack/README.md
new file mode 100644
index 00000000..70048b42
--- /dev/null
+++ b/packs/symfony-pack/README.md
@@ -0,0 +1,67 @@
+
+
+A powerful and flexible flash notifications system for PHP, Laravel, Symfony
+
+
+ :eyes: PHP Flasher helps you to add flash notifications to your PHP 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 many notification libraries : __tailwindcss__, __bootstrap__, __toastr.js__, __sweet alert 2__, __pnotify__, __noty__, and __notyf__
+and its highly extendable so you can add your custom notifications.
+
+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 object
+> * Limit the number of displayed notifications
+> * Show notifications from different libraries at the same time
+> * Framework angostic with integration for : Symfony and Laravel
+> * Support templates
+> * Easy migration from similar libraries.
+> * Very flexible so you can add you own adapters
+> * ...and more
+
+
+## Official Documentation
+
+Documentation for PHP Flasher can be found on the [PHP Flasher website](https://php-flasher.io).
+
+### Contact
+
+PHP Flasher is being actively developed by yoeunes. You can reach out with questions, bug reports, or feature requests
+on any of the following:
+
+- [Github Issues](https://github.com/php-flasher/flasher/issues)
+- [Github](https://github.com/yoeunes)
+- [Twitter](https://twitter.com/yoeunes)
+- [Linkedin](https://www.linkedin.com/in/younes-khoubza/)
+- [Email me directly](mailto:younes.khoubza@gmail.com)
+
+## License
+
+PHP Flasher is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT).
+
+ Made with ❤️ by Younes KHOUBZA
diff --git a/packs/symfony-pack/composer.json b/packs/symfony-pack/composer.json
index f7a13fce..ee932fc5 100644
--- a/packs/symfony-pack/composer.json
+++ b/packs/symfony-pack/composer.json
@@ -5,9 +5,9 @@
"license": "MIT",
"authors": [
{
- "name": "KHOUBZA Younes",
+ "name": "Younes KHOUBZA",
"email": "younes.khoubza@gmail.com",
- "homepage": "https://github.com/yoeunes",
+ "homepage": "https://www.linkedin.com/in/younes-khoubza",
"role": "Developer"
}
],
@@ -16,7 +16,7 @@
"php-flasher/flasher-noty-symfony": "*",
"php-flasher/flasher-notyf-symfony": "*",
"php-flasher/flasher-pnotify-symfony": "*",
- "php-flasher/flasher-sweet-alert-symfony": "*",
+ "php-flasher/flasher-sweetalert-symfony": "*",
"php-flasher/flasher-toastr-symfony": "*"
}
}
diff --git a/phpstan.neon b/phpstan.neon
index 28c90543..f61f464a 100644
--- a/phpstan.neon
+++ b/phpstan.neon
@@ -1,7 +1,6 @@
parameters:
+ level: 9
paths:
- - src/Prime
- - src/Laravel
- level: 8
- excludes_analyse:
- - vendor/*
+ - src
+ excludePaths:
+ - src/Symfony/Bridge/
diff --git a/phpunit-laravel.xml b/phpunit-laravel.xml
index f332bb05..e087e31a 100644
--- a/phpunit-laravel.xml
+++ b/phpunit-laravel.xml
@@ -1,36 +1,17 @@
-
-
-
- src/
-
-
+
-
- tests/Prime
-
+ tests/Prime
tests/Laravel
-
- tests/Toastr/Laravel
-
-
- tests/Notyf/Laravel
-
-
- tests/SweetAlert/Laravel
-
-
- tests/Pnotify/Laravel
-
-
- tests/Noty/Laravel
-
diff --git a/phpunit-symfony.xml b/phpunit-symfony.xml
index ba50bca5..c5a9cded 100644
--- a/phpunit-symfony.xml
+++ b/phpunit-symfony.xml
@@ -1,36 +1,16 @@
-
-
-
- src/
-
-
+
-
- tests/Prime
-
+ tests/Prime
tests/Symfony
-
- tests/Toastr/Symfony
-
-
- tests/Notyf/Symfony
-
-
- tests/SweetAlert/Symfony
-
-
- tests/Pnotify/Symfony
-
-
- tests/Noty/Symfony
-
diff --git a/phpunit.xml b/phpunit.xml
deleted file mode 100644
index 320afbcd..00000000
--- a/phpunit.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
- src/
-
-
-
-
- tests
-
-
-
diff --git a/src/Cli/Laravel/.editorconfig b/src/Cli/Laravel/.editorconfig
deleted file mode 100644
index cd8eb86e..00000000
--- a/src/Cli/Laravel/.editorconfig
+++ /dev/null
@@ -1,15 +0,0 @@
-; This file is for unifying the coding style for different editors and IDEs.
-; More information at http://editorconfig.org
-
-root = true
-
-[*]
-charset = utf-8
-indent_size = 4
-indent_style = space
-end_of_line = lf
-insert_final_newline = true
-trim_trailing_whitespace = true
-
-[*.md]
-trim_trailing_whitespace = false
diff --git a/src/Cli/Laravel/.gitattributes b/src/Cli/Laravel/.gitattributes
deleted file mode 100644
index 3383d44b..00000000
--- a/src/Cli/Laravel/.gitattributes
+++ /dev/null
@@ -1,13 +0,0 @@
-
-# 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/Cli/Laravel/.github/CONTRIBUTING.md b/src/Cli/Laravel/.github/CONTRIBUTING.md
deleted file mode 100644
index b4ae1c4a..00000000
--- a/src/Cli/Laravel/.github/CONTRIBUTING.md
+++ /dev/null
@@ -1,55 +0,0 @@
-# Contributing
-
-Contributions are **welcome** and will be fully **credited**.
-
-Please read and understand the contribution guide before creating an issue or pull request.
-
-## Etiquette
-
-This project is open source, and as such, the maintainers give their free time to build and maintain the source code
-held within. They make the code freely available in the hope that it will be of use to other developers. It would be
-extremely unfair for them to suffer abuse or anger for their hard work.
-
-Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the
-world that developers are civilized and selfless people.
-
-It's the duty of the maintainer to ensure that all submissions to the project are of sufficient
-quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used.
-
-## Viability
-
-When requesting or submitting new features, first consider whether it might be useful to others. Open
-source projects are used by many developers, who may have entirely different needs to your own. Think about
-whether or not your feature is likely to be used by other users of the project.
-
-## Procedure
-
-Before filing an issue:
-
-- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident.
-- Check to make sure your feature suggestion isn't already present within the project.
-- Check the pull requests tab to ensure that the bug doesn't have a fix in progress.
-- Check the pull requests tab to ensure that the feature isn't already in progress.
-
-Before submitting a pull request:
-
-- Check the codebase to ensure that your feature doesn't already exist.
-- Check the pull requests to ensure that another person hasn't already submitted the feature or fix.
-
-## Requirements
-
-If the project maintainer has any additional requirements, you will find them listed here.
-
-- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](https://pear.php.net/package/PHP_CodeSniffer).
-
-- **Add tests!** - Your patch won't be accepted if it doesn't have tests.
-
-- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.
-
-- **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option.
-
-- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
-
-- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.
-
-**Happy coding**!
diff --git a/src/Cli/Laravel/.github/FUNDING.yml b/src/Cli/Laravel/.github/FUNDING.yml
index 5e454f27..7de85ae3 100644
--- a/src/Cli/Laravel/.github/FUNDING.yml
+++ b/src/Cli/Laravel/.github/FUNDING.yml
@@ -1,5 +1,3 @@
-# These are supported funding model platforms
-
patreon: yoeunes
ko_fi: yoeunes
open_collective: php-flasher
diff --git a/src/Cli/Laravel/.github/SECURITY.md b/src/Cli/Laravel/.github/SECURITY.md
deleted file mode 100644
index d9b55dde..00000000
--- a/src/Cli/Laravel/.github/SECURITY.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# Security Policy
-
-If you discover any security related issues, please email younes.khoubza@gmail.com instead of using the issue tracker.
diff --git a/src/Cli/Laravel/.github/dependabot.yml b/src/Cli/Laravel/.github/dependabot.yml
deleted file mode 100644
index c630ffa6..00000000
--- a/src/Cli/Laravel/.github/dependabot.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-version: 2
-updates:
-- package-ecosystem: composer
- directory: "/"
- schedule:
- interval: daily
- open-pull-requests-limit: 10
diff --git a/src/Cli/Laravel/.github/workflows/auto_closer.yaml b/src/Cli/Laravel/.github/workflows/auto_closer.yaml
new file mode 100644
index 00000000..f807ac59
--- /dev/null
+++ b/src/Cli/Laravel/.github/workflows/auto_closer.yaml
@@ -0,0 +1,22 @@
+name: Auto Closer PR
+
+on:
+ pull_request_target:
+ types: [opened]
+
+jobs:
+ run:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: superbrothers/close-pull-request@v3
+ with:
+ comment: |
+ Hi, thank you for your contribution.
+
+ Unfortunately, this repository is read-only. It's a split from our main monorepo repository.
+
+ We'd like to kindly ask you to move the contribution there - https://github.com/php-flasher/php-flasher.
+
+ We'll check it, review it and give you feed back right way.
+
+ Thank you.
diff --git a/src/Cli/Laravel/.github/workflows/close-pull-request.yml b/src/Cli/Laravel/.github/workflows/close-pull-request.yml
deleted file mode 100644
index ed229fac..00000000
--- a/src/Cli/Laravel/.github/workflows/close-pull-request.yml
+++ /dev/null
@@ -1,13 +0,0 @@
-name: Close Pull Request
-
-on:
- pull_request_target:
- types: [opened]
-
-jobs:
- run:
- runs-on: ubuntu-latest
- steps:
- - uses: superbrothers/close-pull-request@v3
- with:
- comment: "Thank you for your pull request. However, you have submitted this PR on a read-only sub split of `php-flasher/php-flasher`. Please submit your PR on the https://github.com/php-flasher/php-flasher repository.
Thanks!"
diff --git a/src/Cli/Laravel/.gitignore b/src/Cli/Laravel/.gitignore
deleted file mode 100644
index 89d72688..00000000
--- a/src/Cli/Laravel/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-.idea
-vendor
-composer.lock
-.phpunit.result.cache
-.phpcs-cache
diff --git a/src/Cli/Laravel/.phpstorm.meta.php b/src/Cli/Laravel/.phpstorm.meta.php
deleted file mode 100644
index 55dcbfa4..00000000
--- a/src/Cli/Laravel/.phpstorm.meta.php
+++ /dev/null
@@ -1,3 +0,0 @@
-
+ */
+
namespace Flasher\Cli\Laravel;
-use Flasher\Cli\Laravel\ServiceProvider\ServiceProviderManager;
+use Flasher\Cli\Prime\CliFactory;
+use Flasher\Cli\Prime\EventListener\RenderListener;
+use Flasher\Cli\Prime\Notify;
+use Flasher\Cli\Prime\Presenter\CliPresenter;
+use Flasher\Prime\EventDispatcher\EventDispatcherInterface;
+use Flasher\Prime\FlasherInterface;
+use Flasher\Prime\Response\ResponseManagerInterface;
use Illuminate\Container\Container;
use Illuminate\Support\ServiceProvider;
final class FlasherCliServiceProvider extends ServiceProvider
{
+ /**
+ * @return void
+ */
public function boot()
{
- $manager = new ServiceProviderManager($this);
- $manager->boot();
+ $this->processConfiguration();
+ $this->registerRenderListener();
+ $this->registerPresenter();
}
/**
- * Register the service provider.
+ * {@inheritdoc}
*/
public function register()
{
- $manager = new ServiceProviderManager($this);
- $manager->register();
+ $this->registerNotifierFactory();
+ $this->registerNotifier();
}
/**
- * Get the services provided by the provider.
- *
- * @return string[]
+ * @return void
*/
- public function provides()
+ private function processConfiguration()
{
- return array(
- 'flasher.cli',
- );
+ $name = 'flasher_cli';
+ $config = $this->app['config']; // @phpstan-ignore-line
+
+ $config->set($name, $config->get($name, array()));
}
/**
- * @return Container
+ * @return void
*/
- public function getApplication()
+ private function registerNotifierFactory()
{
- return $this->app;
+ $this->app->singleton('flasher.cli', function (Container $app) {
+ return new CliFactory($app['flasher.storage_manager']); // @phpstan-ignore-line
+ });
+
+ $this->app->alias('flasher.cli', 'Flasher\Cli\Prime\CliFactory');
}
- public function mergeConfigFrom($path, $key)
+ /**
+ * @return void
+ */
+ private function registerNotifier()
{
- parent::mergeConfigFrom($path, $key);
+ $this->app->singleton('flasher.notify', function (Container $app) {
+ /** @phpstan-ignore-next-line */
+ $title = $app['config']->get('flasher_cli.title', null);
+ $icons = $app['config']->get('flasher_cli.icons', array()); // @phpstan-ignore-line
+
+ return new Notify($title, $icons);
+ });
+
+ $this->app->alias('flasher.notify', 'Flasher\Cli\Prime\Notify');
+ $this->app->alias('flasher.notify', 'Flasher\Cli\Prime\NotifyInterface');
}
- public function publishes(array $paths, $groups = null)
+ /**
+ * @return void
+ */
+ private function registerRenderListener()
{
- parent::publishes($paths, $groups);
+ /** @var FlasherInterface $flasher */
+ $flasher = $this->app['flasher'];
+ $this->app->extend('flasher.event_dispatcher', function (EventDispatcherInterface $dispatcher) use ($flasher) {
+ $dispatcher->addSubscriber(new RenderListener($flasher));
+
+ return $dispatcher;
+ });
+ }
+
+ /**
+ * @return void
+ */
+ private function registerPresenter()
+ {
+ $this->app->extend('flasher.response_manager', function (ResponseManagerInterface $manager, Container $app) {
+ $manager->addPresenter(CliPresenter::NAME, new CliPresenter($app['flasher.notify'])); // @phpstan-ignore-line
+
+ return $manager;
+ });
}
}
diff --git a/src/Cli/Laravel/README.md b/src/Cli/Laravel/README.md
index 5714d7d7..70048b42 100644
--- a/src/Cli/Laravel/README.md
+++ b/src/Cli/Laravel/README.md
@@ -24,12 +24,6 @@
-
-
-
-
-
-
# Why use PHP Flasher ?
@@ -53,21 +47,7 @@ This library is designed, so you can take full control when creating you notific
## Official Documentation
-Documentation for PHP Flasher can be found on the [PHP Flasher website](https://php-flasher.github.io/).
-
-## Backers && Sponsors
-
-Support this project by becoming a sponsor. Your name will show up in the Contribute page of all PHP Flasher installations as well as here with a link to your website!
-
-Thank you to all our backers and sponsors! 🙏
-
-
-
-
-
-
-
-
+Documentation for PHP Flasher can be found on the [PHP Flasher website](https://php-flasher.io).
### Contact
diff --git a/src/Cli/Laravel/Resources/config/config.php b/src/Cli/Laravel/Resources/config/config.php
deleted file mode 100644
index c905961d..00000000
--- a/src/Cli/Laravel/Resources/config/config.php
+++ /dev/null
@@ -1,110 +0,0 @@
- true,
-
- 'render_immediately' => true,
-
- 'title' => 'PHP Flasher',
-
- 'mute' => false,
-
- 'filter_criteria' => array(),
-
- 'icons' => array(),
-
- 'sounds' => array(),
-
- 'notifiers' => array(
- 'growl_notify' => array(
- 'enabled' => true,
- 'priority' => 0,
- 'binary' => 'growlnotify',
- 'binary_paths' => array(),
- 'title' => null,
- 'mute' => true,
- 'icons' => array(),
- 'sounds' => array(),
- ),
- 'kdialog_notifier' => array(
- 'enabled' => true,
- 'priority' => 0,
- 'binary' => 'kdialog',
- 'binary_paths' => array(),
- 'title' => null,
- 'mute' => true,
- 'icons' => array(),
- 'sounds' => array(),
- ),
- 'notifu_notifier' => array(
- 'enabled' => true,
- 'priority' => 0,
- 'binary' => 'notifu',
- 'binary_paths' => array(),
- 'title' => null,
- 'mute' => true,
- 'icons' => array(),
- 'sounds' => array(),
- ),
- 'notify_send' => array(
- 'enabled' => true,
- 'priority' => 2,
- 'binary' => 'notify-send',
- 'binary_paths' => array(),
- 'title' => null,
- 'mute' => true,
- 'icons' => array(),
- 'sounds' => array(),
- ),
- 'zenity' => array(
- 'enabled' => true,
- 'priority' => 1,
- 'binary' => 'zenity',
- 'binary_paths' => array(),
- 'title' => null,
- 'mute' => true,
- 'icons' => array(),
- 'sounds' => array(),
- ),
- 'snore_toast_notifier' => array(
- 'enabled' => true,
- 'priority' => 0,
- 'binary' => 'snoretoast',
- 'binary_paths' => array(),
- 'title' => null,
- 'mute' => true,
- 'icons' => array(),
- 'sounds' => array(),
- ),
- 'terminal_notifier_notifier' => array(
- 'enabled' => true,
- 'priority' => 0,
- 'binary' => 'terminal-notifier',
- 'binary_paths' => array(),
- 'title' => null,
- 'mute' => true,
- 'icons' => array(),
- 'sounds' => array(),
- ),
- 'toaster' => array(
- 'enabled' => true,
- 'priority' => 0,
- 'binary' => 'toast',
- 'binary_paths' => array(),
- 'title' => null,
- 'mute' => true,
- 'icons' => array(),
- 'sounds' => array(),
- ),
- 'apple_script' => array(
- 'enabled' => true,
- 'priority' => 1,
- 'binary' => 'osascript',
- 'binary_paths' => array(),
- 'title' => null,
- 'mute' => true,
- 'icons' => array(),
- 'sounds' => array(),
- ),
- ),
-);
diff --git a/src/Cli/Laravel/Resources/functions/cli.php b/src/Cli/Laravel/Resources/functions/cli.php
deleted file mode 100644
index 5d44cd0f..00000000
--- a/src/Cli/Laravel/Resources/functions/cli.php
+++ /dev/null
@@ -1,21 +0,0 @@
-with($stamps)->desktop($renderImmediately)->addFlash($type, $message, $options);
- }
-}
diff --git a/src/Cli/Laravel/ServiceProvider/Providers/Laravel.php b/src/Cli/Laravel/ServiceProvider/Providers/Laravel.php
deleted file mode 100644
index c5146e74..00000000
--- a/src/Cli/Laravel/ServiceProvider/Providers/Laravel.php
+++ /dev/null
@@ -1,151 +0,0 @@
-app = $app;
- }
-
- public function shouldBeUsed()
- {
- return $this->app instanceof Application;
- }
-
- public function boot(FlasherCliServiceProvider $provider)
- {
- $provider->publishes(array(
- flasher_path(__DIR__.'/../../Resources/config/config.php') => config_path('flasher_cli.php'),
- ), 'flasher-config');
-
- $this->afterBoot();
- }
-
- public function afterBoot()
- {
- $this->app['flasher.response_manager']->addPresenter('cli', $this->app['flasher.presenter.cli']);
-
- $this->app['flasher.event_dispatcher']->addSubscriber(new RenderListener($this->app['flasher.cli']));
-
- $this->app['flasher.event_dispatcher']->addSubscriber(new StampsListener(
- $this->app['flasher.config']->getFrom('flasher_cli', 'render_all', false),
- $this->app['flasher.config']->getFrom('flasher_cli', 'render_immediately', true)
- ));
-
- NotificationBuilder::macro('desktop', function ($renderImmediately = true) {
- return $this->withStamp(new DesktopStamp($renderImmediately));
- });
- }
-
- public function register(FlasherCliServiceProvider $provider)
- {
- $provider->mergeConfigFrom(flasher_path(__DIR__.'/../../Resources/config/config.php'), 'flasher_cli');
-
- $this->registerServices();
- }
-
- public function registerServices()
- {
- $this->app->singleton('flasher.cli', function (Container $app) {
- return new CliNotificationFactory(
- $app['flasher.storage_manager'],
- $app['flasher.response_manager'],
- $app['flasher.config']->getFrom('flasher_cli', 'filter_criteria', array())
- );
- });
-
- $this->app->singleton('flasher.cli.growl_notify', function (Container $app) {
- return new GrowlNotifyNotifier(Laravel::createConfigFor($app, 'growl_notify'));
- });
-
- $this->app->singleton('flasher.cli.kdialog_notifier', function (Container $app) {
- return new KDialogNotifier(Laravel::createConfigFor($app, 'kdialog_notifier'));
- });
-
- $this->app->singleton('flasher.cli.notifu_notifier', function (Container $app) {
- return new NotifuNotifier(Laravel::createConfigFor($app, 'notifu_notifier'));
- });
-
- $this->app->singleton('flasher.cli.notify_send', function (Container $app) {
- return new NotifySendNotifier(Laravel::createConfigFor($app, 'notify_send'));
- });
-
- $this->app->singleton('flasher.cli.snore_toast_notifier', function (Container $app) {
- return new SnoreToastNotifier(Laravel::createConfigFor($app, 'snore_toast_notifier'));
- });
-
- $this->app->singleton('flasher.cli.terminal_notifier_notifier', function (Container $app) {
- return new TerminalNotifierNotifier(Laravel::createConfigFor($app, 'terminal_notifier_notifier'));
- });
-
- $this->app->singleton('flasher.cli.toaster', function (Container $app) {
- return new ToasterNotifier(Laravel::createConfigFor($app, 'toaster'));
- });
-
- $this->app->singleton('flasher.cli.zenity', function (Container $app) {
- return new ToasterNotifier(Laravel::createConfigFor($app, 'zenity'));
- });
-
- $this->app->singleton('flasher.cli.apple_script', function (Container $app) {
- return new AppleScriptNotifier(Laravel::createConfigFor($app, 'apple_script'));
- });
-
- $this->app->singleton('flasher.presenter.cli', function (Container $app) {
- $presenter = new CliPresenter();
-
- $presenter->addNotifier($app['flasher.cli.growl_notify']);
- $presenter->addNotifier($app['flasher.cli.kdialog_notifier']);
- $presenter->addNotifier($app['flasher.cli.notifu_notifier']);
- $presenter->addNotifier($app['flasher.cli.notify_send']);
- $presenter->addNotifier($app['flasher.cli.snore_toast_notifier']);
- $presenter->addNotifier($app['flasher.cli.terminal_notifier_notifier']);
- $presenter->addNotifier($app['flasher.cli.toaster']);
- $presenter->addNotifier($app['flasher.cli.zenity']);
- $presenter->addNotifier($app['flasher.cli.apple_script']);
-
- return $presenter;
- });
-
- $this->app->alias('flasher.cli', 'Flasher\Cli\Prime\FlasherCli');
- $this->app->alias('Flasher\Cli\Prime\FlasherCli', 'Flasher\Cli\Prime\CliFlasherInterface');
- }
-
- private static function createConfigFor(Container $app, $notifier)
- {
- $options = $app['flasher.config']->getFrom('flasher_cli', 'notifiers.'.$notifier);
-
- $options['title'] = $app['flasher.config']->getFrom('flasher_cli', 'title');
- $options['mute'] = $app['flasher.config']->getFrom('flasher_cli', 'mute');
- $options['icons'] = array_replace_recursive($app['flasher.config']->getFrom('flasher_cli', 'icons'), $options['icons']);
- $options['sounds'] = array_replace_recursive($app['flasher.config']->getFrom('flasher_cli', 'sounds'), $options['sounds']);
-
- return $options;
- }
-}
diff --git a/src/Cli/Laravel/ServiceProvider/Providers/Laravel4.php b/src/Cli/Laravel/ServiceProvider/Providers/Laravel4.php
deleted file mode 100644
index 3caff568..00000000
--- a/src/Cli/Laravel/ServiceProvider/Providers/Laravel4.php
+++ /dev/null
@@ -1,30 +0,0 @@
-app instanceof Application && 0 === strpos(Application::VERSION, '4.');
- }
-
- public function boot(FlasherCliServiceProvider $provider)
- {
- $provider->package(
- 'php-flasher/flasher-cli-laravel',
- 'flasher_cli',
- flasher_path(__DIR__ . '/../../Resources')
- );
-
- $this->afterBoot();
- }
-
- public function register(FlasherCliServiceProvider $provider)
- {
- $this->registerServices();
- }
-}
diff --git a/src/Cli/Laravel/ServiceProvider/Providers/ServiceProviderInterface.php b/src/Cli/Laravel/ServiceProvider/Providers/ServiceProviderInterface.php
deleted file mode 100644
index 0e9e20dc..00000000
--- a/src/Cli/Laravel/ServiceProvider/Providers/ServiceProviderInterface.php
+++ /dev/null
@@ -1,17 +0,0 @@
-notifyServiceProvider = $notifyServiceProvider;
- }
-
- public function boot()
- {
- $provider = $this->resolveServiceProvider();
- $provider->boot($this->notifyServiceProvider);
- }
-
- public function register()
- {
- $provider = $this->resolveServiceProvider();
- $provider->register($this->notifyServiceProvider);
- }
-
- /**
- * @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/Cli/Laravel/UPGRADING.md b/src/Cli/Laravel/UPGRADING.md
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/Cli/Laravel/composer.json b/src/Cli/Laravel/composer.json
index c932c0c7..2c18f680 100644
--- a/src/Cli/Laravel/composer.json
+++ b/src/Cli/Laravel/composer.json
@@ -2,42 +2,28 @@
"name": "php-flasher/flasher-cli-laravel",
"description": "PHP Flasher Laravel adapter for Cli",
"type": "library",
- "keywords": [
- "yoeunes",
- "notify",
- "php",
- "laravel",
- "symfony",
- "Lumen",
- "notifications",
- "messages",
- "alerts",
- "pnotify",
- "cli ",
- "bundle",
- "flex"
- ],
- "homepage": "https://php-flasher.github.io/",
+ "keywords": ["yoeunes", "notify", "php", "laravel", "symfony", "Lumen", "notifications", "messages", "alerts", "pnotify", "cli ", "bundle", "flex"],
+ "homepage": "https://php-flasher.io",
"authors": [
{
- "name": "Younes Khoubza",
+ "name": "Younes KHOUBZA",
"email": "younes.khoubza@gmail.com",
- "homepage": "https://github.com/yoeunes",
+ "homepage": "https://www.linkedin.com/in/younes-khoubza",
"role": "Developer"
}
],
"license": "MIT",
"require": {
"php": ">=5.3",
- "php-flasher/flasher-laravel": "^0.9",
- "php-flasher/flasher-cli": "^0.9"
+ "php-flasher/flasher-laravel": "^1.0",
+ "php-flasher/flasher-cli": "^1.0"
},
"autoload": {
"psr-4": {
"Flasher\\Cli\\Laravel\\": ""
},
"files": [
- "Resources/functions/cli.php"
+ "notify.php"
]
},
"extra": {
@@ -50,6 +36,6 @@
"config": {
"sort-packages": true
},
- "minimum-stability": "dev",
+ "minimum-stability": "stable",
"prefer-stable": true
}
diff --git a/src/Cli/Laravel/notify.php b/src/Cli/Laravel/notify.php
new file mode 100644
index 00000000..ee080926
--- /dev/null
+++ b/src/Cli/Laravel/notify.php
@@ -0,0 +1,27 @@
+
+ */
+
+if (!function_exists('notify')) {
+ /**
+ * @param Flasher\Cli\Prime\Notification|string|null $notification
+ *
+ * @return Flasher\Cli\Prime\Notify
+ */
+ function notify($notification = null)
+ {
+ /** @var Flasher\Cli\Prime\Notify $notifier */
+ $notifier = app('flasher.notify');
+
+ if (null === $notification || 0 === func_num_args()) {
+ return $notifier;
+ }
+
+ $notifier->send($notification);
+
+ return $notifier;
+ }
+}
diff --git a/src/Cli/Prime/.editorconfig b/src/Cli/Prime/.editorconfig
deleted file mode 100644
index cd8eb86e..00000000
--- a/src/Cli/Prime/.editorconfig
+++ /dev/null
@@ -1,15 +0,0 @@
-; This file is for unifying the coding style for different editors and IDEs.
-; More information at http://editorconfig.org
-
-root = true
-
-[*]
-charset = utf-8
-indent_size = 4
-indent_style = space
-end_of_line = lf
-insert_final_newline = true
-trim_trailing_whitespace = true
-
-[*.md]
-trim_trailing_whitespace = false
diff --git a/src/Cli/Prime/.gitattributes b/src/Cli/Prime/.gitattributes
deleted file mode 100644
index 3383d44b..00000000
--- a/src/Cli/Prime/.gitattributes
+++ /dev/null
@@ -1,13 +0,0 @@
-
-# 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/Cli/Prime/.github/CONTRIBUTING.md b/src/Cli/Prime/.github/CONTRIBUTING.md
deleted file mode 100644
index b4ae1c4a..00000000
--- a/src/Cli/Prime/.github/CONTRIBUTING.md
+++ /dev/null
@@ -1,55 +0,0 @@
-# Contributing
-
-Contributions are **welcome** and will be fully **credited**.
-
-Please read and understand the contribution guide before creating an issue or pull request.
-
-## Etiquette
-
-This project is open source, and as such, the maintainers give their free time to build and maintain the source code
-held within. They make the code freely available in the hope that it will be of use to other developers. It would be
-extremely unfair for them to suffer abuse or anger for their hard work.
-
-Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the
-world that developers are civilized and selfless people.
-
-It's the duty of the maintainer to ensure that all submissions to the project are of sufficient
-quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used.
-
-## Viability
-
-When requesting or submitting new features, first consider whether it might be useful to others. Open
-source projects are used by many developers, who may have entirely different needs to your own. Think about
-whether or not your feature is likely to be used by other users of the project.
-
-## Procedure
-
-Before filing an issue:
-
-- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident.
-- Check to make sure your feature suggestion isn't already present within the project.
-- Check the pull requests tab to ensure that the bug doesn't have a fix in progress.
-- Check the pull requests tab to ensure that the feature isn't already in progress.
-
-Before submitting a pull request:
-
-- Check the codebase to ensure that your feature doesn't already exist.
-- Check the pull requests to ensure that another person hasn't already submitted the feature or fix.
-
-## Requirements
-
-If the project maintainer has any additional requirements, you will find them listed here.
-
-- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](https://pear.php.net/package/PHP_CodeSniffer).
-
-- **Add tests!** - Your patch won't be accepted if it doesn't have tests.
-
-- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.
-
-- **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option.
-
-- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
-
-- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.
-
-**Happy coding**!
diff --git a/src/Cli/Prime/.github/FUNDING.yml b/src/Cli/Prime/.github/FUNDING.yml
index 5e454f27..7de85ae3 100644
--- a/src/Cli/Prime/.github/FUNDING.yml
+++ b/src/Cli/Prime/.github/FUNDING.yml
@@ -1,5 +1,3 @@
-# These are supported funding model platforms
-
patreon: yoeunes
ko_fi: yoeunes
open_collective: php-flasher
diff --git a/src/Cli/Prime/.github/SECURITY.md b/src/Cli/Prime/.github/SECURITY.md
deleted file mode 100644
index d9b55dde..00000000
--- a/src/Cli/Prime/.github/SECURITY.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# Security Policy
-
-If you discover any security related issues, please email younes.khoubza@gmail.com instead of using the issue tracker.
diff --git a/src/Cli/Prime/.github/dependabot.yml b/src/Cli/Prime/.github/dependabot.yml
deleted file mode 100644
index c630ffa6..00000000
--- a/src/Cli/Prime/.github/dependabot.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-version: 2
-updates:
-- package-ecosystem: composer
- directory: "/"
- schedule:
- interval: daily
- open-pull-requests-limit: 10
diff --git a/src/Cli/Prime/.github/workflows/auto_closer.yaml b/src/Cli/Prime/.github/workflows/auto_closer.yaml
new file mode 100644
index 00000000..f807ac59
--- /dev/null
+++ b/src/Cli/Prime/.github/workflows/auto_closer.yaml
@@ -0,0 +1,22 @@
+name: Auto Closer PR
+
+on:
+ pull_request_target:
+ types: [opened]
+
+jobs:
+ run:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: superbrothers/close-pull-request@v3
+ with:
+ comment: |
+ Hi, thank you for your contribution.
+
+ Unfortunately, this repository is read-only. It's a split from our main monorepo repository.
+
+ We'd like to kindly ask you to move the contribution there - https://github.com/php-flasher/php-flasher.
+
+ We'll check it, review it and give you feed back right way.
+
+ Thank you.
diff --git a/src/Cli/Prime/.github/workflows/close-pull-request.yml b/src/Cli/Prime/.github/workflows/close-pull-request.yml
deleted file mode 100644
index ed229fac..00000000
--- a/src/Cli/Prime/.github/workflows/close-pull-request.yml
+++ /dev/null
@@ -1,13 +0,0 @@
-name: Close Pull Request
-
-on:
- pull_request_target:
- types: [opened]
-
-jobs:
- run:
- runs-on: ubuntu-latest
- steps:
- - uses: superbrothers/close-pull-request@v3
- with:
- comment: "Thank you for your pull request. However, you have submitted this PR on a read-only sub split of `php-flasher/php-flasher`. Please submit your PR on the https://github.com/php-flasher/php-flasher repository.
Thanks!"
diff --git a/src/Cli/Prime/.gitignore b/src/Cli/Prime/.gitignore
deleted file mode 100644
index 89d72688..00000000
--- a/src/Cli/Prime/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-.idea
-vendor
-composer.lock
-.phpunit.result.cache
-.phpcs-cache
diff --git a/src/Cli/Prime/.phpstorm.meta.php b/src/Cli/Prime/.phpstorm.meta.php
index 7c3f0838..ef331a8a 100644
--- a/src/Cli/Prime/.phpstorm.meta.php
+++ b/src/Cli/Prime/.phpstorm.meta.php
@@ -3,9 +3,9 @@
namespace PHPSTORM_META;
override(\Flasher\Prime\FlasherInterface::create(), map([
- 'cli' => \Flasher\Cli\Prime\CliNotificationFactory::class
+ 'cli' => \Flasher\Cli\Prime\CliFactory::class
]));
override(\Flasher\Prime\FlasherInterface::using(), map([
- 'cli' => \Flasher\Cli\Prime\CliNotificationFactory::class
+ 'cli' => \Flasher\Cli\Prime\CliFactory::class
]));
diff --git a/src/Cli/Prime/CHANGELOG.md b/src/Cli/Prime/CHANGELOG.md
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/Cli/Prime/CODE_OF_CONDUCT.md b/src/Cli/Prime/CODE_OF_CONDUCT.md
deleted file mode 100644
index ec367cc6..00000000
--- a/src/Cli/Prime/CODE_OF_CONDUCT.md
+++ /dev/null
@@ -1,76 +0,0 @@
-# Contributor Covenant Code of Conduct
-
-## Our Pledge
-
-In the interest of fostering an open and welcoming environment, we as
-contributors and maintainers pledge to making participation in our project and
-our community a harassment-free experience for everyone, regardless of age, body
-size, disability, ethnicity, sex characteristics, gender identity and expression,
-level of experience, education, socio-economic status, nationality, personal
-appearance, race, religion, or sexual identity and orientation.
-
-## Our Standards
-
-Examples of behavior that contributes to creating a positive environment
-include:
-
-* Using welcoming and inclusive language
-* Being respectful of differing viewpoints and experiences
-* Gracefully accepting constructive criticism
-* Focusing on what is best for the community
-* Showing empathy towards other community members
-
-Examples of unacceptable behavior by participants include:
-
-* The use of sexualized language or imagery and unwelcome sexual attention or
- advances
-* Trolling, insulting/derogatory comments, and personal or political attacks
-* Public or private harassment
-* Publishing others' private information, such as a physical or electronic
- address, without explicit permission
-* Other conduct which could reasonably be considered inappropriate in a
- professional setting
-
-## Our Responsibilities
-
-Project maintainers are responsible for clarifying the standards of acceptable
-behavior and are expected to take appropriate and fair corrective action in
-response to any instances of unacceptable behavior.
-
-Project maintainers have the right and responsibility to remove, edit, or
-reject comments, commits, code, wiki edits, issues, and other contributions
-that are not aligned to this Code of Conduct, or to ban temporarily or
-permanently any contributor for other behaviors that they deem inappropriate,
-threatening, offensive, or harmful.
-
-## Scope
-
-This Code of Conduct applies both within project spaces and in public spaces
-when an individual is representing the project or its community. Examples of
-representing a project or community include using an official project e-mail
-address, posting via an official social media account, or acting as an appointed
-representative at an online or offline event. Representation of a project may be
-further defined and clarified by project maintainers.
-
-## Enforcement
-
-Instances of abusive, harassing, or otherwise unacceptable behavior may be
-reported by contacting the project team at younes.khoubza@gmail.com. All
-complaints will be reviewed and investigated and will result in a response that
-is deemed necessary and appropriate to the circumstances. The project team is
-obligated to maintain confidentiality with regard to the reporter of an incident.
-Further details of specific enforcement policies may be posted separately.
-
-Project maintainers who do not follow or enforce the Code of Conduct in good
-faith may face temporary or permanent repercussions as determined by other
-members of the project's leadership.
-
-## Attribution
-
-This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
-available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
-
-[homepage]: https://www.contributor-covenant.org
-
-For answers to common questions about this code of conduct, see
-https://www.contributor-covenant.org/faq
diff --git a/src/Cli/Prime/CliNotificationBuilder.php b/src/Cli/Prime/CliBuilder.php
similarity index 59%
rename from src/Cli/Prime/CliNotificationBuilder.php
rename to src/Cli/Prime/CliBuilder.php
index 5c03e646..347e5e2b 100644
--- a/src/Cli/Prime/CliNotificationBuilder.php
+++ b/src/Cli/Prime/CliBuilder.php
@@ -1,20 +1,26 @@
+ */
+
namespace Flasher\Cli\Prime;
use Flasher\Prime\Notification\NotificationBuilder;
-final class CliNotificationBuilder extends NotificationBuilder
+final class CliBuilder extends NotificationBuilder
{
/**
* @param string $title
*
- * @return self
+ * @return static
*/
public function title($title)
{
+ /** @var Notification $notification */
$notification = $this->envelope->getNotification();
- $notification->setTitle(addslashes($title));
+ $notification->setTitle($title);
return $this;
}
@@ -22,10 +28,11 @@ final class CliNotificationBuilder extends NotificationBuilder
/**
* @param string $icon
*
- * @return self
+ * @return static
*/
public function icon($icon)
{
+ /** @var Notification $notification */
$notification = $this->envelope->getNotification();
$notification->setIcon($icon);
diff --git a/src/Cli/Prime/CliFactory.php b/src/Cli/Prime/CliFactory.php
new file mode 100644
index 00000000..443c40e7
--- /dev/null
+++ b/src/Cli/Prime/CliFactory.php
@@ -0,0 +1,18 @@
+
+ */
+
+namespace Flasher\Cli\Prime;
+
+use Flasher\Prime\Factory\NotificationFactory;
+
+final class CliFactory extends NotificationFactory
+{
+ public function createNotificationBuilder()
+ {
+ return new CliBuilder($this->getStorageManager(), new Notification(), 'cli');
+ }
+}
diff --git a/src/Cli/Prime/CliFlasherInterface.php b/src/Cli/Prime/CliFlasherInterface.php
deleted file mode 100644
index 87ff9d4e..00000000
--- a/src/Cli/Prime/CliFlasherInterface.php
+++ /dev/null
@@ -1,11 +0,0 @@
-title;
- }
-
- /**
- * @param string $title
- */
- public function setTitle($title)
- {
- $this->title = $title;
- }
-
- /**
- * @return string
- */
- public function getIcon()
- {
- return $this->icon;
- }
-
- /**
- * @param string $icon
- */
- public function setIcon($icon)
- {
- $this->icon = $icon;
- }
-
- public function toArray()
- {
- return array_merge(parent::toArray(), array(
- 'title' => $this->getTitle(),
- 'icon' => $this->getIcon(),
- ));
- }
-}
diff --git a/src/Cli/Prime/CliNotificationFactory.php b/src/Cli/Prime/CliNotificationFactory.php
deleted file mode 100644
index 486888b3..00000000
--- a/src/Cli/Prime/CliNotificationFactory.php
+++ /dev/null
@@ -1,38 +0,0 @@
-responseManager = $responseManager;
- $this->filterCriteria = $filterCriteria;
- }
-
- public function render(array $criteria = array(), $merge = true)
- {
- if ($merge) {
- $criteria = $this->filterCriteria + $criteria;
- }
-
- return $this->responseManager->render($criteria, 'cli');
- }
-
- public function createNotificationBuilder()
- {
- return new CliNotificationBuilder($this->getStorageManager(), new CliNotification(), 'cli');
- }
-}
diff --git a/src/Cli/Prime/EventListener/RenderListener.php b/src/Cli/Prime/EventListener/RenderListener.php
index e616f30c..6d4648a2 100644
--- a/src/Cli/Prime/EventListener/RenderListener.php
+++ b/src/Cli/Prime/EventListener/RenderListener.php
@@ -1,43 +1,44 @@
+ */
+
namespace Flasher\Cli\Prime\EventListener;
-use Flasher\Cli\Prime\CliFlasherInterface;
-use Flasher\Cli\Prime\Stamp\DesktopStamp;
-use Flasher\Prime\Envelope;
+use Flasher\Cli\Prime\Presenter\CliPresenter;
use Flasher\Prime\EventDispatcher\Event\PostPersistEvent;
use Flasher\Prime\EventDispatcher\EventListener\EventSubscriberInterface;
+use Flasher\Prime\FlasherInterface;
final class RenderListener implements EventSubscriberInterface
{
+ /**
+ * @var FlasherInterface
+ */
private $flasher;
- public function __construct(CliFlasherInterface $flasher)
+ public function __construct(FlasherInterface $flasher)
{
$this->flasher = $flasher;
}
/**
- * @param PostPersistEvent $event
+ * @return void
*/
- public function __invoke($event)
+ public function __invoke(PostPersistEvent $event)
{
- if (PHP_SAPI !== 'cli') {
+ if ('cli' !== \PHP_SAPI) {
return;
}
- $callback = function(Envelope $envelope) {
- $stamp = $envelope->get('Flasher\Cli\Prime\Stamp\DesktopStamp');
- if (!$stamp instanceof DesktopStamp) {
- return false;
- }
-
- return $stamp->isRenderImmediately();
- };
-
- $this->flasher->render(array('filter' => $callback));
+ $this->flasher->render(array(), CliPresenter::NAME);
}
+ /**
+ * {@inheritdoc}
+ */
public static function getSubscribedEvents()
{
return 'Flasher\Prime\EventDispatcher\Event\PostPersistEvent';
diff --git a/src/Cli/Prime/EventListener/StampsListener.php b/src/Cli/Prime/EventListener/StampsListener.php
deleted file mode 100644
index dcd9dc13..00000000
--- a/src/Cli/Prime/EventListener/StampsListener.php
+++ /dev/null
@@ -1,48 +0,0 @@
-renderAll = $renderAll;
- $this->renderImmediately = $renderImmediately;
- }
-
- /**
- * @param PersistEvent|UpdateEvent $event
- */
- public function __invoke($event)
- {
- if (PHP_SAPI !== 'cli') {
- return;
- }
-
- foreach ($event->getEnvelopes() as $envelope) {
- $this->attachStamps($envelope);
- }
- }
-
- public static function getSubscribedEvents()
- {
- return 'Flasher\Prime\EventDispatcher\Event\PersistEvent';
- }
-
- private function attachStamps(Envelope $envelope)
- {
- $stamp = $envelope->get('Flasher\Cli\Prime\Stamp\DesktopStamp');
- if (null === $stamp && true === $this->renderAll) {
- $envelope->withStamp(new DesktopStamp($this->renderImmediately));
- }
- }
-}
diff --git a/src/Cli/Prime/Notification.php b/src/Cli/Prime/Notification.php
new file mode 100644
index 00000000..404f38d4
--- /dev/null
+++ b/src/Cli/Prime/Notification.php
@@ -0,0 +1,228 @@
+
+ */
+
+namespace Flasher\Cli\Prime;
+
+use Flasher\Prime\Notification\Envelope;
+use Flasher\Prime\Notification\Notification as BaseNotification;
+use Flasher\Prime\Notification\NotificationInterface;
+
+final class Notification extends BaseNotification
+{
+ /**
+ * @var string|null
+ */
+ private $title;
+
+ /**
+ * @var string|null
+ */
+ private $icon;
+
+ /**
+ * @param string|null $message
+ * @param string|null $title
+ * @param string|null $icon
+ * @param string $type
+ * @param array $options
+ */
+ public function __construct($message = null, $title = null, $icon = null, $type = self::INFO, array $options = array())
+ {
+ $this->message = $message;
+ $this->title = $title;
+ $this->icon = $icon;
+ $this->type = $type;
+ $this->options = $options;
+ }
+
+ /**
+ * @param Notification|string $notification
+ *
+ * @return static
+ */
+ public static function wrap($notification)
+ {
+ if ($notification instanceof Notification) {
+ return $notification;
+ }
+
+ return self::create($notification);
+ }
+
+ /**
+ * @param string $message
+ * @param string|null $title
+ * @param string|null $icon
+ * @param string $type
+ * @param array $options
+ *
+ * @return static
+ */
+ public static function create($message, $title = null, $icon = null, $type = self::INFO, array $options = array())
+ {
+ return new self($message, $title, $icon, $type, $options);
+ }
+
+ /**
+ * @param string $message
+ * @param string|null $title
+ * @param string|null $icon
+ * @param array $options
+ *
+ * @return static
+ */
+ public static function error($message, $title = null, $icon = null, array $options = array())
+ {
+ return self::create($message, $title, $icon, NotificationInterface::ERROR, $options);
+ }
+
+ /**
+ * @param string $message
+ * @param string|null $title
+ * @param string|null $icon
+ * @param array $options
+ *
+ * @return static
+ */
+ public static function info($message, $title = null, $icon = null, array $options = array())
+ {
+ return self::create($message, $title, $icon, NotificationInterface::INFO, $options);
+ }
+
+ /**
+ * @param string $message
+ * @param string|null $title
+ * @param string|null $icon
+ * @param array $options
+ *
+ * @return static
+ */
+ public static function success($message, $title = null, $icon = null, array $options = array())
+ {
+ return self::create($message, $title, $icon, NotificationInterface::SUCCESS, $options);
+ }
+
+ /**
+ * @param string $message
+ * @param string|null $title
+ * @param string|null $icon
+ * @param array $options
+ *
+ * @return static
+ */
+ public static function warning($message, $title = null, $icon = null, array $options = array())
+ {
+ return self::create($message, $title, $icon, NotificationInterface::WARNING, $options);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getMessage()
+ {
+ $message = parent::getMessage();
+
+ if (\is_string($message)) {
+ $message = addslashes($message);
+ }
+
+ return $message;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getOption($name, $default = null)
+ {
+ $option = parent::getOption($name, $default);
+
+ if (\is_string($option)) {
+ $option = addslashes($option);
+ }
+
+ return $option;
+ }
+
+ /**
+ * @return string|null
+ */
+ public function getTitle()
+ {
+ $title = $this->title;
+
+ if (\is_string($title)) {
+ $title = addslashes($title);
+ }
+
+ return $title;
+ }
+
+ /**
+ * @param string|null $title
+ *
+ * @return static
+ */
+ public function setTitle($title)
+ {
+ $this->title = $title;
+
+ return $this;
+ }
+
+ /**
+ * @return string|null
+ */
+ public function getIcon()
+ {
+ return $this->icon;
+ }
+
+ /**
+ * @param string|null $icon
+ *
+ * @return static
+ */
+ public function setIcon($icon)
+ {
+ $this->icon = $icon;
+
+ return $this;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function toArray()
+ {
+ return array_merge(parent::toArray(), array(
+ 'title' => $this->getTitle(),
+ 'icon' => $this->getIcon(),
+ ));
+ }
+
+ /**
+ * @return static
+ */
+ public static function fromEnvelope(Envelope $envelope)
+ {
+ $self = new self();
+
+ $self->setType($envelope->getType());
+ $self->setMessage($envelope->getMessage());
+ $self->setOptions($envelope->getOptions());
+
+ $notification = $envelope->getNotification();
+ if (!$notification instanceof self) {
+ return $self;
+ }
+
+ $self->setTitle($notification->getTitle());
+ $self->setIcon($notification->getIcon());
+
+ return $self;
+ }
+}
diff --git a/src/Cli/Prime/Notifier/AbstractNotifier.php b/src/Cli/Prime/Notifier/AbstractNotifier.php
deleted file mode 100644
index c80b66d9..00000000
--- a/src/Cli/Prime/Notifier/AbstractNotifier.php
+++ /dev/null
@@ -1,146 +0,0 @@
-configureOptions($options);
- }
-
- public function render(array $envelopes)
- {
- foreach ($envelopes as $envelope) {
- $this->renderEnvelope($envelope);
- }
- }
-
- abstract public function renderEnvelope(Envelope $envelope);
-
- public function isSupported()
- {
- return $this->options['is_supported'];
- }
-
- public function getPriority()
- {
- return $this->options['priority'];
- }
-
- public function getBinary()
- {
- return $this->options['binary'];
- }
-
- public function getBinaryPaths()
- {
- return $this->options['binary_paths'];
- }
-
- public function getProgram()
- {
- if (Program::exist($this->getBinary())) {
- return $this->getBinary();
- }
-
- foreach ((array)$this->getBinaryPaths() as $path) {
- $path = Path::realpath($path);
-
- if (file_exists($path)) {
- return $path;
- }
- }
-
- return null;
- }
-
- public function getTitle(Envelope $envelope)
- {
- $notification = $envelope->getNotification();
-
- if (method_exists($notification, 'getTitle') && null !== $notification->getTitle()) {
- return addslashes($notification->getTitle());
- }
-
- return addslashes($this->options['title']);
- }
-
- public function isEnabled()
- {
- return $this->options['enabled'];
- }
-
- /**
- * @param Envelope $envelope
- *
- * @return string
- */
- public function getIcon(Envelope $envelope)
- {
- $notification = $envelope->getNotification();
- if ($notification instanceof CliNotification && $notification->getIcon()) {
- return Path::realpath($notification->getIcon());
- }
-
- $type = $envelope->getType();
-
- if (isset($this->options['icons'][$type]) && file_exists($this->options['icons'][$type])) {
- return Path::realpath($this->options['icons'][$type]);
- }
-
- return Path::realpath(__DIR__.'/../Resources/icons/info.png');
- }
-
- public function playSound($type = null)
- {
- if ($this->options['mute']) {
- return;
- }
-
- \exec('paplay '.$this->getSound($type));
- }
-
- public function getSound($type)
- {
- if (isset($this->options['sounds'][$type]) && file_exists($this->options['sounds'][$type])) {
- return Path::realpath($this->options['sounds'][$type]);
- }
-
- return Path::realpath(__DIR__.'/../Resources/sounds/info.wav');
- }
-
- public function configureOptions(array $options)
- {
- $default = array(
- 'enabled' => true,
- 'priority' => 0,
- 'binary' => null,
- 'binary_paths' => array(),
- 'title' => 'PHPFlasher',
- 'icons' => array(
- NotificationInterface::TYPE_SUCCESS => Path::realpath(__DIR__.'/../Resources/icons/success.png'),
- NotificationInterface::TYPE_ERROR => Path::realpath(__DIR__.'/../Resources/icons/error.png'),
- NotificationInterface::TYPE_INFO => Path::realpath(__DIR__.'/../Resources/icons/info.png'),
- NotificationInterface::TYPE_WARNING => Path::realpath(__DIR__.'/../Resources/icons/warning.png'),
- ),
- 'mute' => false,
- 'sounds' => array(
- NotificationInterface::TYPE_SUCCESS => Path::realpath(__DIR__.'/../Resources/sounds/success.wav'),
- NotificationInterface::TYPE_ERROR => Path::realpath(__DIR__.'/../Resources/sounds/error.wav'),
- NotificationInterface::TYPE_INFO => Path::realpath(__DIR__.'/../Resources/sounds/info.wav'),
- NotificationInterface::TYPE_WARNING => Path::realpath(__DIR__.'/../Resources/sounds/warning.wav'),
- ),
- );
-
- $this->options = array_replace_recursive($default, $options);
- }
-}
diff --git a/src/Cli/Prime/Notifier/AppleScriptBaseNotifier.php b/src/Cli/Prime/Notifier/AppleScriptBaseNotifier.php
new file mode 100644
index 00000000..6411dccc
--- /dev/null
+++ b/src/Cli/Prime/Notifier/AppleScriptBaseNotifier.php
@@ -0,0 +1,57 @@
+
+ */
+
+namespace Flasher\Cli\Prime\Notifier;
+
+use Flasher\Cli\Prime\Notification;
+use Flasher\Cli\Prime\System\Command;
+use Flasher\Cli\Prime\System\OS;
+
+final class AppleScriptBaseNotifier extends BaseNotifier
+{
+ /**
+ * {@inheritdoc}
+ */
+ public function send($notification)
+ {
+ $notification = Notification::wrap($notification);
+
+ $cmd = new Command($this->getProgram());
+
+ $cmd
+ ->addArgument(sprintf('display notification "%s"', $notification->getMessage()))
+ ->addArgument(sprintf('with title "%s"', $notification->getTitle()));
+
+ /** @var string $subtitle */
+ $subtitle = $notification->getOption('subtitle');
+ if ($subtitle) {
+ $cmd->addArgument(sprintf('subtitle "%s"', $subtitle));
+ }
+
+ $cmd->run();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function isSupported()
+ {
+ if (!$this->getProgram()) {
+ return false;
+ }
+
+ return OS::isMacOS() && version_compare(OS::getMacOSVersion(), '10.9.0', '>=');
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getBinary()
+ {
+ return 'osascript';
+ }
+}
diff --git a/src/Cli/Prime/Notifier/AppleScriptNotifier.php b/src/Cli/Prime/Notifier/AppleScriptNotifier.php
deleted file mode 100644
index b34c6f45..00000000
--- a/src/Cli/Prime/Notifier/AppleScriptNotifier.php
+++ /dev/null
@@ -1,51 +0,0 @@
-getProgram());
-
- $cmd
- ->addArgument(sprintf('display notification "%s"', $envelope->getMessage()))
- ->addArgument(sprintf('with title "%s"', $this->getTitle($envelope)));
-
- $subtitle = $envelope->getOption('subtitle');
- if ($subtitle) {
- $cmd->addArgument(sprintf('subtitle "%s"', $subtitle));
- }
-
- $sound = $envelope->getOption('sound');
- if ($sound) {
- $cmd->addArgument(sprintf('sound name "%s"', $sound));
- }
-
- $cmd->run();
- }
-
- public function isSupported()
- {
- if (!$this->getProgram() || !$this->isEnabled()) {
- return false;
- }
-
- return OS::isMacOS() && version_compare(OS::getMacOSVersion(), '10.9.0', '>=');
- }
-
- public function configureOptions(array $options)
- {
- $default = array(
- 'binary' => 'osascript',
- );
-
- $options = array_replace_recursive($default, $options);
-
- parent::configureOptions($options);
- }
-}
diff --git a/src/Cli/Prime/Notifier/BaseNotifier.php b/src/Cli/Prime/Notifier/BaseNotifier.php
new file mode 100644
index 00000000..53eddf96
--- /dev/null
+++ b/src/Cli/Prime/Notifier/BaseNotifier.php
@@ -0,0 +1,111 @@
+
+ */
+
+namespace Flasher\Cli\Prime\Notifier;
+
+use Flasher\Cli\Prime\Notification;
+use Flasher\Cli\Prime\NotifyInterface;
+use Flasher\Cli\Prime\System\Path;
+use Flasher\Cli\Prime\System\Program;
+use Flasher\Prime\Notification\NotificationInterface;
+
+abstract class BaseNotifier implements NotifyInterface
+{
+ /**
+ * {@inheritdoc}
+ */
+ public function isSupported()
+ {
+ return true;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getPriority()
+ {
+ return 0;
+ }
+
+ /**
+ * @return string|null
+ */
+ public function getBinary()
+ {
+ return null;
+ }
+
+ /**
+ * @return string|string[]
+ */
+ public function getBinaryPaths()
+ {
+ return array();
+ }
+
+ /**
+ * @return string|null
+ */
+ public function getProgram()
+ {
+ if (Program::exist($this->getBinary())) {
+ return $this->getBinary();
+ }
+
+ foreach ((array) $this->getBinaryPaths() as $path) {
+ $path = Path::realpath($path);
+
+ if (file_exists($path)) {
+ return $path;
+ }
+ }
+
+ return null;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function success($message, $title = null, $options = array())
+ {
+ $this->type(NotificationInterface::SUCCESS, $message, $title, $options);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function info($message, $title = null, $options = array())
+ {
+ $this->type(NotificationInterface::INFO, $message, $title, $options);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function error($message, $title = null, $options = array())
+ {
+ $this->type(NotificationInterface::ERROR, $message, $title, $options);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function warning($message, $title = null, $options = array())
+ {
+ $this->type(NotificationInterface::WARNING, $message, $title, $options);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function type($type, $message, $title = null, $options = array())
+ {
+ $notification = new Notification($message, $title, null, $type, $options);
+
+ $this->send($notification);
+ }
+}
diff --git a/src/Cli/Prime/Notifier/GrowlNotifyBaseNotifier.php b/src/Cli/Prime/Notifier/GrowlNotifyBaseNotifier.php
new file mode 100644
index 00000000..4a0434ef
--- /dev/null
+++ b/src/Cli/Prime/Notifier/GrowlNotifyBaseNotifier.php
@@ -0,0 +1,48 @@
+
+ */
+
+namespace Flasher\Cli\Prime\Notifier;
+
+use Flasher\Cli\Prime\Notification;
+use Flasher\Cli\Prime\System\Command;
+use Flasher\Cli\Prime\System\OS;
+
+final class GrowlNotifyBaseNotifier extends BaseNotifier
+{
+ /**
+ * {@inheritdoc}
+ */
+ public function send($notification)
+ {
+ $notification = Notification::wrap($notification);
+
+ $cmd = new Command($this->getProgram());
+
+ $cmd
+ ->addOption('--message', $notification->getMessage())
+ ->addOption('--title', $notification->getTitle())
+ ->addOption('--image', $notification->getIcon());
+
+ $cmd->run();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function isSupported()
+ {
+ return OS::isMacOS() && $this->getProgram();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getBinary()
+ {
+ return 'growlnotify';
+ }
+}
diff --git a/src/Cli/Prime/Notifier/GrowlNotifyNotifier.php b/src/Cli/Prime/Notifier/GrowlNotifyNotifier.php
deleted file mode 100644
index 73cce673..00000000
--- a/src/Cli/Prime/Notifier/GrowlNotifyNotifier.php
+++ /dev/null
@@ -1,38 +0,0 @@
-getProgram());
-
- $cmd
- ->addOption('--message', $envelope->getMessage())
- ->addOption('--title', $this->getTitle($envelope))
- ->addOption('--image', $this->getIcon($envelope));
-
- $cmd->run();
- }
-
- public function isSupported()
- {
- return $this->isEnabled() && OS::isMacOS() && $this->getProgram();
- }
-
- public function configureOptions(array $options)
- {
- $default = array(
- 'binary' => 'growlnotify',
- );
-
- $options = array_replace_recursive($default, $options);
-
- parent::configureOptions($options);
- }
-}
diff --git a/src/Cli/Prime/Notifier/KDialogBaseNotifier.php b/src/Cli/Prime/Notifier/KDialogBaseNotifier.php
new file mode 100644
index 00000000..b5e9ba65
--- /dev/null
+++ b/src/Cli/Prime/Notifier/KDialogBaseNotifier.php
@@ -0,0 +1,48 @@
+
+ */
+
+namespace Flasher\Cli\Prime\Notifier;
+
+use Flasher\Cli\Prime\Notification;
+use Flasher\Cli\Prime\System\Command;
+use Flasher\Cli\Prime\System\OS;
+
+final class KDialogBaseNotifier extends BaseNotifier
+{
+ /**
+ * {@inheritdoc}
+ */
+ public function send($notification)
+ {
+ $notification = Notification::wrap($notification);
+
+ $cmd = new Command($this->getProgram());
+
+ $cmd
+ ->addOption('--passivepopup', $notification->getMessage())
+ ->addOption('--title', $notification->getTitle())
+ ->addArgument(5);
+
+ $cmd->run();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function isSupported()
+ {
+ return OS::isUnix() && $this->getProgram();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getBinary()
+ {
+ return 'kdialog';
+ }
+}
diff --git a/src/Cli/Prime/Notifier/KDialogNotifier.php b/src/Cli/Prime/Notifier/KDialogNotifier.php
deleted file mode 100644
index 072f9abc..00000000
--- a/src/Cli/Prime/Notifier/KDialogNotifier.php
+++ /dev/null
@@ -1,38 +0,0 @@
-getProgram());
-
- $cmd
- ->addOption('--passivepopup', $envelope->getMessage())
- ->addOption('--title', $this->getTitle($envelope))
- ->addArgument(5);
-
- $cmd->run();
- }
-
- public function isSupported()
- {
- return $this->isEnabled() && OS::isUnix() && $this->getProgram();
- }
-
- public function configureOptions(array $options)
- {
- $default = array(
- 'binary' => 'kdialog',
- );
-
- $options = array_replace_recursive($default, $options);
-
- parent::configureOptions($options);
- }
-}
diff --git a/src/Cli/Prime/Notifier/NotifierInterface.php b/src/Cli/Prime/Notifier/NotifierInterface.php
deleted file mode 100644
index c4cf1111..00000000
--- a/src/Cli/Prime/Notifier/NotifierInterface.php
+++ /dev/null
@@ -1,28 +0,0 @@
-
+ */
+
+namespace Flasher\Cli\Prime\Notifier;
+
+use Flasher\Cli\Prime\Notification;
+use Flasher\Cli\Prime\System\Command;
+use Flasher\Cli\Prime\System\OS;
+use Flasher\Cli\Prime\System\Path;
+
+final class NotifuBaseNotifier extends BaseNotifier
+{
+ public function send($notification)
+ {
+ $notification = Notification::wrap($notification);
+
+ $cmd = new Command($this->getProgram());
+
+ $cmd
+ ->addOption('/m', $notification->getMessage())
+ ->addOption('/p', $notification->getTitle())
+ ->addOption('/i', $notification->getIcon());
+
+ $cmd->run();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function isSupported()
+ {
+ return OS::isWindowsSeven() && $this->getProgram();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getBinary()
+ {
+ return 'notifu';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getBinaryPaths()
+ {
+ return Path::realpath(__DIR__.'/../Resources/bin/notifu/notifu.exe');
+ }
+}
diff --git a/src/Cli/Prime/Notifier/NotifuNotifier.php b/src/Cli/Prime/Notifier/NotifuNotifier.php
deleted file mode 100644
index bf98981c..00000000
--- a/src/Cli/Prime/Notifier/NotifuNotifier.php
+++ /dev/null
@@ -1,42 +0,0 @@
-getProgram());
-
- $cmd
- ->addOption('/m', $envelope->getMessage())
- ->addOption('/p', $this->getTitle($envelope))
- ->addOption('/i', $this->getIcon($envelope));
-
- $cmd->run();
- }
-
- public function isSupported()
- {
- return $this->isEnabled() && OS::isWindowsSeven() && $this->getProgram();
- }
-
- public function configureOptions(array $options)
- {
- $default = array(
- 'binary' => 'notifu',
- 'binary_paths' => array(
- Path::realpath(__DIR__.'/../Resources/bin/notifu/notifu.exe'),
- ),
- );
-
- $options = array_replace_recursive($default, $options);
-
- parent::configureOptions($options);
- }
-}
diff --git a/src/Cli/Prime/Notifier/NotifySendBaseNotifier.php b/src/Cli/Prime/Notifier/NotifySendBaseNotifier.php
new file mode 100644
index 00000000..9fbd24f4
--- /dev/null
+++ b/src/Cli/Prime/Notifier/NotifySendBaseNotifier.php
@@ -0,0 +1,51 @@
+
+ */
+
+namespace Flasher\Cli\Prime\Notifier;
+
+use Flasher\Cli\Prime\Notification;
+use Flasher\Cli\Prime\System\Command;
+use Flasher\Cli\Prime\System\OS;
+
+final class NotifySendBaseNotifier extends BaseNotifier
+{
+ /**
+ * {@inheritdoc}
+ */
+ public function send($notification)
+ {
+ $notification = Notification::wrap($notification);
+
+ $cmd = new Command($this->getProgram());
+
+ $cmd
+ ->addOption('--urgency', 'normal')
+ ->addOption('--app-name', 'notify')
+ ->addOption('--icon', $notification->getIcon())
+ ->addOption('--expire-time', 1)
+ ->addArgument($notification->getTitle())
+ ->addArgument($notification->getMessage());
+
+ $cmd->run();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function isSupported()
+ {
+ return OS::isUnix() && $this->getProgram();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getBinary()
+ {
+ return 'notify-send';
+ }
+}
diff --git a/src/Cli/Prime/Notifier/NotifySendNotifier.php b/src/Cli/Prime/Notifier/NotifySendNotifier.php
deleted file mode 100644
index 6034e592..00000000
--- a/src/Cli/Prime/Notifier/NotifySendNotifier.php
+++ /dev/null
@@ -1,48 +0,0 @@
-getProgram());
-
- $cmd
- ->addOption('--urgency', 'normal')
- ->addOption('--app-name', 'notify')
- ->addOption('--icon', $this->getIcon($envelope))
- ->addOption('--expire-time', $this->getExpireTime())
- ->addArgument($this->getTitle($envelope))
- ->addArgument($envelope->getMessage());
-
- $cmd->run();
- }
-
- public function isSupported()
- {
- return $this->isEnabled() && OS::isUnix() && $this->getProgram();
- }
-
- public function getExpireTime()
- {
- return (int)$this->options['expire_time'];
- }
-
- public function configureOptions(array $options)
- {
- $default = array(
- 'binary' => 'notify-send',
- 'expire_time' => 1,
- 'priority' => 2,
- );
-
- $options = array_replace_recursive($default, $options);
-
- parent::configureOptions($options);
- }
-}
diff --git a/src/Cli/Prime/Notifier/NullBaseNotifier.php b/src/Cli/Prime/Notifier/NullBaseNotifier.php
new file mode 100644
index 00000000..ea93cbfe
--- /dev/null
+++ b/src/Cli/Prime/Notifier/NullBaseNotifier.php
@@ -0,0 +1,34 @@
+
+ */
+
+namespace Flasher\Cli\Prime\Notifier;
+
+final class NullBaseNotifier extends BaseNotifier
+{
+ /**
+ * {@inheritdoc}
+ */
+ public function send($notification)
+ {
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function isSupported()
+ {
+ return false;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getBinary()
+ {
+ return '';
+ }
+}
diff --git a/src/Cli/Prime/Notifier/NullNotifier.php b/src/Cli/Prime/Notifier/NullNotifier.php
deleted file mode 100644
index 74f26dc0..00000000
--- a/src/Cli/Prime/Notifier/NullNotifier.php
+++ /dev/null
@@ -1,17 +0,0 @@
-
+ */
+
+namespace Flasher\Cli\Prime\Notifier;
+
+use Flasher\Cli\Prime\Notification;
+use Flasher\Cli\Prime\System\Command;
+use Flasher\Cli\Prime\System\OS;
+use Flasher\Cli\Prime\System\Path;
+
+final class SnoreToastBaseNotifier extends BaseNotifier
+{
+ /**
+ * {@inheritdoc}
+ */
+ public function send($notification)
+ {
+ $notification = Notification::wrap($notification);
+
+ $cmd = new Command($this->getProgram());
+
+ $cmd
+ ->addOption('-m', $notification->getMessage())
+ ->addOption('-t', $notification->getTitle())
+ ->addOption('-p', $notification->getIcon());
+
+ $cmd->run();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function isSupported()
+ {
+ if (!$this->getProgram()) {
+ return false;
+ }
+
+ return OS::isWindowsEightOrHigher() || OS::isWindowsSubsystemForLinux();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getBinary()
+ {
+ return 'snoretoast';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getBinaryPaths()
+ {
+ return Path::realpath(__DIR__.'/../Resources/bin/snoreToast/snoretoast-x86.exe');
+ }
+}
diff --git a/src/Cli/Prime/Notifier/SnoreToastNotifier.php b/src/Cli/Prime/Notifier/SnoreToastNotifier.php
deleted file mode 100644
index b7f2707a..00000000
--- a/src/Cli/Prime/Notifier/SnoreToastNotifier.php
+++ /dev/null
@@ -1,46 +0,0 @@
-getProgram());
-
- $cmd
- ->addOption('-m', $envelope->getMessage())
- ->addOption('-t', $this->getTitle($envelope))
- ->addOption('-p', $this->getIcon($envelope));
-
- $cmd->run();
- }
-
- public function isSupported()
- {
- if (!$this->getProgram() || !$this->isEnabled()) {
- return false;
- }
-
- return OS::isWindowsEightOrHigher() || OS::isWindowsSubsystemForLinux();
- }
-
- public function configureOptions(array $options)
- {
- $default = array(
- 'binary' => 'snoretoast',
- 'binary_paths' => array(
- Path::realpath(__DIR__.'/../Resources/bin/snoreToast/snoretoast-x86.exe'),
- ),
- );
-
- $options = array_replace_recursive($default, $options);
-
- parent::configureOptions($options);
- }
-}
diff --git a/src/Cli/Prime/Notifier/TerminalNotifierBaseNotifier.php b/src/Cli/Prime/Notifier/TerminalNotifierBaseNotifier.php
new file mode 100644
index 00000000..93224eca
--- /dev/null
+++ b/src/Cli/Prime/Notifier/TerminalNotifierBaseNotifier.php
@@ -0,0 +1,57 @@
+
+ */
+
+namespace Flasher\Cli\Prime\Notifier;
+
+use Flasher\Cli\Prime\Notification;
+use Flasher\Cli\Prime\System\Command;
+use Flasher\Cli\Prime\System\OS;
+
+final class TerminalNotifierBaseNotifier extends BaseNotifier
+{
+ /**
+ * {@inheritdoc}
+ */
+ public function send($notification)
+ {
+ $notification = Notification::wrap($notification);
+
+ $cmd = new Command($this->getProgram());
+
+ $cmd
+ ->addOption('-message', $notification->getMessage())
+ ->addOption('-title', $notification->getTitle());
+
+ if (version_compare(OS::getMacOSVersion(), '10.9.0', '>=')) {
+ $cmd->addOption('-appIcon', $notification->getIcon());
+ }
+
+ /** @var string|null $url */
+ $url = $notification->getOption('url');
+ if ($url) {
+ $cmd->addOption('-open', $url);
+ }
+
+ $cmd->run();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function isSupported()
+ {
+ return OS::isMacOS() && $this->getProgram();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getBinary()
+ {
+ return 'terminal-notifier';
+ }
+}
diff --git a/src/Cli/Prime/Notifier/TerminalNotifierNotifier.php b/src/Cli/Prime/Notifier/TerminalNotifierNotifier.php
deleted file mode 100644
index 3b7d0327..00000000
--- a/src/Cli/Prime/Notifier/TerminalNotifierNotifier.php
+++ /dev/null
@@ -1,46 +0,0 @@
-getProgram());
-
- $cmd
- ->addOption('-message', $envelope->getMessage())
- ->addOption('-title', $this->getTitle($envelope));
-
- if (version_compare(OS::getMacOSVersion(), '10.9.0', '>=')) {
- $cmd->addOption('-appIcon', $this->getIcon($envelope));
- }
-
- $url = $envelope->getOption('url');
- if ($url) {
- $cmd->addOption('-open', $url);
- }
-
- $cmd->run();
- }
-
- public function isSupported()
- {
- return $this->isEnabled() && OS::isMacOS() && $this->getProgram();
- }
-
- public function configureOptions(array $options)
- {
- $default = array(
- 'binary' => 'terminal-notifier',
- );
-
- $options = array_replace_recursive($default, $options);
-
- parent::configureOptions($options);
- }
-}
diff --git a/src/Cli/Prime/Notifier/ToasterBaseNotifier.php b/src/Cli/Prime/Notifier/ToasterBaseNotifier.php
new file mode 100644
index 00000000..f9f6f2c8
--- /dev/null
+++ b/src/Cli/Prime/Notifier/ToasterBaseNotifier.php
@@ -0,0 +1,62 @@
+
+ */
+
+namespace Flasher\Cli\Prime\Notifier;
+
+use Flasher\Cli\Prime\Notification;
+use Flasher\Cli\Prime\System\Command;
+use Flasher\Cli\Prime\System\OS;
+use Flasher\Cli\Prime\System\Path;
+
+final class ToasterBaseNotifier extends BaseNotifier
+{
+ /**
+ * {@inheritdoc}
+ */
+ public function send($notification)
+ {
+ $notification = Notification::wrap($notification);
+
+ $cmd = new Command($this->getProgram());
+
+ $cmd
+ ->addOption('-t', $notification->getTitle())
+ ->addOption('-m', $notification->getMessage())
+ ->addOption('-p', $notification->getIcon())
+ ->addArgument('-w');
+
+ $cmd->run();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function isSupported()
+ {
+ if (!$this->getProgram()) {
+ return false;
+ }
+
+ return OS::isWindowsEightOrHigher() || OS::isWindowsSubsystemForLinux();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getBinary()
+ {
+ return 'toast';
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getBinaryPaths()
+ {
+ return Path::realpath(__DIR__.'/../Resources/bin/toaster/toast.exe');
+ }
+}
diff --git a/src/Cli/Prime/Notifier/ToasterNotifier.php b/src/Cli/Prime/Notifier/ToasterNotifier.php
deleted file mode 100644
index c40a53be..00000000
--- a/src/Cli/Prime/Notifier/ToasterNotifier.php
+++ /dev/null
@@ -1,47 +0,0 @@
-getProgram());
-
- $cmd
- ->addOption('-t', $this->getTitle($envelope))
- ->addOption('-m', $envelope->getMessage())
- ->addOption('-p', $this->getIcon($envelope))
- ->addArgument('-w');;
-
- $cmd->run();
- }
-
- public function isSupported()
- {
- if (!$this->getProgram() || !$this->isEnabled()) {
- return false;
- }
-
- return OS::isWindowsEightOrHigher() || OS::isWindowsSubsystemForLinux();
- }
-
- public function configureOptions(array $options)
- {
- $default = array(
- 'binary' => 'toast',
- 'binary_paths' => array(
- Path::realpath(__DIR__.'/../Resources/bin/toaster/toast.exe'),
- ),
- );
-
- $options = array_replace_recursive($default, $options);
-
- parent::configureOptions($options);
- }
-}
diff --git a/src/Cli/Prime/Notifier/ZenityBaseNotifier.php b/src/Cli/Prime/Notifier/ZenityBaseNotifier.php
new file mode 100644
index 00000000..ca0f2de1
--- /dev/null
+++ b/src/Cli/Prime/Notifier/ZenityBaseNotifier.php
@@ -0,0 +1,48 @@
+
+ */
+
+namespace Flasher\Cli\Prime\Notifier;
+
+use Flasher\Cli\Prime\Notification;
+use Flasher\Cli\Prime\System\Command;
+use Flasher\Cli\Prime\System\OS;
+
+final class ZenityBaseNotifier extends BaseNotifier
+{
+ /**
+ * {@inheritdoc}
+ */
+ public function send($notification)
+ {
+ $notification = Notification::wrap($notification);
+
+ $cmd = new Command($this->getProgram());
+
+ $cmd
+ ->addArgument('--notification')
+ ->addOption('--text', $notification->getTitle().'\n\n'.$notification->getMessage())
+ ->addOption('--window-icon', $notification->getIcon());
+
+ $cmd->run();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function isSupported()
+ {
+ return OS::isUnix() && $this->getProgram();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getBinary()
+ {
+ return 'zenity';
+ }
+}
diff --git a/src/Cli/Prime/Notifier/ZenityNotifier.php b/src/Cli/Prime/Notifier/ZenityNotifier.php
deleted file mode 100644
index c9289849..00000000
--- a/src/Cli/Prime/Notifier/ZenityNotifier.php
+++ /dev/null
@@ -1,40 +0,0 @@
-getProgram());
-
- $cmd
- ->addArgument('--notification')
- ->addOption('--text', $this->getTitle($envelope).'\n\n'.$envelope->getMessage())
- ->addOption('--window-icon', $this->getIcon($envelope));
-
- $cmd->run();
- }
-
- public function isSupported()
- {
- return $this->isEnabled() && OS::isUnix() && $this->getProgram();
- }
-
- public function configureOptions(array $options)
- {
- $default = array(
- 'binary' => 'zenity',
- 'expire_time' => 0,
- 'priority' => 1,
- );
-
- $options = array_replace_recursive($default, $options);
-
- parent::configureOptions($options);
- }
-}
diff --git a/src/Cli/Prime/Notify.php b/src/Cli/Prime/Notify.php
new file mode 100644
index 00000000..b4047b9f
--- /dev/null
+++ b/src/Cli/Prime/Notify.php
@@ -0,0 +1,231 @@
+
+ */
+
+namespace Flasher\Cli\Prime;
+
+use Flasher\Cli\Prime\Notifier\BaseNotifier;
+use Flasher\Cli\Prime\System\Path;
+use Flasher\Prime\Notification\NotificationInterface;
+
+final class Notify extends BaseNotifier
+{
+ /**
+ * @var NotifyInterface|null
+ */
+ private $notifier;
+
+ /**
+ * @var NotifyInterface[]
+ */
+ private $notifiers = array();
+
+ /**
+ * @var NotifyInterface[]
+ */
+ private $sorted = array();
+
+ /**
+ * @var bool|null
+ */
+ private $isSupported;
+
+ /**
+ * @var string|null
+ */
+ private $title;
+
+ /**
+ * @var array{success?: string, error?: string, info?: string, warning?: string}
+ */
+ private $icons = array();
+
+ /**
+ * @param string|null $title
+ * @param array{success?: string, error?: string, info?: string, warning?: string}|string $icons
+ */
+ public function __construct($title = 'PHP Flasher', $icons = array())
+ {
+ $this->title = $title;
+ $this->icons = $this->configureIcons($icons);
+
+ $this->addNotifier(new Notifier\NotifySendBaseNotifier());
+ $this->addNotifier(new Notifier\AppleScriptBaseNotifier());
+ $this->addNotifier(new Notifier\GrowlNotifyBaseNotifier());
+ $this->addNotifier(new Notifier\KDialogBaseNotifier());
+ $this->addNotifier(new Notifier\NotifuBaseNotifier());
+ $this->addNotifier(new Notifier\SnoreToastBaseNotifier());
+ $this->addNotifier(new Notifier\TerminalNotifierBaseNotifier());
+ $this->addNotifier(new Notifier\ToasterBaseNotifier());
+ $this->addNotifier(new Notifier\ZenityBaseNotifier());
+ }
+
+ /**
+ * @param string|null $title
+ * @param array{success?: string, error?: string, info?: string, warning?: string}|string $icons
+ *
+ * @return static
+ */
+ public static function create($title = null, $icons = array())
+ {
+ return new self($title, $icons);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function send($notification)
+ {
+ $notification = $this->configureNotification($notification);
+
+ $notifier = $this->createNotifier();
+ $notifier->send($notification);
+ }
+
+ /**
+ * @return void
+ */
+ public function addNotifier(NotifyInterface $notifier)
+ {
+ $this->notifiers[] = $notifier;
+ $this->reset();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getPriority()
+ {
+ return 0;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function isSupported()
+ {
+ if (null !== $this->isSupported) {
+ return $this->isSupported;
+ }
+
+ if ($this->notifier instanceof NotifyInterface) {
+ return true;
+ }
+
+ foreach ($this->getNotifiers() as $notifier) {
+ if ($notifier->isSupported()) {
+ return $this->isSupported = true;
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * @return void
+ */
+ private function reset()
+ {
+ $this->notifier = null;
+ $this->sorted = array();
+ $this->isSupported = null;
+ }
+
+ /**
+ * @return NotifyInterface[]
+ */
+ private function getNotifiers()
+ {
+ if (array() !== $this->sorted) {
+ return $this->sorted;
+ }
+
+ $this->sorted = $this->notifiers;
+
+ usort($this->sorted, static function (NotifyInterface $a, NotifyInterface $b) {
+ $priorityA = $a->getPriority();
+ $priorityB = $b->getPriority();
+
+ if ($priorityA === $priorityB) {
+ return 0;
+ }
+
+ return $priorityA < $priorityB ? 1 : -1;
+ });
+
+ return $this->sorted;
+ }
+
+ /**
+ * @return NotifyInterface
+ */
+ private function createNotifier()
+ {
+ if ($this->notifier instanceof NotifyInterface) {
+ return $this->notifier;
+ }
+
+ foreach ($this->getNotifiers() as $notifier) {
+ if ($notifier->isSupported()) {
+ return $this->notifier = $notifier;
+ }
+ }
+
+ return new Notifier\NullBaseNotifier();
+ }
+
+ /**
+ * @param array{success?: string, error?: string, info?: string, warning?: string}|string $icons
+ *
+ * @return array<'default'|'error'|'info'|'success'|'warning', string>
+ */
+ private function configureIcons($icons = array())
+ {
+ $icons = $icons ?: array();
+
+ if (!\is_array($icons)) {
+ $icons = array(
+ NotificationInterface::SUCCESS => $icons,
+ NotificationInterface::ERROR => $icons,
+ NotificationInterface::INFO => $icons,
+ NotificationInterface::WARNING => $icons,
+ 'default' => $icons,
+ );
+ }
+
+ return array_merge(array(
+ NotificationInterface::SUCCESS => Path::realpath(__DIR__.'/Resources/icons/success.png'),
+ NotificationInterface::ERROR => Path::realpath(__DIR__.'/Resources/icons/error.png'),
+ NotificationInterface::INFO => Path::realpath(__DIR__.'/Resources/icons/info.png'),
+ NotificationInterface::WARNING => Path::realpath(__DIR__.'/Resources/icons/warning.png'),
+ 'default' => Path::realpath(__DIR__.'/Resources/icons/info.png'),
+ ), $icons);
+ }
+
+ /**
+ * @param Notification|string $notification
+ *
+ * @return Notification
+ */
+ private function configureNotification($notification)
+ {
+ $notification = Notification::wrap($notification);
+
+ if (null === $notification->getTitle()) {
+ $notification->setTitle($this->title);
+ }
+
+ if (null === $notification->getIcon() && isset($this->icons[$notification->getType()])) {
+ $notification->setIcon($this->icons[$notification->getType()]); // @phpstan-ignore-line
+ }
+
+ if (null === $notification->getIcon()) {
+ $notification->setIcon($this->icons['default']); // @phpstan-ignore-line
+ }
+
+ return $notification;
+ }
+}
diff --git a/src/Cli/Prime/NotifyInterface.php b/src/Cli/Prime/NotifyInterface.php
new file mode 100644
index 00000000..994e0cbe
--- /dev/null
+++ b/src/Cli/Prime/NotifyInterface.php
@@ -0,0 +1,74 @@
+
+ */
+
+namespace Flasher\Cli\Prime;
+
+interface NotifyInterface
+{
+ /**
+ * @param Notification|string $notification
+ *
+ * @return void
+ */
+ public function send($notification);
+
+ /**
+ * @return int
+ */
+ public function getPriority();
+
+ /**
+ * @return bool
+ */
+ public function isSupported();
+
+ /**
+ * @param string $type
+ * @param string $message
+ * @param string|null $title
+ * @param array $options
+ *
+ * @return void
+ */
+ public function type($type, $message, $title = null, $options = array());
+
+ /**
+ * @param string $message
+ * @param string|null $title
+ * @param array $options
+ *
+ * @return void
+ */
+ public function warning($message, $title = null, $options = array());
+
+ /**
+ * @param string $message
+ * @param string|null $title
+ * @param array $options
+ *
+ * @return void
+ */
+ public function info($message, $title = null, $options = array());
+
+ /**
+ * @param string $message
+ * @param string|null $title
+ * @param array $options
+ *
+ * @return void
+ */
+ public function error($message, $title = null, $options = array());
+
+ /**
+ * @param string $message
+ * @param string|null $title
+ * @param array $options
+ *
+ * @return void
+ */
+ public function success($message, $title = null, $options = array());
+}
diff --git a/src/Cli/Prime/Presenter/CliPresenter.php b/src/Cli/Prime/Presenter/CliPresenter.php
index f8e22097..5e064d59 100644
--- a/src/Cli/Prime/Presenter/CliPresenter.php
+++ b/src/Cli/Prime/Presenter/CliPresenter.php
@@ -1,73 +1,44 @@
+ */
+
namespace Flasher\Cli\Prime\Presenter;
-use Flasher\Cli\Prime\Notifier\NotifierInterface;
-use Flasher\Cli\Prime\Notifier\NullNotifier;
+use Flasher\Cli\Prime\Notification;
+use Flasher\Cli\Prime\Notify;
+use Flasher\Cli\Prime\NotifyInterface;
use Flasher\Prime\Response\Presenter\PresenterInterface;
use Flasher\Prime\Response\Response;
final class CliPresenter implements PresenterInterface
{
- /**
- * @var NotifierInterface[]
- */
- private $notifiers = array();
+ const NAME = 'cli';
/**
- * @var NotifierInterface[]
+ * @var NotifyInterface
*/
- private $sorted = array();
+ private $notifier;
+ public function __construct(NotifyInterface $notifier = null)
+ {
+ $this->notifier = $notifier ?: new Notify();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
public function render(Response $response)
{
- if (0 === count($response->getEnvelopes())) {
+ if ('cli' !== \PHP_SAPI || array() === $response->getEnvelopes()) {
return;
}
- $notifier = $this->createNotifier();
-
- $notifier->render($response->getEnvelopes());
- }
-
- public function addNotifier(NotifierInterface $notifier)
- {
- $this->notifiers[] = $notifier;
- }
-
- public function getSortedNotifiers()
- {
- if (0 !== count($this->sorted)) {
- return $this->sorted;
+ foreach ($response->getEnvelopes() as $envelope) {
+ $notification = Notification::fromEnvelope($envelope);
+ $this->notifier->send($notification);
}
-
- $this->sorted = $this->notifiers;
-
- usort($this->sorted, static function (NotifierInterface $a, NotifierInterface $b) {
- $priorityA = $a->getPriority();
- $priorityB = $b->getPriority();
-
- if ($priorityA == $priorityB) {
- return 0;
- }
-
- return $priorityA < $priorityB ? 1 : -1;
- });
-
- return $this->sorted;
- }
-
- /**
- * @return NotifierInterface
- */
- private function createNotifier()
- {
- foreach ($this->getSortedNotifiers() as $notifier) {
- if ($notifier->isSupported()) {
- return $notifier;
- }
- }
-
- return new NullNotifier();
}
}
diff --git a/src/Cli/Prime/README.md b/src/Cli/Prime/README.md
index eacd0f2a..70048b42 100644
--- a/src/Cli/Prime/README.md
+++ b/src/Cli/Prime/README.md
@@ -24,17 +24,11 @@
-
-
-
-
-
-
# Why use PHP Flasher ?
-The PHP Flasher project supports many notification libraries : __tailwindcss__, __bootstrap__, __cli.js__, __sweet alert 2__, __pnotify__, __noty__, and __notyf__
+The PHP Flasher project supports many notification libraries : __tailwindcss__, __bootstrap__, __toastr.js__, __sweet alert 2__, __pnotify__, __noty__, and __notyf__
and its highly extendable so you can add your custom notifications.
This library is designed, so you can take full control when creating you notifications :
@@ -53,21 +47,7 @@ This library is designed, so you can take full control when creating you notific
## Official Documentation
-Documentation for PHP Flasher can be found on the [PHP Flasher website](https://php-flasher.github.io/).
-
-## Backers && Sponsors
-
-Support this project by becoming a sponsor. Your name will show up in the Contribute page of all PHP Flasher installations as well as here with a link to your website!
-
-Thank you to all our backers and sponsors! 🙏
-
-
-
-
-
-
-
-
+Documentation for PHP Flasher can be found on the [PHP Flasher website](https://php-flasher.io).
### Contact
diff --git a/src/Cli/Prime/Resources/bin/notifu/notifu.exe b/src/Cli/Prime/Resources/bin/notifu/notifu.exe
index 33938d73..e69de29b 100644
Binary files a/src/Cli/Prime/Resources/bin/notifu/notifu.exe and b/src/Cli/Prime/Resources/bin/notifu/notifu.exe differ
diff --git a/src/Cli/Prime/Resources/bin/snoreToast/snoretoast-x86.exe b/src/Cli/Prime/Resources/bin/snoreToast/snoretoast-x86.exe
index 908afb95..e69de29b 100644
Binary files a/src/Cli/Prime/Resources/bin/snoreToast/snoretoast-x86.exe and b/src/Cli/Prime/Resources/bin/snoreToast/snoretoast-x86.exe differ
diff --git a/src/Cli/Prime/Resources/bin/toaster/Microsoft.WindowsAPICodePack.Shell.dll b/src/Cli/Prime/Resources/bin/toaster/Microsoft.WindowsAPICodePack.Shell.dll
index 4542663e..e69de29b 100644
Binary files a/src/Cli/Prime/Resources/bin/toaster/Microsoft.WindowsAPICodePack.Shell.dll and b/src/Cli/Prime/Resources/bin/toaster/Microsoft.WindowsAPICodePack.Shell.dll differ
diff --git a/src/Cli/Prime/Resources/bin/toaster/Microsoft.WindowsAPICodePack.dll b/src/Cli/Prime/Resources/bin/toaster/Microsoft.WindowsAPICodePack.dll
index ac869492..e69de29b 100644
Binary files a/src/Cli/Prime/Resources/bin/toaster/Microsoft.WindowsAPICodePack.dll and b/src/Cli/Prime/Resources/bin/toaster/Microsoft.WindowsAPICodePack.dll differ
diff --git a/src/Cli/Prime/Resources/bin/toaster/toast.exe b/src/Cli/Prime/Resources/bin/toaster/toast.exe
index 64af9c80..e69de29b 100644
Binary files a/src/Cli/Prime/Resources/bin/toaster/toast.exe and b/src/Cli/Prime/Resources/bin/toaster/toast.exe differ
diff --git a/src/Cli/Prime/Resources/sounds/error.wav b/src/Cli/Prime/Resources/sounds/error.wav
deleted file mode 100644
index c5a6e625..00000000
Binary files a/src/Cli/Prime/Resources/sounds/error.wav and /dev/null differ
diff --git a/src/Cli/Prime/Resources/sounds/info.wav b/src/Cli/Prime/Resources/sounds/info.wav
deleted file mode 100644
index 3a48e6b3..00000000
Binary files a/src/Cli/Prime/Resources/sounds/info.wav and /dev/null differ
diff --git a/src/Cli/Prime/Resources/sounds/success.wav b/src/Cli/Prime/Resources/sounds/success.wav
deleted file mode 100644
index 4d319d2d..00000000
Binary files a/src/Cli/Prime/Resources/sounds/success.wav and /dev/null differ
diff --git a/src/Cli/Prime/Resources/sounds/warning.wav b/src/Cli/Prime/Resources/sounds/warning.wav
deleted file mode 100644
index 5684ce95..00000000
Binary files a/src/Cli/Prime/Resources/sounds/warning.wav and /dev/null differ
diff --git a/src/Cli/Prime/Stamp/DesktopStamp.php b/src/Cli/Prime/Stamp/DesktopStamp.php
deleted file mode 100644
index 11a40bbe..00000000
--- a/src/Cli/Prime/Stamp/DesktopStamp.php
+++ /dev/null
@@ -1,24 +0,0 @@
-renderImmediately = $renderImmediately;
- }
-
- /**
- * @return bool
- */
- public function isRenderImmediately()
- {
- return $this->renderImmediately;
- }
-}
diff --git a/src/Cli/Prime/System/Command.php b/src/Cli/Prime/System/Command.php
index 0bb32253..8fe7e472 100644
--- a/src/Cli/Prime/System/Command.php
+++ b/src/Cli/Prime/System/Command.php
@@ -1,38 +1,71 @@
+ */
+
namespace Flasher\Cli\Prime\System;
-class Command
+final class Command
{
+ /**
+ * @var string|null
+ */
private $command;
+
+ /**
+ * @var array
+ */
private $options = array();
+
+ /**
+ * @var array
+ */
private $arguments = array();
+ /**
+ * @param string|null $command
+ */
public function __construct($command)
{
- $this->command = escapeshellcmd($command);
+ $this->command = null !== $command ? escapeshellcmd((string) $command) : null;
}
+ /**
+ * @param string $name
+ * @param int|string|null $value
+ *
+ * @return static
+ */
public function addOption($name, $value = null)
{
- $this->options[$name] = escapeshellarg($value);
+ $this->options[$name] = null !== $value ? escapeshellarg((string) $value) : null;
return $this;
}
+ /**
+ * @param int|string|null $argument
+ *
+ * @return static
+ */
public function addArgument($argument)
{
- $this->arguments[] = escapeshellarg($argument);
+ $this->arguments[] = null !== $argument ? escapeshellarg((string) $argument) : $argument;
return $this;
}
+ /**
+ * @return void
+ */
public function run()
{
$command = $this->command.' '.$this->formatOptions().' '.$this->formatArguments();
if (OS::isWindows()) {
- pclose(popen("start /B ".$command, "r"));
+ pclose(popen('start /B '.$command, 'r')); // @phpstan-ignore-line
return;
}
@@ -40,11 +73,17 @@ class Command
exec($command);
}
+ /**
+ * @return string
+ */
private function formatArguments()
{
return implode(' ', $this->arguments);
}
+ /**
+ * @return string
+ */
private function formatOptions()
{
$line = '';
diff --git a/src/Cli/Prime/System/OS.php b/src/Cli/Prime/System/OS.php
index c83f33c4..b200d2e0 100644
--- a/src/Cli/Prime/System/OS.php
+++ b/src/Cli/Prime/System/OS.php
@@ -1,56 +1,88 @@
+ */
+
namespace Flasher\Cli\Prime\System;
-class OS
+final class OS
{
+ /**
+ * @return string
+ */
public static function getName()
{
return php_uname('s');
}
+ /**
+ * @return string
+ */
public static function getRelease()
{
return php_uname('r');
}
+ /**
+ * @return bool
+ */
public static function isUnix()
{
- return in_array(self::getName(), array(
+ return \in_array(self::getName(), array(
'Linux',
'FreeBSD',
'NetBSD',
'OpenBSD',
'SunOS',
'DragonFly',
- ));
+ ), true);
}
+ /**
+ * @return bool
+ */
public static function isWindows()
{
return 'WIN' === strtoupper(substr(self::getName(), 0, 3));
}
+ /**
+ * @return bool
+ */
public static function isWindowsSeven()
{
return self::isWindows() && '6.1' === self::getRelease();
}
+ /**
+ * @return bool
+ */
public static function isWindowsEightOrHigher()
{
return self::isWindows() && version_compare(self::getRelease(), '6.2', '>=');
}
+ /**
+ * @return bool
+ */
public static function isWindowsSubsystemForLinux()
{
return self::isUnix() && false !== mb_strpos(strtolower(self::getName()), 'microsoft');
}
+ /**
+ * @return bool
+ */
public static function isMacOS()
{
return false !== strpos(self::getName(), 'Darwin');
}
+ /**
+ * @return string
+ */
public static function getMacOSVersion()
{
exec('sw_vers -productVersion', $output);
diff --git a/src/Cli/Prime/System/Path.php b/src/Cli/Prime/System/Path.php
index 77eb4ca7..ca1c5db4 100644
--- a/src/Cli/Prime/System/Path.php
+++ b/src/Cli/Prime/System/Path.php
@@ -1,11 +1,21 @@
+ */
+
namespace Flasher\Cli\Prime\System;
-class Path
+final class Path
{
+ /**
+ * @param string $path
+ *
+ * @return string
+ */
public static function realpath($path)
{
- return realpath(str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $path));
+ return (string) realpath(str_replace(array('/', '\\'), \DIRECTORY_SEPARATOR, $path));
}
}
diff --git a/src/Cli/Prime/System/Program.php b/src/Cli/Prime/System/Program.php
index 311e0f65..4bf58011 100644
--- a/src/Cli/Prime/System/Program.php
+++ b/src/Cli/Prime/System/Program.php
@@ -1,19 +1,33 @@
-null");
-
- return !empty($output);
- }
-
- $output = shell_exec("command -v $program");
-
- return !empty($output);
- }
-}
+
+ */
+
+namespace Flasher\Cli\Prime\System;
+
+final class Program
+{
+ /**
+ * @param string|null $program
+ *
+ * @return bool
+ */
+ public static function exist($program)
+ {
+ if (null === $program) {
+ return false;
+ }
+
+ if (OS::isWindows()) {
+ $output = shell_exec("where {$program} 2>null");
+
+ return !empty($output);
+ }
+
+ $output = shell_exec("command -v {$program}");
+
+ return !empty($output);
+ }
+}
diff --git a/src/Cli/Prime/UPGRADING.md b/src/Cli/Prime/UPGRADING.md
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/Cli/Prime/composer.json b/src/Cli/Prime/composer.json
index 94c0f94c..01e1967a 100644
--- a/src/Cli/Prime/composer.json
+++ b/src/Cli/Prime/composer.json
@@ -2,26 +2,13 @@
"name": "php-flasher/flasher-cli",
"description": "PHP Flasher adapter for Cli Console Terminal",
"type": "library",
- "keywords": [
- "notify",
- "php",
- "laravel",
- "symfony",
- "Lumen",
- "notifications",
- "messages",
- "alerts",
- "pnotify",
- "console",
- "Cli",
- "Terminal"
- ],
- "homepage": "https://php-flasher.github.io/",
+ "keywords": ["notify", "php", "laravel", "symfony", "Lumen", "notifications", "messages", "alerts", "pnotify", "console", "Cli", "Terminal"],
+ "homepage": "https://php-flasher.io",
"authors": [
{
- "name": "Younes Khoubza",
+ "name": "Younes KHOUBZA",
"email": "younes.khoubza@gmail.com",
- "homepage": "https://github.com/yoeunes",
+ "homepage": "https://www.linkedin.com/in/younes-khoubza",
"role": "Developer"
}
],
@@ -29,7 +16,7 @@
"require": {
"php": ">=5.3",
"ext-mbstring": "*",
- "php-flasher/flasher": "^0.9"
+ "php-flasher/flasher": "^1.0"
},
"autoload": {
"psr-4": {
@@ -39,6 +26,6 @@
"config": {
"sort-packages": true
},
- "minimum-stability": "dev",
+ "minimum-stability": "stable",
"prefer-stable": true
}
diff --git a/src/Cli/Symfony/.editorconfig b/src/Cli/Symfony/.editorconfig
deleted file mode 100644
index cd8eb86e..00000000
--- a/src/Cli/Symfony/.editorconfig
+++ /dev/null
@@ -1,15 +0,0 @@
-; This file is for unifying the coding style for different editors and IDEs.
-; More information at http://editorconfig.org
-
-root = true
-
-[*]
-charset = utf-8
-indent_size = 4
-indent_style = space
-end_of_line = lf
-insert_final_newline = true
-trim_trailing_whitespace = true
-
-[*.md]
-trim_trailing_whitespace = false
diff --git a/src/Cli/Symfony/.gitattributes b/src/Cli/Symfony/.gitattributes
deleted file mode 100644
index 3383d44b..00000000
--- a/src/Cli/Symfony/.gitattributes
+++ /dev/null
@@ -1,13 +0,0 @@
-
-# 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/Cli/Symfony/.github/CONTRIBUTING.md b/src/Cli/Symfony/.github/CONTRIBUTING.md
deleted file mode 100644
index b4ae1c4a..00000000
--- a/src/Cli/Symfony/.github/CONTRIBUTING.md
+++ /dev/null
@@ -1,55 +0,0 @@
-# Contributing
-
-Contributions are **welcome** and will be fully **credited**.
-
-Please read and understand the contribution guide before creating an issue or pull request.
-
-## Etiquette
-
-This project is open source, and as such, the maintainers give their free time to build and maintain the source code
-held within. They make the code freely available in the hope that it will be of use to other developers. It would be
-extremely unfair for them to suffer abuse or anger for their hard work.
-
-Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the
-world that developers are civilized and selfless people.
-
-It's the duty of the maintainer to ensure that all submissions to the project are of sufficient
-quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used.
-
-## Viability
-
-When requesting or submitting new features, first consider whether it might be useful to others. Open
-source projects are used by many developers, who may have entirely different needs to your own. Think about
-whether or not your feature is likely to be used by other users of the project.
-
-## Procedure
-
-Before filing an issue:
-
-- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident.
-- Check to make sure your feature suggestion isn't already present within the project.
-- Check the pull requests tab to ensure that the bug doesn't have a fix in progress.
-- Check the pull requests tab to ensure that the feature isn't already in progress.
-
-Before submitting a pull request:
-
-- Check the codebase to ensure that your feature doesn't already exist.
-- Check the pull requests to ensure that another person hasn't already submitted the feature or fix.
-
-## Requirements
-
-If the project maintainer has any additional requirements, you will find them listed here.
-
-- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](https://pear.php.net/package/PHP_CodeSniffer).
-
-- **Add tests!** - Your patch won't be accepted if it doesn't have tests.
-
-- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.
-
-- **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option.
-
-- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
-
-- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.
-
-**Happy coding**!
diff --git a/src/Cli/Symfony/.github/FUNDING.yml b/src/Cli/Symfony/.github/FUNDING.yml
index 5e454f27..7de85ae3 100644
--- a/src/Cli/Symfony/.github/FUNDING.yml
+++ b/src/Cli/Symfony/.github/FUNDING.yml
@@ -1,5 +1,3 @@
-# These are supported funding model platforms
-
patreon: yoeunes
ko_fi: yoeunes
open_collective: php-flasher
diff --git a/src/Cli/Symfony/.github/SECURITY.md b/src/Cli/Symfony/.github/SECURITY.md
deleted file mode 100644
index d9b55dde..00000000
--- a/src/Cli/Symfony/.github/SECURITY.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# Security Policy
-
-If you discover any security related issues, please email younes.khoubza@gmail.com instead of using the issue tracker.
diff --git a/src/Cli/Symfony/.github/dependabot.yml b/src/Cli/Symfony/.github/dependabot.yml
deleted file mode 100644
index c630ffa6..00000000
--- a/src/Cli/Symfony/.github/dependabot.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-version: 2
-updates:
-- package-ecosystem: composer
- directory: "/"
- schedule:
- interval: daily
- open-pull-requests-limit: 10
diff --git a/src/Cli/Symfony/.github/workflows/auto_closer.yaml b/src/Cli/Symfony/.github/workflows/auto_closer.yaml
new file mode 100644
index 00000000..f807ac59
--- /dev/null
+++ b/src/Cli/Symfony/.github/workflows/auto_closer.yaml
@@ -0,0 +1,22 @@
+name: Auto Closer PR
+
+on:
+ pull_request_target:
+ types: [opened]
+
+jobs:
+ run:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: superbrothers/close-pull-request@v3
+ with:
+ comment: |
+ Hi, thank you for your contribution.
+
+ Unfortunately, this repository is read-only. It's a split from our main monorepo repository.
+
+ We'd like to kindly ask you to move the contribution there - https://github.com/php-flasher/php-flasher.
+
+ We'll check it, review it and give you feed back right way.
+
+ Thank you.
diff --git a/src/Cli/Symfony/.github/workflows/close-pull-request.yml b/src/Cli/Symfony/.github/workflows/close-pull-request.yml
deleted file mode 100644
index ed229fac..00000000
--- a/src/Cli/Symfony/.github/workflows/close-pull-request.yml
+++ /dev/null
@@ -1,13 +0,0 @@
-name: Close Pull Request
-
-on:
- pull_request_target:
- types: [opened]
-
-jobs:
- run:
- runs-on: ubuntu-latest
- steps:
- - uses: superbrothers/close-pull-request@v3
- with:
- comment: "Thank you for your pull request. However, you have submitted this PR on a read-only sub split of `php-flasher/php-flasher`. Please submit your PR on the https://github.com/php-flasher/php-flasher repository.
Thanks!"
diff --git a/src/Cli/Symfony/.gitignore b/src/Cli/Symfony/.gitignore
deleted file mode 100644
index 89d72688..00000000
--- a/src/Cli/Symfony/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-.idea
-vendor
-composer.lock
-.phpunit.result.cache
-.phpcs-cache
diff --git a/src/Cli/Symfony/.phpstorm.meta.php b/src/Cli/Symfony/.phpstorm.meta.php
deleted file mode 100644
index 55dcbfa4..00000000
--- a/src/Cli/Symfony/.phpstorm.meta.php
+++ /dev/null
@@ -1,3 +0,0 @@
-
+ */
+
namespace Flasher\Cli\Symfony\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
@@ -8,16 +13,19 @@ use Symfony\Component\DependencyInjection\Reference;
final class NotifierCompilerPass implements CompilerPassInterface
{
+ /**
+ * @return void
+ */
public function process(ContainerBuilder $container)
{
- if (!$container->has('flasher.presenter.cli')) {
+ if (!$container->has('flasher.cli_notifier')) {
return;
}
- $presenter = $container->findDefinition('flasher.presenter.cli');
+ $notifier = $container->findDefinition('flasher.cli_notifier');
foreach ($container->findTaggedServiceIds('flasher.cli_notifier') as $id => $tags) {
- $presenter->addMethodCall('addNotifier', array(new Reference($id)));
+ $notifier->addMethodCall('addNotifier', array(new Reference($id)));
}
}
}
diff --git a/src/Cli/Symfony/DependencyInjection/Configuration.php b/src/Cli/Symfony/DependencyInjection/Configuration.php
index bf6d948f..0d428321 100644
--- a/src/Cli/Symfony/DependencyInjection/Configuration.php
+++ b/src/Cli/Symfony/DependencyInjection/Configuration.php
@@ -1,8 +1,12 @@
+ */
+
namespace Flasher\Cli\Symfony\DependencyInjection;
-use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
@@ -14,450 +18,25 @@ final class Configuration implements ConfigurationInterface
public function getConfigTreeBuilder()
{
$name = 'flasher_cli';
+
$treeBuilder = new TreeBuilder($name);
- $rootNode = $this->getRootNode($treeBuilder, $name);
+
+ $rootNode = method_exists($treeBuilder, 'getRootNode')
+ ? $treeBuilder->getRootNode()
+ : $treeBuilder->root($name); // @phpstan-ignore-line
$rootNode
->children()
- ->booleanNode('render_all')
- ->defaultValue(true)
- ->end()
- ->booleanNode('render_immediately')
- ->defaultValue(true)
- ->end()
->scalarNode('title')
->defaultValue('PHP Flasher')
->end()
- ->booleanNode('mute')
- ->defaultValue(true)
- ->end()
- ->arrayNode('filter_criteria')
- ->prototype('variable')->end()
- ->defaultValue(array())
- ->end()
->arrayNode('icons')
->prototype('variable')->end()
->defaultValue(array())
->end()
- ->arrayNode('sounds')
- ->prototype('variable')->end()
- ->defaultValue(array())
- ->end()
- ->append($this->addNotifiersConfig())
->end()
;
return $treeBuilder;
}
-
- private function addNotifiersConfig()
- {
- $name = 'notifiers';
- $rootNode = $this->getRootNode(new TreeBuilder($name), $name);
-
- $rootNode
- ->addDefaultsIfNotSet()
- ->fixXmlConfig('notifier')
- ->children()
- ->append($this->addGrowlNotifyNotifier())
- ->append($this->addKDialogNotifier())
- ->append($this->addNotifuNotifier())
- ->append($this->addNotifySendNotifier())
- ->append($this->addSnoreToastNotifier())
- ->append($this->addTerminalNotifierNotifier())
- ->append($this->addToasterNotifier())
- ->append($this->addZenityNotifier())
- ->append($this->addAppleScriptNotifier())
- ->end();
-
- return $rootNode;
- }
-
- /**
- * @return ArrayNodeDefinition
- */
- private function addGrowlNotifyNotifier()
- {
- $name = 'growl_notify';
- $rootNode = $this->getRootNode(new TreeBuilder($name), $name);
-
- $rootNode
- ->addDefaultsIfNotSet()
- ->children()
- ->booleanNode('enabled')->defaultValue(true)->end()
- ->scalarNode('priority')
- ->beforeNormalization()
- ->always(function ($v) { return (int) $v; })
- ->end()
- ->defaultValue(0)
- ->end()
- ->scalarNode('binary')->defaultValue('growlnotify')->end()
- ->arrayNode('binary_paths')
- ->beforeNormalization()
- ->ifString()
- ->then(function($v) { return array($v); })
- ->end()
- ->prototype('scalar')->end()
- ->end()
- ->scalarNode('title')->defaultValue(null)->end()
- ->booleanNode('mute')->defaultValue(true)->end()
- ->arrayNode('icons')
- ->prototype('variable')->end()
- ->defaultValue(array())
- ->end()
- ->arrayNode('sounds')
- ->prototype('scalar')->end()
- ->defaultValue(array())
- ->end()
- ->end()
- ;
-
- return $rootNode;
- }
-
- /**
- * @return ArrayNodeDefinition
- */
- private function addKDialogNotifier()
- {
- $name = 'kdialog_notifier';
- $rootNode = $this->getRootNode(new TreeBuilder($name), $name);
-
- $rootNode
- ->addDefaultsIfNotSet()
- ->children()
- ->booleanNode('enabled')->defaultValue(true)->end()
- ->scalarNode('priority')
- ->beforeNormalization()
- ->always(function ($v) { return (int) $v; })
- ->end()
- ->defaultValue(0)
- ->end()
- ->scalarNode('binary')->defaultValue('kdialog')->end()
- ->arrayNode('binary_paths')
- ->beforeNormalization()
- ->ifString()
- ->then(function($v) { return array($v); })
- ->end()
- ->prototype('scalar')->end()
- ->end()
- ->scalarNode('title')->defaultValue(null)->end()
- ->booleanNode('mute')->defaultValue(true)->end()
- ->arrayNode('icons')
- ->prototype('variable')->end()
- ->defaultValue(array())
- ->end()
- ->arrayNode('sounds')
- ->prototype('variable')->end()
- ->defaultValue(array())
- ->end()
- ->end()
- ;
-
- return $rootNode;
- }
-
- /**
- * @return ArrayNodeDefinition
- */
- private function addNotifuNotifier()
- {
- $name = 'notifu_notifier';
- $rootNode = $this->getRootNode(new TreeBuilder($name), $name);
-
- $rootNode
- ->addDefaultsIfNotSet()
- ->children()
- ->booleanNode('enabled')->defaultValue(true)->end()
- ->scalarNode('priority')
- ->beforeNormalization()
- ->always(function ($v) { return (int) $v; })
- ->end()
- ->defaultValue(0)
- ->end()
- ->scalarNode('binary')->defaultValue('notifu')->end()
- ->arrayNode('binary_paths')
- ->beforeNormalization()
- ->ifString()
- ->then(function($v) { return array($v); })
- ->end()
- ->prototype('scalar')->end()
- ->end()
- ->scalarNode('title')->defaultValue(null)->end()
- ->booleanNode('mute')->defaultValue(true)->end()
- ->arrayNode('icons')
- ->prototype('variable')->end()
- ->defaultValue(array())
- ->end()
- ->arrayNode('sounds')
- ->prototype('variable')->end()
- ->defaultValue(array())
- ->end()
- ->end()
- ;
-
- return $rootNode;
- }
-
- /**
- * @return ArrayNodeDefinition
- */
- private function addNotifySendNotifier()
- {
- $name = 'notify_send';
- $rootNode = $this->getRootNode(new TreeBuilder($name), $name);
-
- $rootNode
- ->addDefaultsIfNotSet()
- ->children()
- ->booleanNode('enabled')->defaultValue(true)->end()
- ->scalarNode('priority')
- ->beforeNormalization()
- ->always(function ($v) { return (int) $v; })
- ->end()
- ->defaultValue(2)
- ->end()
- ->scalarNode('binary')->defaultValue('notify-send')->end()
- ->arrayNode('binary_paths')
- ->beforeNormalization()
- ->ifString()
- ->then(function($v) { return array($v); })
- ->end()
- ->prototype('scalar')->end()
- ->end()
- ->scalarNode('title')->defaultValue(null)->end()
- ->booleanNode('mute')->defaultValue(true)->end()
- ->arrayNode('icons')
- ->prototype('variable')->end()
- ->defaultValue(array())
- ->end()
- ->arrayNode('sounds')
- ->prototype('variable')->end()
- ->defaultValue(array())
- ->end()
- ->end()
- ;
-
- return $rootNode;
- }
-
- /**
- * @return ArrayNodeDefinition
- */
- private function addSnoreToastNotifier()
- {
- $name = 'snore_toast_notifier';
- $rootNode = $this->getRootNode(new TreeBuilder($name), $name);
-
- $rootNode
- ->addDefaultsIfNotSet()
- ->children()
- ->booleanNode('enabled')->defaultValue(true)->end()
- ->scalarNode('priority')
- ->beforeNormalization()
- ->always(function ($v) { return (int) $v; })
- ->end()
- ->defaultValue(0)
- ->end()
- ->scalarNode('binary')->defaultValue('snoretoast')->end()
- ->arrayNode('binary_paths')
- ->beforeNormalization()
- ->ifString()
- ->then(function($v) { return array($v); })
- ->end()
- ->prototype('scalar')->end()
- ->end()
- ->scalarNode('title')->defaultValue(null)->end()
- ->booleanNode('mute')->defaultValue(true)->end()
- ->arrayNode('icons')
- ->prototype('variable')->end()
- ->defaultValue(array())
- ->end()
- ->arrayNode('sounds')
- ->prototype('variable')->end()
- ->defaultValue(array())
- ->end()
- ->end()
- ;
-
- return $rootNode;
- }
-
- /**
- * @return ArrayNodeDefinition
- */
- private function addTerminalNotifierNotifier()
- {
- $name = 'terminal_notifier_notifier';
- $rootNode = $this->getRootNode(new TreeBuilder($name), $name);
-
- $rootNode
- ->addDefaultsIfNotSet()
- ->children()
- ->booleanNode('enabled')->defaultValue(true)->end()
- ->scalarNode('priority')
- ->beforeNormalization()
- ->always(function ($v) { return (int) $v; })
- ->end()
- ->defaultValue(0)
- ->end()
- ->scalarNode('binary')->defaultValue('terminal-notifier')->end()
- ->arrayNode('binary_paths')
- ->beforeNormalization()
- ->ifString()
- ->then(function($v) { return array($v); })
- ->end()
- ->prototype('scalar')->end()
- ->end()
- ->scalarNode('title')->defaultValue(null)->end()
- ->booleanNode('mute')->defaultValue(true)->end()
- ->arrayNode('icons')
- ->prototype('variable')->end()
- ->defaultValue(array())
- ->end()
- ->arrayNode('sounds')
- ->prototype('variable')->end()
- ->defaultValue(array())
- ->end()
- ->end()
- ;
-
- return $rootNode;
- }
-
- /**
- * @return ArrayNodeDefinition
- */
- private function addToasterNotifier()
- {
- $name = 'toaster';
- $rootNode = $this->getRootNode(new TreeBuilder($name), $name);
-
- $rootNode
- ->addDefaultsIfNotSet()
- ->children()
- ->booleanNode('enabled')->defaultValue(true)->end()
- ->scalarNode('priority')
- ->beforeNormalization()
- ->always(function ($v) { return (int) $v; })
- ->end()
- ->defaultValue(0)
- ->end()
- ->scalarNode('binary')->defaultValue('toast')->end()
- ->arrayNode('binary_paths')
- ->beforeNormalization()
- ->ifString()
- ->then(function($v) { return array($v); })
- ->end()
- ->prototype('scalar')->end()
- ->end()
- ->scalarNode('title')->defaultValue(null)->end()
- ->booleanNode('mute')->defaultValue(true)->end()
- ->arrayNode('icons')
- ->prototype('variable')->end()
- ->defaultValue(array())
- ->end()
- ->arrayNode('sounds')
- ->prototype('variable')->end()
- ->defaultValue(array())
- ->end()
- ->end()
- ;
-
- return $rootNode;
- }
-
- /**
- * @return ArrayNodeDefinition
- */
- private function addZenityNotifier()
- {
- $name = 'zenity';
- $rootNode = $this->getRootNode(new TreeBuilder($name), $name);
-
- $rootNode
- ->addDefaultsIfNotSet()
- ->children()
- ->booleanNode('enabled')->defaultValue(true)->end()
- ->scalarNode('priority')
- ->beforeNormalization()
- ->always(function ($v) { return (int) $v; })
- ->end()
- ->defaultValue(1)
- ->end()
- ->scalarNode('binary')->defaultValue('zenity')->end()
- ->arrayNode('binary_paths')
- ->beforeNormalization()
- ->ifString()
- ->then(function($v) { return array($v); })
- ->end()
- ->prototype('scalar')->end()
- ->end()
- ->scalarNode('title')->defaultValue(null)->end()
- ->booleanNode('mute')->defaultValue(true)->end()
- ->arrayNode('icons')
- ->prototype('variable')->end()
- ->defaultValue(array())
- ->end()
- ->arrayNode('sounds')
- ->prototype('variable')->end()
- ->defaultValue(array())
- ->end()
- ->end()
- ;
-
- return $rootNode;
- }
-
- /**
- * @return ArrayNodeDefinition
- */
- private function addAppleScriptNotifier()
- {
- $name = 'apple_script';
- $rootNode = $this->getRootNode(new TreeBuilder($name), $name);
-
- $rootNode
- ->addDefaultsIfNotSet()
- ->children()
- ->booleanNode('enabled')->defaultValue(true)->end()
- ->scalarNode('priority')
- ->beforeNormalization()
- ->always(function ($v) { return (int) $v; })
- ->end()
- ->defaultValue(1)
- ->end()
- ->scalarNode('binary')->defaultValue('osascript')->end()
- ->arrayNode('binary_paths')
- ->beforeNormalization()
- ->ifString()
- ->then(function($v) { return array($v); })
- ->end()
- ->prototype('scalar')->end()
- ->end()
- ->scalarNode('title')->defaultValue(null)->end()
- ->booleanNode('mute')->defaultValue(true)->end()
- ->arrayNode('icons')
- ->prototype('variable')->end()
- ->defaultValue(array())
- ->end()
- ->arrayNode('sounds')
- ->prototype('variable')->end()
- ->defaultValue(array())
- ->end()
- ->end()
- ;
-
- return $rootNode;
- }
-
- private function getRootNode(TreeBuilder $treeBuilder, $name)
- {
- // BC layer for symfony/config 4.1 and older
- if (\method_exists($treeBuilder, 'getRootNode')) {
- return $treeBuilder->getRootNode();
- }
-
- return $treeBuilder->root($name);
- }
}
diff --git a/src/Cli/Symfony/DependencyInjection/FlasherCliExtension.php b/src/Cli/Symfony/DependencyInjection/FlasherCliExtension.php
index 5e819277..361a915d 100644
--- a/src/Cli/Symfony/DependencyInjection/FlasherCliExtension.php
+++ b/src/Cli/Symfony/DependencyInjection/FlasherCliExtension.php
@@ -1,5 +1,10 @@
+ */
+
namespace Flasher\Cli\Symfony\DependencyInjection;
use Symfony\Component\Config\FileLocator;
@@ -10,56 +15,29 @@ use Symfony\Component\HttpKernel\DependencyInjection\Extension;
final class FlasherCliExtension extends Extension
{
/**
- * @throws \Exception
+ * @param array> $configs
+ *
+ * @return void
*/
public function load(array $configs, ContainerBuilder $container)
{
- $configuration = new Configuration();
- $config = $this->processConfiguration($configuration, $configs);
+ $configs = $this->processConfiguration(new Configuration(), $configs);
- $loader = new Loader\PhpFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config'));
+ $loader = new Loader\PhpFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('services.php');
- $container
- ->findDefinition('flasher.event_listener.cli_stamps_listener')
- ->replaceArgument(0, $config['render_all'])
- ->replaceArgument(1, $config['render_immediately']);
-
- $container
- ->findDefinition('flasher.cli')
- ->replaceArgument(2, $config['filter_criteria']);
-
- $this->registerNotifiersConfiguration($container, $config);
+ $this->configureNotifier($configs, $container);
}
- private function registerNotifiersConfiguration(ContainerBuilder $container, array $config)
+ /**
+ * @param array> $configs
+ *
+ * @return void
+ */
+ private function configureNotifier(array $configs, ContainerBuilder $container)
{
- $this->registerNotifier($container, $config, 'growl_notify');
- $this->registerNotifier($container, $config, 'kdialog_notifier');
- $this->registerNotifier($container, $config, 'notifu_notifier');
- $this->registerNotifier($container, $config, 'notify_send');
- $this->registerNotifier($container, $config, 'snore_toast_notifier');
- $this->registerNotifier($container, $config, 'terminal_notifier_notifier');
- $this->registerNotifier($container, $config, 'toaster');
- $this->registerNotifier($container, $config, 'apple_script');
- }
-
- private function registerNotifier(ContainerBuilder $container, array $config, $notifier)
- {
- $container
- ->findDefinition("flasher.cli.$notifier")
- ->replaceArgument(0, $this->createConfigFor($config, $notifier));
- }
-
- private function createConfigFor(array $config, $notifier)
- {
- $options = $config['notifiers'][$notifier];
-
- $options['title'] = $config['title'];
- $options['mute'] = $config['mute'];
- $options['icons'] = array_replace_recursive($config['icons'], $options['icons']);
- $options['sounds'] = array_replace_recursive($config['sounds'], $options['sounds']);
-
- return $options;
+ $notifier = $container->getDefinition('flasher.notify');
+ $notifier->replaceArgument(0, $configs['title']); // @phpstan-ignore-line
+ $notifier->replaceArgument(1, $configs['icons']); // @phpstan-ignore-line
}
}
diff --git a/src/Cli/Symfony/FlasherCliSymfonyBundle.php b/src/Cli/Symfony/FlasherCliSymfonyBundle.php
index f37627f3..7ee4de2c 100644
--- a/src/Cli/Symfony/FlasherCliSymfonyBundle.php
+++ b/src/Cli/Symfony/FlasherCliSymfonyBundle.php
@@ -1,23 +1,19 @@
+ */
+
namespace Flasher\Cli\Symfony;
-use Flasher\Cli\Prime\Stamp\DesktopStamp;
use Flasher\Cli\Symfony\DependencyInjection\Compiler\NotifierCompilerPass;
-use Flasher\Prime\Notification\NotificationBuilder;
-use Flasher\Symfony\Bridge\FlasherBundle;
use Flasher\Cli\Symfony\DependencyInjection\FlasherCliExtension;
+use Flasher\Symfony\Bridge\FlasherBundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class FlasherCliSymfonyBundle extends FlasherBundle // Symfony\Component\HttpKernel\Bundle\Bundle
{
- public function boot()
- {
- NotificationBuilder::macro('desktop', function ($renderImmediately = true) {
- return $this->withStamp(new DesktopStamp($renderImmediately));
- });
- }
-
protected function flasherBuild(ContainerBuilder $container)
{
$container->addCompilerPass(new NotifierCompilerPass());
diff --git a/src/Cli/Symfony/README.md b/src/Cli/Symfony/README.md
index 5714d7d7..70048b42 100644
--- a/src/Cli/Symfony/README.md
+++ b/src/Cli/Symfony/README.md
@@ -24,12 +24,6 @@
-
-
-
-
-
-
# Why use PHP Flasher ?
@@ -53,21 +47,7 @@ This library is designed, so you can take full control when creating you notific
## Official Documentation
-Documentation for PHP Flasher can be found on the [PHP Flasher website](https://php-flasher.github.io/).
-
-## Backers && Sponsors
-
-Support this project by becoming a sponsor. Your name will show up in the Contribute page of all PHP Flasher installations as well as here with a link to your website!
-
-Thank you to all our backers and sponsors! 🙏
-
-
-
-
-
-
-
-
+Documentation for PHP Flasher can be found on the [PHP Flasher website](https://php-flasher.io).
### Contact
diff --git a/src/Cli/Symfony/Resources/config/services.php b/src/Cli/Symfony/Resources/config/services.php
index d82da21d..a7a34164 100644
--- a/src/Cli/Symfony/Resources/config/services.php
+++ b/src/Cli/Symfony/Resources/config/services.php
@@ -1,85 +1,47 @@
+ */
+
+use Flasher\Cli\Prime\Presenter\CliPresenter;
use Flasher\Symfony\Bridge\Bridge;
+use Symfony\Component\DependencyInjection\ChildDefinition;
+use Symfony\Component\DependencyInjection\DefinitionDecorator;
use Symfony\Component\DependencyInjection\Reference;
-if (class_exists('Symfony\Component\DependencyInjection\ChildDefinition')) {
- $definition = new ChildDefinition('flasher.notification_factory');
-} else {
- $definition = new DefinitionDecorator('flasher.notification_factory');
+if (!isset($container)) {
+ return;
}
+/** @var ChildDefinition $definition */
+$definition = class_exists('Symfony\Component\DependencyInjection\ChildDefinition')
+ ? new ChildDefinition('flasher.notification_factory')
+ : new DefinitionDecorator('flasher.notification_factory'); // @phpstan-ignore-line
+
$definition
- ->setClass('Flasher\Cli\Prime\CliNotificationFactory')
- ->addArgument(new Reference('flasher.response_manager'))
- ->addArgument(array())
+ ->setClass('Flasher\Cli\Prime\CliFactory')
->addTag('flasher.factory', array('alias' => 'cli'));
$container->setDefinition('flasher.cli', $definition);
-$container
- ->register('flasher.presenter.cli', 'Flasher\Cli\Prime\Presenter\CliPresenter')
- ->addTag('flasher.presenter', array('alias' => 'cli'));
+$container->register('flasher.notify', 'Flasher\Cli\Prime\Notify')
+ ->addArgument(null)
+ ->addArgument(array());
$container
- ->register('flasher.event_listener.cli_stamps_listener', 'Flasher\Cli\Prime\EventListener\StampsListener')
- ->addArgument(false)
- ->addArgument(true)
- ->addTag('flasher.event_subscriber');
+ ->register('flasher.cli.presenter', 'Flasher\Cli\Prime\Presenter\CliPresenter')
+ ->addArgument(new Reference('flasher.notify'))
+ ->addTag('flasher.presenter', array('alias' => CliPresenter::NAME));
$container
- ->register('flasher.event_listener.cli_render_listener', 'Flasher\Cli\Prime\EventListener\RenderListener')
- ->addArgument(new Reference('flasher.cli'))
+ ->register('flasher.cli.render_listener', 'Flasher\Cli\Prime\EventListener\RenderListener')
+ ->addArgument(new Reference('flasher'))
->addTag('flasher.event_subscriber', array('priority' => -256));
-$container
- ->register('flasher.cli.growl_notify', 'Flasher\Cli\Prime\Notifier\GrowlNotifyNotifier')
- ->addArgument(array())
- ->addTag('flasher.cli_notifier');
-
-$container
- ->register('flasher.cli.kdialog_notifier', 'Flasher\Cli\Prime\Notifier\KDialogNotifier')
- ->addArgument(array())
- ->addTag('flasher.cli_notifier');
-
-$container
- ->register('flasher.cli.notifu_notifier', 'Flasher\Cli\Prime\Notifier\NotifuNotifier')
- ->addArgument(array())
- ->addTag('flasher.cli_notifier');
-
-$container
- ->register('flasher.cli.notify_send', 'Flasher\Cli\Prime\Notifier\NotifySendNotifier')
- ->addArgument(array())
- ->addTag('flasher.cli_notifier');
-
-$container
- ->register('flasher.cli.snore_toast_notifier', 'Flasher\Cli\Prime\Notifier\SnoreToastNotifier')
- ->addArgument(array())
- ->addTag('flasher.cli_notifier');
-
-$container
- ->register('flasher.cli.terminal_notifier_notifier', 'Flasher\Cli\Prime\Notifier\TerminalNotifierNotifier')
- ->addArgument(array())
- ->addTag('flasher.cli_notifier');
-
-$container
- ->register('flasher.cli.toaster', 'Flasher\Cli\Prime\Notifier\ToasterNotifier')
- ->addArgument(array())
- ->addTag('flasher.cli_notifier');
-
-$container
- ->register('flasher.cli.zenity', 'Flasher\Cli\Prime\Notifier\ZenityNotifier')
- ->addArgument(array())
- ->addTag('flasher.cli_notifier');
-
-$container
- ->register('flasher.cli.apple_script', 'Flasher\Cli\Prime\Notifier\AppleScriptNotifier')
- ->addArgument(array())
- ->addTag('flasher.cli_notifier');
-
if (Bridge::canLoadAliases()) {
- $container->setAlias('Flasher\Cli\Prime\CliNotificationFactory', 'flasher.cli');
- $container->setAlias('Flasher\Cli\Prime\CliFlasherInterface', 'Flasher\Cli\Prime\CliNotificationFactory');
+ $container->setAlias('Flasher\Cli\Prime\CliFactory', 'flasher.cli');
+ $container->setAlias('Flasher\Cli\Prime\Notify', 'flasher.notify');
+ $container->setAlias('Flasher\Cli\Prime\NotifyInterface', 'flasher.notify');
}
diff --git a/src/Cli/Symfony/UPGRADING.md b/src/Cli/Symfony/UPGRADING.md
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/Cli/Symfony/composer.json b/src/Cli/Symfony/composer.json
index 55d75a4c..28cfb86b 100644
--- a/src/Cli/Symfony/composer.json
+++ b/src/Cli/Symfony/composer.json
@@ -2,37 +2,21 @@
"name": "php-flasher/flasher-cli-symfony",
"type": "symfony-bundle",
"description": "PHP Flasher Symfony adapter for Cli Console Terminal",
- "keywords": [
- "yoeunes",
- "notify",
- "php",
- "laravel",
- "symfony",
- "Lumen",
- "notifications",
- "messages",
- "alerts",
- "pnotify",
- "console",
- "cli",
- "terminal",
- "bundle",
- "flex"
- ],
- "homepage": "https://php-flasher.github.io/",
+ "keywords": ["yoeunes", "notify", "php", "laravel", "symfony", "Lumen", "notifications", "messages", "alerts", "pnotify", "console", "cli", "terminal", "bundle", "flex"],
+ "homepage": "https://php-flasher.io",
"authors": [
{
- "name": "Younes Khoubza",
+ "name": "Younes KHOUBZA",
"email": "younes.khoubza@gmail.com",
- "homepage": "https://github.com/yoeunes",
+ "homepage": "https://www.linkedin.com/in/younes-khoubza",
"role": "Developer"
}
],
"license": "MIT",
"require": {
"php": ">=5.3",
- "php-flasher/flasher-symfony": "^0.9",
- "php-flasher/flasher-cli": "^0.9"
+ "php-flasher/flasher-symfony": "^1.0",
+ "php-flasher/flasher-cli": "^1.0"
},
"autoload": {
"psr-4": {
@@ -42,6 +26,6 @@
"config": {
"sort-packages": true
},
- "minimum-stability": "dev",
+ "minimum-stability": "stable",
"prefer-stable": true
}
diff --git a/src/Laravel/.editorconfig b/src/Laravel/.editorconfig
deleted file mode 100644
index cd8eb86e..00000000
--- a/src/Laravel/.editorconfig
+++ /dev/null
@@ -1,15 +0,0 @@
-; This file is for unifying the coding style for different editors and IDEs.
-; More information at http://editorconfig.org
-
-root = true
-
-[*]
-charset = utf-8
-indent_size = 4
-indent_style = space
-end_of_line = lf
-insert_final_newline = true
-trim_trailing_whitespace = true
-
-[*.md]
-trim_trailing_whitespace = false
diff --git a/src/Laravel/.gitattributes b/src/Laravel/.gitattributes
deleted file mode 100644
index 3383d44b..00000000
--- a/src/Laravel/.gitattributes
+++ /dev/null
@@ -1,13 +0,0 @@
-
-# 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/Laravel/.github/CONTRIBUTING.md b/src/Laravel/.github/CONTRIBUTING.md
deleted file mode 100644
index b4ae1c4a..00000000
--- a/src/Laravel/.github/CONTRIBUTING.md
+++ /dev/null
@@ -1,55 +0,0 @@
-# Contributing
-
-Contributions are **welcome** and will be fully **credited**.
-
-Please read and understand the contribution guide before creating an issue or pull request.
-
-## Etiquette
-
-This project is open source, and as such, the maintainers give their free time to build and maintain the source code
-held within. They make the code freely available in the hope that it will be of use to other developers. It would be
-extremely unfair for them to suffer abuse or anger for their hard work.
-
-Please be considerate towards maintainers when raising issues or presenting pull requests. Let's show the
-world that developers are civilized and selfless people.
-
-It's the duty of the maintainer to ensure that all submissions to the project are of sufficient
-quality to benefit the project. Many developers have different skillsets, strengths, and weaknesses. Respect the maintainer's decision, and do not be upset or abusive if your submission is not used.
-
-## Viability
-
-When requesting or submitting new features, first consider whether it might be useful to others. Open
-source projects are used by many developers, who may have entirely different needs to your own. Think about
-whether or not your feature is likely to be used by other users of the project.
-
-## Procedure
-
-Before filing an issue:
-
-- Attempt to replicate the problem, to ensure that it wasn't a coincidental incident.
-- Check to make sure your feature suggestion isn't already present within the project.
-- Check the pull requests tab to ensure that the bug doesn't have a fix in progress.
-- Check the pull requests tab to ensure that the feature isn't already in progress.
-
-Before submitting a pull request:
-
-- Check the codebase to ensure that your feature doesn't already exist.
-- Check the pull requests to ensure that another person hasn't already submitted the feature or fix.
-
-## Requirements
-
-If the project maintainer has any additional requirements, you will find them listed here.
-
-- **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - The easiest way to apply the conventions is to install [PHP Code Sniffer](https://pear.php.net/package/PHP_CodeSniffer).
-
-- **Add tests!** - Your patch won't be accepted if it doesn't have tests.
-
-- **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date.
-
-- **Consider our release cycle** - We try to follow [SemVer v2.0.0](https://semver.org/). Randomly breaking public APIs is not an option.
-
-- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.
-
-- **Send coherent history** - Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please [squash them](https://www.git-scm.com/book/en/v2/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) before submitting.
-
-**Happy coding**!
diff --git a/src/Laravel/.github/FUNDING.yml b/src/Laravel/.github/FUNDING.yml
index 5e454f27..7de85ae3 100644
--- a/src/Laravel/.github/FUNDING.yml
+++ b/src/Laravel/.github/FUNDING.yml
@@ -1,5 +1,3 @@
-# These are supported funding model platforms
-
patreon: yoeunes
ko_fi: yoeunes
open_collective: php-flasher
diff --git a/src/Laravel/.github/SECURITY.md b/src/Laravel/.github/SECURITY.md
deleted file mode 100644
index d9b55dde..00000000
--- a/src/Laravel/.github/SECURITY.md
+++ /dev/null
@@ -1,3 +0,0 @@
-# Security Policy
-
-If you discover any security related issues, please email younes.khoubza@gmail.com instead of using the issue tracker.
diff --git a/src/Laravel/.github/dependabot.yml b/src/Laravel/.github/dependabot.yml
deleted file mode 100644
index c630ffa6..00000000
--- a/src/Laravel/.github/dependabot.yml
+++ /dev/null
@@ -1,7 +0,0 @@
-version: 2
-updates:
-- package-ecosystem: composer
- directory: "/"
- schedule:
- interval: daily
- open-pull-requests-limit: 10
diff --git a/src/Laravel/.github/workflows/auto_closer.yaml b/src/Laravel/.github/workflows/auto_closer.yaml
new file mode 100644
index 00000000..f807ac59
--- /dev/null
+++ b/src/Laravel/.github/workflows/auto_closer.yaml
@@ -0,0 +1,22 @@
+name: Auto Closer PR
+
+on:
+ pull_request_target:
+ types: [opened]
+
+jobs:
+ run:
+ runs-on: ubuntu-latest
+ steps:
+ - uses: superbrothers/close-pull-request@v3
+ with:
+ comment: |
+ Hi, thank you for your contribution.
+
+ Unfortunately, this repository is read-only. It's a split from our main monorepo repository.
+
+ We'd like to kindly ask you to move the contribution there - https://github.com/php-flasher/php-flasher.
+
+ We'll check it, review it and give you feed back right way.
+
+ Thank you.
diff --git a/src/Laravel/.github/workflows/close-pull-request.yml b/src/Laravel/.github/workflows/close-pull-request.yml
deleted file mode 100644
index ed229fac..00000000
--- a/src/Laravel/.github/workflows/close-pull-request.yml
+++ /dev/null
@@ -1,13 +0,0 @@
-name: Close Pull Request
-
-on:
- pull_request_target:
- types: [opened]
-
-jobs:
- run:
- runs-on: ubuntu-latest
- steps:
- - uses: superbrothers/close-pull-request@v3
- with:
- comment: "Thank you for your pull request. However, you have submitted this PR on a read-only sub split of `php-flasher/php-flasher`. Please submit your PR on the https://github.com/php-flasher/php-flasher repository.
Thanks!"
diff --git a/src/Laravel/.gitignore b/src/Laravel/.gitignore
deleted file mode 100644
index 89d72688..00000000
--- a/src/Laravel/.gitignore
+++ /dev/null
@@ -1,5 +0,0 @@
-.idea
-vendor
-composer.lock
-.phpunit.result.cache
-.phpcs-cache
diff --git a/src/Laravel/.phpstorm.meta.php b/src/Laravel/.phpstorm.meta.php
index 04d96382..a5c94f72 100644
--- a/src/Laravel/.phpstorm.meta.php
+++ b/src/Laravel/.phpstorm.meta.php
@@ -4,37 +4,14 @@ namespace PHPSTORM_META;
$mapping = [
'' => '@',
-
- 'Flasher\Prime\Config\ConfigInterface' => \Flasher\Laravel\Config\Config::class,
- 'Flasher\Prime\EventDispatcher\EventDispatcherInterface' => \Flasher\Prime\EventDispatcher\EventDispatcher::class,
- 'Flasher\Prime\Factory\NotificationFactoryInterface' => \Flasher\Prime\Factory\NotificationFactory::class,
- 'Flasher\Prime\Filter\FilterInterface' => \Flasher\Prime\Filter\Filter::class,
'Flasher\Prime\FlasherInterface' => \Flasher\Prime\Flasher::class,
- 'Flasher\Prime\Response\ResponseManagerInterface' => \Flasher\Prime\Response\ResponseManager::class,
- 'Flasher\Prime\Storage\StorageInterface' => \Flasher\Laravel\Storage\Storage::class,
- 'Flasher\Prime\Storage\StorageManagerInterface' => \Flasher\Prime\Storage\StorageManager::class,
- 'Flasher\Prime\Template\EngineInterface' => \Flasher\Laravel\Template\BladeEngine::class,
-
'flasher' => \Flasher\Prime\Flasher::class,
- 'flasher.config' => \Flasher\Laravel\Config\Config::class,
- 'flasher.event_dispatcher' => \Flasher\Prime\EventDispatcher\EventDispatcher::class,
- 'flasher.filter' => \Flasher\Prime\Filter\Filter::class,
- 'flasher.notification_factory' => \Flasher\Prime\Factory\NotificationFactory::class,
- 'flasher.template' => \Flasher\Prime\Factory\TemplateFactory::class,
'flasher.noty' => \Flasher\Noty\Prime\NotyFactory::class,
'flasher.notyf' => \Flasher\Notyf\Prime\NotyfFactory::class,
'flasher.pnotify' => \Flasher\Pnotify\Prime\PnotifyFactory::class,
- 'flasher.resource_manager' => \Flasher\Prime\Response\Resource\ResourceManager::class,
- 'flasher.response_manager' => \Flasher\Prime\Response\ResponseManager::class,
- 'flasher.storage' => \Flasher\Laravel\Storage\Storage::class,
- 'flasher.storage_manager' => \Flasher\Prime\Storage\StorageManager::class,
- 'flasher.sweet_alert' => \Flasher\SweetAlert\Prime\SweetAlertFactory::class,
- 'flasher.template_engine' => \Flasher\Laravel\Template\BladeEngine::class,
+ 'flasher.sweetalert' => \Flasher\SweetAlert\Prime\SweetAlertFactory::class,
+ 'flasher.template' => \Flasher\Prime\Factory\FlasherFactory::class,
'flasher.toastr' => \Flasher\Toastr\Prime\ToastrFactory::class,
-
- 'flasher.template.tailwindcss' => \Flasher\Prime\Factory\TemplateFactory::class,
- 'flasher.template.tailwindcss_bg' => \Flasher\Prime\Factory\TemplateFactory::class,
- 'flasher.template.boostrap' => \Flasher\Prime\Factory\TemplateFactory::class,
];
override(new \Illuminate\Contracts\Container\Container, map($mapping));
diff --git a/src/Laravel/CHANGELOG.md b/src/Laravel/CHANGELOG.md
deleted file mode 100644
index e69de29b..00000000
diff --git a/src/Laravel/CODE_OF_CONDUCT.md b/src/Laravel/CODE_OF_CONDUCT.md
deleted file mode 100644
index ec367cc6..00000000
--- a/src/Laravel/CODE_OF_CONDUCT.md
+++ /dev/null
@@ -1,76 +0,0 @@
-# Contributor Covenant Code of Conduct
-
-## Our Pledge
-
-In the interest of fostering an open and welcoming environment, we as
-contributors and maintainers pledge to making participation in our project and
-our community a harassment-free experience for everyone, regardless of age, body
-size, disability, ethnicity, sex characteristics, gender identity and expression,
-level of experience, education, socio-economic status, nationality, personal
-appearance, race, religion, or sexual identity and orientation.
-
-## Our Standards
-
-Examples of behavior that contributes to creating a positive environment
-include:
-
-* Using welcoming and inclusive language
-* Being respectful of differing viewpoints and experiences
-* Gracefully accepting constructive criticism
-* Focusing on what is best for the community
-* Showing empathy towards other community members
-
-Examples of unacceptable behavior by participants include:
-
-* The use of sexualized language or imagery and unwelcome sexual attention or
- advances
-* Trolling, insulting/derogatory comments, and personal or political attacks
-* Public or private harassment
-* Publishing others' private information, such as a physical or electronic
- address, without explicit permission
-* Other conduct which could reasonably be considered inappropriate in a
- professional setting
-
-## Our Responsibilities
-
-Project maintainers are responsible for clarifying the standards of acceptable
-behavior and are expected to take appropriate and fair corrective action in
-response to any instances of unacceptable behavior.
-
-Project maintainers have the right and responsibility to remove, edit, or
-reject comments, commits, code, wiki edits, issues, and other contributions
-that are not aligned to this Code of Conduct, or to ban temporarily or
-permanently any contributor for other behaviors that they deem inappropriate,
-threatening, offensive, or harmful.
-
-## Scope
-
-This Code of Conduct applies both within project spaces and in public spaces
-when an individual is representing the project or its community. Examples of
-representing a project or community include using an official project e-mail
-address, posting via an official social media account, or acting as an appointed
-representative at an online or offline event. Representation of a project may be
-further defined and clarified by project maintainers.
-
-## Enforcement
-
-Instances of abusive, harassing, or otherwise unacceptable behavior may be
-reported by contacting the project team at younes.khoubza@gmail.com. All
-complaints will be reviewed and investigated and will result in a response that
-is deemed necessary and appropriate to the circumstances. The project team is
-obligated to maintain confidentiality with regard to the reporter of an incident.
-Further details of specific enforcement policies may be posted separately.
-
-Project maintainers who do not follow or enforce the Code of Conduct in good
-faith may face temporary or permanent repercussions as determined by other
-members of the project's leadership.
-
-## Attribution
-
-This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
-available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
-
-[homepage]: https://www.contributor-covenant.org
-
-For answers to common questions about this code of conduct, see
-https://www.contributor-covenant.org/faq
diff --git a/src/Laravel/Config/Config.php b/src/Laravel/Config/Config.php
deleted file mode 100644
index 69cb8cd3..00000000
--- a/src/Laravel/Config/Config.php
+++ /dev/null
@@ -1,41 +0,0 @@
-config = $config;
- $this->separator = $separator;
- }
-
- public function get($key, $default = null)
- {
- return $this->getFrom('flasher', $key, $default);
- }
-
- /**
- * @param string $namespace
- * @param string $key
- * @param mixed $default
- *
- * @return mixed
- */
- public function getFrom($namespace, $key, $default = null)
- {
- return $this->config->get($namespace . $this->separator . $key, $default);
- }
-}
diff --git a/src/Laravel/Facade/Flasher.php b/src/Laravel/Facade/Flasher.php
index 86dd9817..ea344cb6 100644
--- a/src/Laravel/Facade/Flasher.php
+++ b/src/Laravel/Facade/Flasher.php
@@ -1,8 +1,13 @@
+ */
+
namespace Flasher\Laravel\Facade;
-use Flasher\Prime\Envelope;
+use Flasher\Prime\Notification\Envelope;
use Flasher\Prime\Notification\NotificationBuilder;
use Flasher\Prime\Notification\NotificationInterface;
use Flasher\Prime\Stamp\StampInterface;
@@ -13,7 +18,7 @@ use Illuminate\Support\Facades\Facade;
* @method static NotificationBuilder addError(string $message, array $options = array())
* @method static NotificationBuilder addWarning(string $message, array $options = array())
* @method static NotificationBuilder addInfo(string $message, array $options = array())
- * @method static NotificationBuilder addFlash(string|NotificationInterface $type, string $message = null, array $options = array())
+ * @method static NotificationBuilder addFlash(NotificationInterface|string $type, string $message = null, array $options = array())
* @method static NotificationBuilder flash(StampInterface[] $stamps = array())
* @method static NotificationBuilder type(string $type, string $message = null, array $options = array())
* @method static NotificationBuilder message(string $message)
diff --git a/src/Laravel/FlasherServiceProvider.php b/src/Laravel/FlasherServiceProvider.php
index 463252dc..9dc00039 100644
--- a/src/Laravel/FlasherServiceProvider.php
+++ b/src/Laravel/FlasherServiceProvider.php
@@ -1,83 +1,239 @@
+ */
+
namespace Flasher\Laravel;
-use Flasher\Laravel\ServiceProvider\ServiceProviderManager;
-use Illuminate\Container\Container;
-use Illuminate\Support\ServiceProvider;
+use Flasher\Laravel\Middleware\SessionMiddleware;
+use Flasher\Laravel\Storage\SessionBag;
+use Flasher\Laravel\Support\Laravel;
+use Flasher\Laravel\Support\ServiceProvider;
+use Flasher\Laravel\Template\BladeTemplateEngine;
+use Flasher\Prime\Config\Config;
+use Flasher\Prime\EventDispatcher\EventDispatcher;
+use Flasher\Prime\Flasher;
+use Flasher\Prime\Plugin\FlasherPlugin;
+use Flasher\Prime\Response\Resource\ResourceManager;
+use Flasher\Prime\Response\ResponseManager;
+use Flasher\Prime\Storage\StorageBag;
+use Flasher\Prime\Storage\StorageManager;
+use Illuminate\Foundation\Application;
+use Illuminate\Support\Facades\Blade;
+use Illuminate\View\Compilers\BladeCompiler;
+use Livewire\Component;
+use Livewire\LivewireManager;
+use Livewire\Response;
+/**
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
+ */
final class FlasherServiceProvider extends ServiceProvider
{
/**
- * Bootstrap the application events.
- *
+ * {@inheritdoc}
+ */
+ public function afterBoot()
+ {
+ $this->registerBladeDirectives();
+ $this->registerLivewire();
+ }
+
+ /**
+ * @{@inheritdoc}
+ */
+ protected function createPlugin()
+ {
+ return new FlasherPlugin();
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function afterRegister()
+ {
+ $this->registerConfig();
+ $this->registerFlasher();
+ $this->registerResourceManager();
+ $this->registerResponseManager();
+ $this->registerStorageManager();
+ $this->registerEventDispatcher();
+ $this->registerSessionMiddleware();
+ }
+
+ /**
* @return void
*/
- public function boot()
+ private function registerConfig()
{
- /** @var Container $app */
- $app = $this->app;
- $manager = new ServiceProviderManager($this, $app);
- $manager->boot();
+ $this->app->singleton('flasher.config', function (Application $app) {
+ return new Config($app['config']->get('flasher')); // @phpstan-ignore-line
+ });
}
/**
- * Register the service provider.
+ * @return void
*/
- public function register()
+ private function registerFlasher()
{
- /** @var Container $app */
- $app = $this->app;
- $manager = new ServiceProviderManager($this, $app);
- $manager->register();
+ $this->app->singleton('flasher', function (Application $app) {
+ return new Flasher($app['flasher.config']->get('default'), $app['flasher.response_manager'], $app['flasher.storage_manager']); // @phpstan-ignore-line
+ });
+ $this->app->alias('flasher', 'Flasher\Prime\Flasher');
+ $this->app->bind('Flasher\Prime\FlasherInterface', 'flasher');
}
/**
- * Get the services provided by the provider.
+ * @return void
+ */
+ private function registerResourceManager()
+ {
+ $this->app->singleton('flasher.resource_manager', function (Application $app) {
+ return new ResourceManager($app['flasher.config'], new BladeTemplateEngine($app['view'])); // @phpstan-ignore-line
+ });
+ }
+
+ /**
+ * @return void
+ */
+ private function registerResponseManager()
+ {
+ $this->app->singleton('flasher.response_manager', function (Application $app) {
+ return new ResponseManager($app['flasher.resource_manager'], $app['flasher.storage_manager'], $app['flasher.event_dispatcher']); // @phpstan-ignore-line
+ });
+ }
+
+ /**
+ * @return void
+ */
+ private function registerStorageManager()
+ {
+ $this->app->singleton('flasher.storage_manager', function (Application $app) {
+ return new StorageManager(new StorageBag(new SessionBag($app['session'])), $app['flasher.event_dispatcher']); // @phpstan-ignore-line
+ });
+ }
+
+ /**
+ * @return void
+ */
+ private function registerEventDispatcher()
+ {
+ $this->app->singleton('flasher.event_dispatcher', function () {
+ return new EventDispatcher();
+ });
+ }
+
+ /**
+ * @return void
+ */
+ private function registerSessionMiddleware()
+ {
+ $config = $this->app['flasher.config'];
+ if (true !== $config->get('flash_bag.enabled', false)) {
+ return;
+ }
+
+ $mapping = $config->get('flash_bag.mapping', array());
+ $this->app->singleton('Flasher\Laravel\Middleware\SessionMiddleware', function (Application $app) use ($mapping) {
+ return new SessionMiddleware($app['flasher'], $mapping); // @phpstan-ignore-line
+ });
+ }
+
+ /**
+ * @return void
+ */
+ private function registerLivewire()
+ {
+ if (!$this->app->bound('livewire')) {
+ return;
+ }
+
+ $livewire = $this->app->make('livewire');
+ if (!$livewire instanceof LivewireManager) {
+ return;
+ }
+
+ $livewire->listen('component.dehydrate', function (Component $component, Response $response) {
+ $data = app('flasher')->render(array(), 'array'); // @phpstan-ignore-line
+
+ if (\count($data['envelopes']) > 0) {
+ $data['context']['livewire'] = array(
+ 'id' => $component->id,
+ 'name' => $response->fingerprint['name'],
+ );
+
+ $response->effects['dispatches'][] = array(
+ 'event' => 'flasher:render',
+ 'data' => $data,
+ );
+ }
+ });
+ }
+
+ /**
+ * @return void
*
- * @return string[]
+ * @SuppressWarnings(PHPMD.CyclomaticComplexity)
*/
- public function provides()
+ private function registerBladeDirectives()
{
- return array(
- 'flasher',
- );
- }
+ $startsWith = function ($haystack, $needle) {
+ return 0 === substr_compare($haystack, $needle, 0, \strlen($needle));
+ };
- /**
- * @return Container
- */
- public function getApplication()
- {
- /** @var Container $app */
- $app = $this->app;
+ $endsWith = function ($haystack, $needle) {
+ return 0 === substr_compare($haystack, $needle, -\strlen($needle));
+ };
- return $app;
- }
+ if (Laravel::isVersion('5.1', '>=')) {
+ Blade::directive('flasher_render', function ($criteria = array()) use ($startsWith, $endsWith) {
+ if (!empty($criteria) && $startsWith($criteria, '(') && $endsWith($criteria, ')')) {
+ $criteria = substr($criteria, 1, -1);
+ }
- public function mergeConfigFrom($path, $key)
- {
- parent::mergeConfigFrom($path, $key);
- }
+ return "render({$criteria}); ?>";
+ });
- /**
- * @param string[] $paths
- */
- public function publishes(array $paths, $groups = null)
- {
- parent::publishes($paths, $groups);
- }
+ return;
+ }
- public function loadTranslationsFrom($path, $namespace)
- {
- parent::loadTranslationsFrom($path, $namespace);
- }
+ if (Laravel::isVersion('5.0', '>=')) {
+ Blade::extend(function ($view, BladeCompiler $compiler) use ($startsWith, $endsWith) {
+ if (!method_exists($compiler, 'createPlainMatcher')) {
+ return '';
+ }
- /**
- * @param string $path
- */
- public function loadViewsFrom($path, $namespace)
- {
- parent::loadViewsFrom($path, $namespace);
+ $pattern = $compiler->createPlainMatcher('flasher_render(.*)');
+ $matches = array();
+
+ preg_match($pattern, $view, $matches);
+
+ $value = $matches[2];
+
+ if (!empty($value) && $startsWith($value, '(') && $endsWith($value, ')')) {
+ $value = substr($value, 1, -1);
+ }
+
+ return str_replace(
+ '%criteria%',
+ $value,
+ $matches[1]."render(%criteria%); ?>"
+ );
+ });
+
+ return;
+ }
+
+ Blade::extend(function ($view, BladeCompiler $compiler) {
+ if (!method_exists($compiler, 'createMatcher')) {
+ return '';
+ }
+
+ $pattern = $compiler->createMatcher('flasher_render');
+
+ return preg_replace($pattern, '$1render$2; ?>', $view);
+ });
}
}
diff --git a/src/Laravel/Middleware/SessionMiddleware.php b/src/Laravel/Middleware/SessionMiddleware.php
old mode 100755
new mode 100644
index 9a395255..33b1bfce
--- a/src/Laravel/Middleware/SessionMiddleware.php
+++ b/src/Laravel/Middleware/SessionMiddleware.php
@@ -1,36 +1,37 @@
+ */
+
namespace Flasher\Laravel\Middleware;
use Closure;
-use Flasher\Prime\Config\ConfigInterface;
use Flasher\Prime\FlasherInterface;
-use Flasher\Prime\Response\ResponseManagerInterface;
+use Flasher\Prime\Response\Presenter\HtmlPresenter;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
final class SessionMiddleware
{
- /**
- * @var ConfigInterface
- */
- private $config;
-
/**
* @var FlasherInterface
*/
private $flasher;
/**
- * @var ResponseManagerInterface
+ * @var array
*/
- private $renderer;
+ private $mapping;
- public function __construct(ConfigInterface $config, FlasherInterface $flasher, ResponseManagerInterface $renderer)
+ /**
+ * @param array $mapping
+ */
+ public function __construct(FlasherInterface $flasher, array $mapping = array())
{
- $this->config = $config;
$this->flasher = $flasher;
- $this->renderer = $renderer;
+ $this->mapping = $this->flatMapping($mapping);
}
/**
@@ -43,19 +44,26 @@ final class SessionMiddleware
/** @var Response $response */
$response = $next($request);
- if ($request->isXmlHttpRequest() || true !== $this->config->get('auto_create_from_session')) {
+ if ($request->isXmlHttpRequest() || !$request->hasSession()) {
+ return $response;
+ }
+
+ $content = $response->getContent() ?: '';
+ $insertPlaceHolder = HtmlPresenter::FLASHER_FLASH_BAG_PLACE_HOLDER;
+ $insertPosition = strripos($content, $insertPlaceHolder);
+ if (false === $insertPosition) {
return $response;
}
$readyToRender = false;
-
- foreach ($this->typesMapping() as $alias => $type) {
+ foreach ($this->mapping as $alias => $type) {
if (false === $request->session()->has($alias)) {
continue;
}
- $this->flasher->addFlash($type, $request->session()->get($alias));
-
+ /** @var string $message */
+ $message = $request->session()->get($alias);
+ $this->flasher->addFlash((string) $type, $message);
$readyToRender = true;
}
@@ -63,40 +71,32 @@ final class SessionMiddleware
return $response;
}
- $htmlResponse = $this->renderer->render(array(), 'html');
+ $htmlResponse = $this->flasher->render(array(), 'html', array('envelopes_only' => true));
if (empty($htmlResponse)) {
return $response;
}
- $content = $response->getContent();
- if (false === $content) {
- return $response;
- }
-
- $pos = (int) strripos($content, '