public function MongodbServiceProvider::alter in MongoDB 8
Modifies existing service definitions.
Parameters
ContainerBuilder $container: The ContainerBuilder whose service definitions can be altered.
Overrides ServiceModifierInterface::alter
File
- src/
MongodbServiceProvider.php, line 38 - Definition of Drupal\mongodb\MongodbServiceProvider..
Class
- MongodbServiceProvider
- MongoDB service provider. Registers Mongo-related services.
Namespace
Drupal\mongodbCode
public function alter(ContainerBuilder $container) {
$mongodb_is_default = $container
->hasParameter('default_backend') && $container
->getParameter('default_backend') === 'mongodb';
if ($container
->hasDefinition('mongodb.session_manager') && ($container
->hasAlias('session_manager') && $container
->getAlias('session_manager') === 'mongodb.session_manager' || $mongodb_is_default)) {
// DrupalKernel checks whether the session_manager is initialized and
// aliases get initialized at their target so we need to replace the
// definition instead of aliasing.
$definition = $container
->getDefinition('mongodb.session_manager');
$container
->removeAlias('session_manager');
$container
->setDefinition('session_manager', $definition);
$container
->removeDefinition('mongodb.session_manager');
}
if ($mongodb_is_default && $container
->hasDefinition('block.repository')) {
#$container->setAlias('block.repository', 'block.repository.mongodb');
}
static::createIndexes($container
->get('mongo'));
}