sshversioncontrol / notificationbundle
为 Symfony 简单通知包
dev-master
2017-06-02 11:32 UTC
Requires
- php: ^5.5.9 || ^7.0
- symfony/dependency-injection: ~2.3|~3.0
- symfony/framework-bundle: ^2.7 || ^3.0
Requires (Dev)
- doctrine/doctrine-bundle: ^1.3
- phpunit/phpunit: ~4.8
- symfony/symfony: ^2.7 || ^3.0
This package is auto-updated.
Last update: 2024-09-16 05:08:32 UTC
README
安装
要在您的 Symfony 项目中使用此包,请将以下内容添加到您的 composer.json
{
"require": {
// ...
"": "dev-master"
}
}
并在您的内核中启用它
<?php
// app/AppKernel.php
public function registerBundles()
{
$bundles = array(
// ...
new GitSSH2\NotificationBundle\GitSSH2NotificationBundle(),
);
}
配置
如果您想使用默认的系统处理程序,该处理程序将通知存储在数据库中,您需要更新数据库
php bin/console doctrine:schema:update --force
默认配置是使用系统处理程序。您可以创建自己的处理程序并将它们注册。
gitssh2.notification.manager:
class: GitSSH2\NotificationBundle\Notification\Manager\NotificationManager
arguments: [["@gitssh2.notification.handler.system"]]
使用方法
此包是一个简单通知系统的基础。要触发通知,您只需使用 Symfony 的事件调度器,例如。
<?php
$notification = new Notification();
$notification->setTitle('Hello');
$notification->setMessage('Welcome message');
...
$notifcationEvent = new NotificationEvent($notification);
$dispatcher = $this->get('event_dispatcher');
$dispatcher->dispatch($notifcationEvent::NAME, $notifcationEvent);
建议您使用自己的通知实体。您需要做的就是实现 GitSSH2\NotificationBundle\Notification\NotificationEntityInterface
您还应该实现自己的通知处理程序。例如,您可以创建一个电子邮件处理程序。
以下代码示例将遵循