File tree Expand file tree Collapse file tree 3 files changed +29
-18
lines changed
Expand file tree Collapse file tree 3 files changed +29
-18
lines changed Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ namespace ErrorHeroModule;
55use App\Exception\MyException;
66use RuntimeException;
77use Error;
8- use Laminas\Log\LoggerAbstractServiceFactory ;
8+ use ErrorHeroModule\Command\BaseLoggingCommandInitializer ;
99use ErrorHeroModule\Middleware\Mezzio;
1010use ErrorHeroModule\Middleware\MezzioFactory;
1111use ErrorHeroModule\ErrorHeroModule\Middleware\Routed\Preview\ErrorPreviewAction;
@@ -14,6 +14,7 @@ use ErrorHeroModule\Handler\LoggingFactory;
1414use ErrorHeroModule\Command\BaseLoggingCommand;
1515use Laminas\Db\Adapter\AdapterInterface;
1616use Laminas\Log;
17+ use Laminas\Log\LoggerAbstractServiceFactory;
1718use Laminas\ServiceManager\Factory\InvokableFactory;
1819
1920return [
@@ -160,14 +161,7 @@ json
160161 Logging::class => LoggingFactory::class,
161162 ],
162163 'initializers' => [
163- static function ($service, $instance) : void {
164- if ($instance instanceof BaseLoggingCommand) {
165- $instance->init(
166- $service->get('config')['error-hero-module'],
167- $service->get(Logging::class)
168- );
169- }
170- }
164+ BaseLoggingCommandInitializer::class,
171165 ],
172166 ],
173167
Original file line number Diff line number Diff line change 22
33namespace ErrorHeroModule ;
44
5- use ErrorHeroModule \Command \BaseLoggingCommand ;
5+ use ErrorHeroModule \Command \BaseLoggingCommandInitializer ;
66use ErrorHeroModule \Command \Preview \ErrorPreviewConsoleCommand ;
77use ErrorHeroModule \Controller \ErrorPreviewController ;
88use Laminas \Log \LoggerAbstractServiceFactory ;
4747 ErrorPreviewConsoleCommand::class => InvokableFactory::class,
4848 ],
4949 'initializers ' => [
50- static function ($ service , $ instance ) : void {
51- if ($ instance instanceof BaseLoggingCommand) {
52- $ instance ->init (
53- $ service ->get ('config ' )['error-hero-module ' ],
54- $ service ->get (Logging::class)
55- );
56- }
57- }
50+ BaseLoggingCommandInitializer::class,
5851 ],
5952 ],
6053
Original file line number Diff line number Diff line change 1+
2+ <?php
3+
4+ declare (strict_types=1 );
5+
6+ namespace ErrorHeroModule \Command ;
7+
8+ use ErrorHeroModule \Handler \Logging ;
9+ use Psr \Container \ContainerInterface ;
10+
11+ class BaseLoggingCommandInitializer implements InitializerInterface
12+ {
13+ public function __invoke (ContainerInterface $ container , $ instance )
14+ {
15+ if (! $ instance instanceof BaseLoggingCommand) {
16+ return ;
17+ }
18+
19+ $ instance ->init (
20+ $ container ->get ('config ' )['error-hero-module ' ],
21+ $ container ->get (Logging::class)
22+ );
23+ }
24+ }
You can’t perform that action at this time.
0 commit comments