From aa645778e3cdcae19be976b54db27472443bf335 Mon Sep 17 00:00:00 2001 From: Younes ENNAJI Date: Sun, 13 Oct 2024 23:44:52 +0100 Subject: [PATCH] chore: update laravel and symfony configuration documentation --- docs/pages/laravel.md | 45 ++++++++++++--------- docs/pages/symfony.md | 68 +++++++++++++++++++------------- src/Laravel/Resources/config.php | 47 +++++++++++++--------- 3 files changed, 96 insertions(+), 64 deletions(-) diff --git a/docs/pages/laravel.md b/docs/pages/laravel.md index 2b26c34c..71034746 100644 --- a/docs/pages/laravel.md +++ b/docs/pages/laravel.md @@ -53,32 +53,30 @@ This will create a file at `config/flasher.php` with the following content: 'flasher', - // Path to the main JavaScript file of PHPFlasher + // Path to the main PHPFlasher JavaScript file 'main_script' => '/vendor/flasher/flasher.min.js', - // Path to the stylesheets for PHPFlasher notifications + // List of CSS files to style your notifications 'styles' => [ '/vendor/flasher/flasher.min.css', ], - // Enable translation of PHPFlasher messages using Laravel's translator service - 'translate' => true, + // Set global options for all notifications (optional) + // 'options' => [ + // 'timeout' => 5000, // Time in milliseconds before the notification disappears + // 'position' => 'top-right', // Where the notification appears on the screen + // ], - // Automatically inject PHPFlasher assets in HTML response + // Automatically inject JavaScript and CSS assets into your HTML pages 'inject_assets' => true, - // Global options - 'options' => [ - 'timeout' => 5000, // in milliseconds - 'position' => 'top-right', - 'escapeHtml' => false, - ], + // Enable message translation using Laravel's translation service + 'translate' => true, - // Configuration for the flash bag (converting Laravel flash messages) - // Map Laravel session keys to PHPFlasher types + // Map Laravel flash message keys to notification types 'flash_bag' => [ 'success' => ['success'], 'error' => ['error', 'danger'], @@ -86,11 +84,22 @@ return [ 'info' => ['info', 'notice', 'alert'], ], - // Filter criteria for notifications (e.g., limit number, types) - 'filter' => [ - 'limit' => 5, // Limit the number of displayed notifications - ], + // Set criteria to filter which notifications are displayed (optional) + // 'filter' => [ + // 'limit' => 5, // Maximum number of notifications to show at once + // ], + + // Define notification presets to simplify notification creation (optional) + // 'presets' => [ + // 'entity_saved' => [ + // 'type' => 'success', + // 'title' => 'Entity saved', + // 'message' => 'Entity saved successfully', + // ], + // ], ]; + + ``` --- diff --git a/docs/pages/symfony.md b/docs/pages/symfony.md index 4aaceaaf..1b041a2e 100644 --- a/docs/pages/symfony.md +++ b/docs/pages/symfony.md @@ -52,40 +52,54 @@ This will create a file at `config/packages/flasher.yaml` with the following con # config/packages/flasher.yaml flasher: - # Default notification library (e.g., 'flasher', 'toastr', 'noty', etc.) + # Default notification library (e.g., 'flasher', 'toastr', 'noty', 'notyf', 'sweetalert') default: flasher - - # Path to the main JavaScript file of PHPFlasher + + # Path to the main PHPFlasher JavaScript file main_script: '/vendor/flasher/flasher.min.js' - - # Path to the stylesheets for PHPFlasher notifications + + # List of CSS files to style your notifications styles: - '/vendor/flasher/flasher.min.css' - - # Enable translation of PHPFlasher messages using Symfony's translator service - translate: true - - # Automatically inject PHPFlasher assets in HTML response + + # Set global options for all notifications (optional) + # options: + # # Time in milliseconds before the notification disappears + # timeout: 5000 + # # Where the notification appears on the screen + # position: 'top-right' + + # Automatically inject JavaScript and CSS assets into your HTML pages inject_assets: true - - # Global options - options: - # timeout in milliseconds - timeout: 5000 - position: 'top-right' - escapeHtml: false - - # Map Symfony session keys to PHPFlasher notification types + + # Enable message translation using Symfony's translation service + translate: true + + # URL patterns to exclude from asset injection and flash_bag conversion + excluded_paths: + - '/^\/_profiler/' + - '/^\/_fragment/' + + # Map Symfony flash message keys to notification types flash_bag: - success: ['success'] - error: ['error', 'danger'] - warning: ['warning', 'alarm'] - info: ['info', 'notice', 'alert'] + success: ['success'] + error: ['error', 'danger'] + warning: ['warning', 'alarm'] + info: ['info', 'notice', 'alert'] + + # Set criteria to filter which notifications are displayed (optional) + # filter: + # # Maximum number of notifications to show at once + # limit: 5 + + # Define notification presets to simplify notification creation (optional) + # presets: + # # Example preset: + # entity_saved: + # type: 'success' + # title: 'Entity saved' + # message: 'Entity saved successfully' - # Criteria to filter displayed notifications (limit, types) - filter: - # Limit number of displayed notifications - limit: 5 ``` --- diff --git a/src/Laravel/Resources/config.php b/src/Laravel/Resources/config.php index e09acf8c..1d3c754c 100644 --- a/src/Laravel/Resources/config.php +++ b/src/Laravel/Resources/config.php @@ -2,34 +2,34 @@ declare(strict_types=1); -namespace Flasher\Laravel\Resources; - return [ - // Default notification library (e.g., 'flasher', 'toastr', 'noty', etc.) + // Default notification library (e.g., 'flasher', 'toastr', 'noty', 'notyf', 'sweetalert') 'default' => 'flasher', - // Path to the main JavaScript file of PHPFlasher + // Path to the main PHPFlasher JavaScript file 'main_script' => '/vendor/flasher/flasher.min.js', - // Path to the stylesheets for PHPFlasher notifications + // List of CSS files to style your notifications 'styles' => [ '/vendor/flasher/flasher.min.css', ], - // Whether to translate PHPFlasher messages using Laravel's translation service - 'translate' => true, + // Set global options for all notifications (optional) + // 'options' => [ + // 'timeout' => 5000, // Time in milliseconds before the notification disappears + // 'position' => 'top-right', // Where the notification appears on the screen + // ], - // Automatically inject PHPFlasher assets into HTML response + // Automatically inject JavaScript and CSS assets into your HTML pages 'inject_assets' => true, - // Global options - 'options' => [ - 'timeout' => 5000, // in milliseconds - 'position' => 'top-right', - ], + // Enable message translation using Laravel's translation service + 'translate' => true, - // Configuration for the flash bag (converting Laravel flash messages) - // Map Laravel session keys to PHPFlasher types + // URL patterns to exclude from asset injection and flash_bag conversion + 'excluded_paths' => [], + + // Map Laravel flash message keys to notification types 'flash_bag' => [ 'success' => ['success'], 'error' => ['error', 'danger'], @@ -37,8 +37,17 @@ return [ 'info' => ['info', 'notice', 'alert'], ], - // Filter criteria for notifications (e.g., limit number, types) - 'filter' => [ - 'limit' => 5, // Limit the number of displayed notifications - ], + // Set criteria to filter which notifications are displayed (optional) + // 'filter' => [ + // 'limit' => 5, // Maximum number of notifications to show at once + // ], + + // Define notification presets to simplify notification creation (optional) + // 'presets' => [ + // 'entity_saved' => [ + // 'type' => 'success', + // 'title' => 'Entity saved', + // 'message' => 'Entity saved successfully', + // ], + // ], ];