php-solution / notification-bundle
Symfony bundle for using notification component with user notify functionality
Installs: 1 050
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=7.1
- php-solution/notification: ~0.1
- symfony/config: >=3.1
- symfony/dependency-injection: >=3.1
- symfony/event-dispatcher: >=3.1
- symfony/http-kernel: >=3.1
- symfony/options-resolver: >=3.1
Requires (Dev)
- symfony/swiftmailer-bundle: >=2.0
Suggests
- symfony/swiftmailer-bundle: for use SwiftMailer as Notifier
This package is auto-updated.
Last update: 2024-11-14 18:19:34 UTC
README
This bundle integrates Notification component to Symfony application.
Please, see documentation for Notification component before start development.
Configuration
notification:
extensions:
use_for_manager: "notification.extension.context_configurator"
context_configurator:
enabled: true
event_dispatcher:
enabled: false
notifier_swiftmailer:
enabled: true
default_sender: ~
Installing
- Add to your composer.json
"require": {
...
"php-solution/notification-bundle": "dev-master",
...
}
- run:
composer update php-solution/notification-bundle
Example
Notification Type:
<?php
namespace AppBundle\Notification;
use PhpSolution\Notification\Context;
use PhpSolution\Notification\Extension\ContextConfigure\ConfiguratorInterface;
use PhpSolution\Notification\Rule\RuleInterface;
use PhpSolution\Notification\Type\AbstractType;
use PhpSolution\NotificationBundle\Notifier\SwiftMailer\Rule;
use Symfony\Component\OptionsResolver\OptionsResolver;
class NotificationType extends AbstractType implements ConfiguratorInterface
{
/**
* Must yield RuleInterface
*
* @param Context|null $context
*
* @return \Generator|RuleInterface|RuleInterface[]
*/
public function initialize(?Context $context): \Generator
{
yield new Rule($context['recipient_email']);
}
/**
* @param OptionsResolver $resolver
*/
public function configureContext(OptionsResolver $resolver)
{
$resolver
->setRequired('recipient_email')
->setAllowedTypes('recipient_email', 'string');
}
}
On controller:
$this->get('notification.manager')->notifyType(
new NotificationType(),
new Context(['recipient_email' => 'email@gmail.com'])
);