Skip to content

Commit e7fba80

Browse files
committed
fix module spec
1 parent 772d3ed commit e7fba80

File tree

3 files changed

+29
-18
lines changed

3 files changed

+29
-18
lines changed

config/mezzio-error-hero-module.local.php.dist

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ namespace ErrorHeroModule;
55
use App\Exception\MyException;
66
use RuntimeException;
77
use Error;
8-
use Laminas\Log\LoggerAbstractServiceFactory;
8+
use ErrorHeroModule\Command\BaseLoggingCommandInitializer;
99
use ErrorHeroModule\Middleware\Mezzio;
1010
use ErrorHeroModule\Middleware\MezzioFactory;
1111
use ErrorHeroModule\ErrorHeroModule\Middleware\Routed\Preview\ErrorPreviewAction;
@@ -14,6 +14,7 @@ use ErrorHeroModule\Handler\LoggingFactory;
1414
use ErrorHeroModule\Command\BaseLoggingCommand;
1515
use Laminas\Db\Adapter\AdapterInterface;
1616
use Laminas\Log;
17+
use Laminas\Log\LoggerAbstractServiceFactory;
1718
use Laminas\ServiceManager\Factory\InvokableFactory;
1819

1920
return [
@@ -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

config/module.config.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace ErrorHeroModule;
44

5-
use ErrorHeroModule\Command\BaseLoggingCommand;
5+
use ErrorHeroModule\Command\BaseLoggingCommandInitializer;
66
use ErrorHeroModule\Command\Preview\ErrorPreviewConsoleCommand;
77
use ErrorHeroModule\Controller\ErrorPreviewController;
88
use Laminas\Log\LoggerAbstractServiceFactory;
@@ -47,14 +47,7 @@
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

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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+
}

0 commit comments

Comments
 (0)