artox-lab / clarc-notification-bundle
Artox Lab CLARC bundle 的通知适配器
1.2.0
2022-10-31 14:37 UTC
Requires
- php: >=7.3
- symfony/framework-bundle: ^5.0 || ^6.0
- symfony/yaml: ^5.0 || ^6.0
Requires (Dev)
- roave/security-advisories: dev-master
This package is auto-updated.
Last update: 2024-08-29 05:37:19 UTC
README
安装
使用 Symfony Flex 的应用程序
打开命令行控制台,进入你的项目目录并执行
$ composer require artox-lab/clarc-notification-bundle
未使用 Symfony Flex 的应用程序
步骤 1: 下载 Bundle
打开命令行控制台,进入你的项目目录并执行以下命令以下载此 Bundle 的最新稳定版本
$ composer require artox-lab/clarc-notification-bundle
此命令要求你全局安装了 Composer,具体请参考 Composer 文档中的 安装章节。
步骤 2: 启用 Bundle
然后,通过将其添加到项目中 config/bundles.php
文件中注册的 Bundle 列表来启用该 Bundle
// config/bundles.php return [ // ... ArtoxLab\Bundle\ClarcNotificationBundle\ArtoxLabClarcNotificationBundle::class => ['all' => true], ];
用法
你需要在你的应用程序中实现
use App\Entities\Notification\ExampleNotification; use ArtoxLab\Bundle\ClarcNotificationBundle\Notification\Entities\Notifier\NotifierInterface; use ArtoxLab\Bundle\ClarcNotificationBundle\Notification\Entities\Recipient\EmailRecipient; use ArtoxLab\Bundle\ClarcNotificationBundle\Notification\Entities\Recipient\SmsRecipient; class Example { /** * Notifier * * @var NotifierInterface */ private $notifier; /** * Example constructor. * * @param NotifierInterface $notifier Notifier */ public function __construct(NotifierInterface $notifier) { $this->notifier = $notifier; } /** * Notify example * * @return void */ public function notify(): void { $notification = new ExampleNotification('test'); $smsRecipient = new SmsRecipient('+123123123'); $emailRecipient = new EmailRecipient('test@example.com'); $this->notifier->notify($notification, $smsRecipient, $emailRecipient); } }