class MongodbWatchdogServiceProvider in MongoDB 8.2
MongodbWatchdogServiceProvider add $formState support to forms.
Hierarchy
- class \Drupal\mongodb_watchdog\MongodbWatchdogServiceProvider implements ServiceModifierInterface
Expanded class hierarchy of MongodbWatchdogServiceProvider
File
- modules/
mongodb_watchdog/ src/ MongodbWatchdogServiceProvider.php, line 12
Namespace
Drupal\mongodb_watchdogView source
class MongodbWatchdogServiceProvider implements ServiceModifierInterface {
const KERNEL_RESOLVER = 'http_kernel.controller.argument_resolver';
// Individual resolvers.
const RESOLVER_DEFAULT = 'argument_resolver.default';
const RESOLVER_FORM_STATE = 'argument_resolver.mongodb_watchdog.form_state';
/**
* {@inheritdoc}
*/
public function alter(ContainerBuilder $container) {
$kernelResolverDefinition = $container
->getDefinition(static::KERNEL_RESOLVER);
$resolvers = $kernelResolverDefinition
->getArgument(1);
$defaultIndex = $count = count($resolvers);
/** @var \Symfony\Component\DependencyInjection\Reference $reference */
foreach ($resolvers as $index => $reference) {
if ("{$reference}" === static::RESOLVER_DEFAULT) {
$defaultIndex = $index;
break;
}
}
$formStateResolverReference = new Reference(static::RESOLVER_FORM_STATE);
// If the default resolved is present, insert just before it.
if ($defaultIndex != $count) {
array_splice($resolvers, $defaultIndex, 0, [
$formStateResolverReference,
]);
}
else {
array_push($resolvers, [
$formStateResolverReference,
]);
}
$kernelResolverDefinition
->setArgument(1, $resolvers);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MongodbWatchdogServiceProvider:: |
public | function |
Modifies existing service definitions. Overrides ServiceModifierInterface:: |
|
MongodbWatchdogServiceProvider:: |
constant | |||
MongodbWatchdogServiceProvider:: |
constant | |||
MongodbWatchdogServiceProvider:: |
constant |