wazum / console-output-service
该包的最新版本(1.0.0)没有可用的许可证信息。
提供Symfony ConsoleOutput作为服务
1.0.0
2022-05-31 06:43 UTC
Requires
- symfony/console: *
- typo3/cms-core: ^10||^11||^12
README
安装
composer require "wazum/console-output-service"
用法
这个小小的TYPO3扩展提供了Symfony ConsoleOutput
服务。
然后,ConsoleOutput
可以被注入到需要的地方(任何控制台命令之外),因此您不需要传递实例(如果服务不是直接调用,例如在下面的基于事件的系统中,这是不可能的)。
namespace Vendor\Extension\EventListener; use Symfony\Component\Console\Output\ConsoleOutput; final class OnSomethingHappened { public function __construct(private readonly ConsoleOutput $output) { } public function __invoke(SomethingHappened $event): void { $this->output->writeln( '<info>Something happened!</info>' ); } }
背景
该扩展为ConsoleOutput
配置了一个工厂,当您将ConsoleOutput
作为服务注入时,将自动使用。
services: Wazum\ConsoleOutputService\Console\ConsoleOutputFactory: ~ Symfony\Component\Console\Output\ConsoleOutput: factory: ['@Wazum\ConsoleOutputService\Console\ConsoleOutputFactory', 'create']