https://github.com/synolia/syliusadminnotificationplugin
https://github.com/synolia/syliusadminnotificationplugin
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/synolia/syliusadminnotificationplugin
- Owner: synolia
- License: eupl-1.2
- Created: 2022-05-05T09:08:25.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2022-11-07T15:58:02.000Z (over 2 years ago)
- Last Synced: 2025-03-28T22:09:35.736Z (2 months ago)
- Language: PHP
- Size: 57.6 KB
- Stars: 0
- Watchers: 12
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
Awesome Lists containing this project
README

Admin Notification Plugin
Notification messages in your Sylius admin panel.
## Features
* Add custom notification messages in your Sylius admin panel.
* Show list of notifications## Requirements
| | Version |
|:-------|:-----------|
| PHP | ^7.4, ^8.0 |
| Sylius | ^1.9 |## Installation
1. Add the bundle and dependencies in your composer.json :
```shell
composer require synolia/sylius-admin-notification-plugin
```2. Import routing in your project `config/routes/synolia_sylius_admin_notification.yaml`:
```yaml
synolia_sylius_admin_notification_plugin:
resource: "@SynoliaSyliusAdminNotificationPlugin/config/routes/admin_routing.yaml"
prefix: '%sylius_admin.path_name%'
```3. Apply plugin migrations to your database:
```shell
bin/console doctrine:migrations:migrate
```## How to create a notification
### Send notification using Symfony notifier
```php
notifier = $notifier;
}protected function send(string $title, string $content): void
{
$notification = (new Notification($title, ['chat/admin_notification']))
->content($content);$this->notifier->send($notification);
}
}
```### Send notification using monolog handler
```yaml
monolog:
channels: ['synolia_sylius_admin_notification']
handlers:
synolia_sylius_admin_notification:
channels: [synolia_sylius_admin_notification]
level: debug
type: service
id: Synolia\SyliusAdminNotificationPlugin\Handler\Monolog\AdminNotificationHandler
``````php
synoliaSyliusAdminNotificationLogger = $synoliaSyliusAdminNotificationLogger;
}protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->synoliaSyliusAdminNotificationLogger->critical('Notification message', [
'context_1' => 'this is the first context',
'context_2' => [
'key' => 'val'
],
]);
}
}
```### Write logs as notification
```yaml
monolog:
handlers:
synolia_sylius_admin_notification:
level: debug
type: service
id: Synolia\SyliusAdminNotificationPlugin\Handler\Monolog\AdminNotificationHandler
main:
type: fingers_crossed
action_level: error
handler: grouped
channels: [ "!deprecation", "!sonata"]
excluded_http_codes: [404, 405]
buffer_size: 50 # How many messages should be saved? Prevent memory leaks
grouped:
type: group
members: [ nested, deduplicated ]
nested:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
deduplicated:
type: deduplication
handler: synolia_sylius_admin_notification
```## Development
See [How to contribute](CONTRIBUTING.md).
## License
This library is under the EUPL-1.2 license.
## Credits
Developed by [Synolia](https://synolia.com/).