ssch / t3-notifier
用于 Symfony Notifier 的包装器
v1.0.3
2023-12-12 14:59 UTC
Requires
- php: ^7.4 || ^8.0
- symfony/notifier: ^5.0 || ^6.2
- symfony/options-resolver: ^5.0 || ^6.2
- typo3/cms-core: ^10.4 || ^11.5 || ^12.4
- typo3/cms-extbase: ^10.4 || ^11.5 || ^12.4
Requires (Dev)
- php-parallel-lint/php-parallel-lint: ^1.3
- phpstan/extension-installer: ^1.2
- phpstan/phpstan: ^1.8
- phpstan/phpstan-phpunit: ^1.2
- phpstan/phpstan-strict-rules: ^1.4
- saschaegerer/phpstan-typo3: ^1.8
- symplify/easy-coding-standard: ^12.0
- typo3/cms-lowlevel: ^10.4 || ^11.5 || ^12.4
- typo3/minimal: ^10.4 || ^11.5 || ^12.4
- typo3/testing-framework: ^6.16 || ^7.0
Replaces
- typo3-ter/t3-notifier: v1.0.3
This package is auto-updated.
Last update: 2024-08-31 00:46:06 UTC
README
将 Symfony Notifier 集成到 TYPO3 https://symfony.ac.cn/doc/current/notifier.html
集成指南
该扩展基本上提供了与在 Symfony 框架中使用通知器相同的功能。为了配置通知器,您需要在扩展的配置文件夹下放置一个 Notifier.php 文件。
return [ 'chatter_transports' => [ 'slack' => '%env(SLACK_DSN)%' ], # 'texter_transports' => [ 'twilio' => '%env(TWILIO_DSN)%' ], # https://symfony.ac.cn/doc/current/notifier.html#configuring-channel-policies 'channel_policy' => [ 'urgent' => ['sms', 'chat/slack', 'email'], 'high' => ['chat/slack'], 'medium' => ['browser'] ] ];
为了使用通知器,您可以通过依赖注入将其注入
use Symfony\Component\Notifier\NotifierInterface; use TYPO3\CMS\Extbase\Mvc\Controller\ActionController; use Symfony\Component\Notifier\Notification\Notification; final class SomeController extends ActionController { public function __construct(private readonly NotifierInterface $notifier) {} public function someAction() { $notification = (new Notification('New Notification')) ->content('You got a new notification.') ->importance(Notification::IMPORTANCE_HIGH); $this->notifier->send($notification, new Recipient('max@mustermann.com')); } }
这将通过 slack 传输将新的通知发送到聊天频道。
日志写入器
该扩展附带一个自定义的 LogWriter,用于通过通知器发送 LogRecords。为了使用 LogWriter,您可以通过 ext_localconf.php 进行配置。
use Ssch\T3Notifier\Logger\Writer\NotifierWriter; use Symfony\Component\Notifier\Recipient\Recipient; use TYPO3\CMS\Core\Log\LogLevel; $GLOBALS['TYPO3_CONF_VARS']['LOG']['Examples']['writerConfiguration'] = [ LogLevel::ERROR => [ NotifierWriter::class => [ // Optional configuration 'channels' => ['chat/slack'] 'recipients' => [new Recipient('max.mustermann@domain.com', '123455678')], ], ], ];
如果您没有传递 channels 选项,您必须配置您的 channel_policy。PSR-3 LogLevel 将被转换为通知的重要性级别。例如,如果您调用 $this->logger->error,它将转换为重要性级别为高。
浏览器频道
[待定]
电子邮件通知
[待定]