1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Drupal\mongodb_watchdog; |
4
|
|
|
|
5
|
|
|
use Drupal\Core\DependencyInjection\ContainerBuilder; |
|
|
|
|
6
|
|
|
use Drupal\Core\DependencyInjection\ServiceModifierInterface; |
|
|
|
|
7
|
|
|
use Symfony\Component\DependencyInjection\Reference; |
|
|
|
|
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* MongodbWatchdogServiceProvider add $formState support to forms. |
11
|
|
|
*/ |
12
|
|
|
class MongodbWatchdogServiceProvider implements ServiceModifierInterface { |
13
|
|
|
|
14
|
|
|
const KERNEL_RESOLVER = 'http_kernel.controller.argument_resolver'; |
15
|
|
|
|
16
|
|
|
// Individual resolvers. |
17
|
|
|
const RESOLVER_DEFAULT = 'argument_resolver.default'; |
18
|
|
|
const RESOLVER_FORM_STATE = 'argument_resolver.mongodb_watchdog.form_state'; |
19
|
|
|
|
20
|
|
|
/** |
21
|
|
|
* {@inheritdoc} |
22
|
|
|
*/ |
23
|
|
|
public function alter(ContainerBuilder $container): void { |
24
|
|
|
$kernelResolverDefinition = $container |
25
|
|
|
->getDefinition(static::KERNEL_RESOLVER); |
26
|
|
|
$resolvers = $kernelResolverDefinition->getArgument(1); |
27
|
|
|
$defaultIndex = $count = count($resolvers); |
28
|
|
|
/** @var \Symfony\Component\DependencyInjection\Reference $reference */ |
29
|
|
|
foreach ($resolvers as $index => $reference) { |
30
|
|
|
if ("$reference" === static::RESOLVER_DEFAULT) { |
31
|
|
|
$defaultIndex = $index; |
32
|
|
|
break; |
33
|
|
|
} |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
$formStateResolverReference = new Reference(static::RESOLVER_FORM_STATE); |
37
|
|
|
|
38
|
|
|
// If the default resolved is present, insert just before it. |
39
|
|
|
if ($defaultIndex != $count) { |
40
|
|
|
array_splice($resolvers, $defaultIndex, 0, [$formStateResolverReference]); |
41
|
|
|
} |
42
|
|
|
// Else add the formState resolver at the end of the list. |
43
|
|
|
else { |
44
|
|
|
array_push($resolvers, [$formStateResolverReference]); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
$kernelResolverDefinition->setArgument(1, $resolvers); |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
} |
51
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths