class GroupServiceProvider in Group 2.0.x
Same name and namespace in other branches
- 8 src/GroupServiceProvider.php \Drupal\group\GroupServiceProvider
Alters existing services for the Group module.
Hierarchy
- class \Drupal\Core\DependencyInjection\ServiceProviderBase implements ServiceModifierInterface, ServiceProviderInterface
- class \Drupal\group\GroupServiceProvider
Expanded class hierarchy of GroupServiceProvider
File
- src/
GroupServiceProvider.php, line 14
Namespace
Drupal\groupView source
class GroupServiceProvider extends ServiceProviderBase {
/**
* {@inheritdoc}
*/
public function alter(ContainerBuilder $container) {
// Ensures you can update to enable VariationCache without the container
// choking on the variation_cache_factory service no longer being there.
if (!$container
->hasDefinition('variation_cache_factory')) {
$definition = new Definition('\\Drupal\\group\\VariationCacheFactoryUpdateFix');
$container
->setDefinition('variation_cache_factory', $definition);
}
// Automatically create missing handler services for GroupRelation plugins.
$modules = $container
->getParameter('container.modules');
$discovery = new AnnotatedClassDiscovery('Plugin/Group/Relation', $container
->get('container.namespaces'), 'Drupal\\group\\Annotation\\GroupRelation', []);
$handlers = [
'access_control' => 'Drupal\\group\\Plugin\\Group\\RelationHandler\\EmptyAccessControl',
'permission_provider' => 'Drupal\\group\\Plugin\\Group\\RelationHandler\\EmptyPermissionProvider',
'post_install' => 'Drupal\\group\\Plugin\\Group\\RelationHandler\\EmptyPostInstall',
];
foreach ($discovery
->getDefinitions() as $plugin_id => $definition) {
// Skip plugins that whose provider is not installed.
// @todo Change this when definitions become classes.
if (!isset($modules[$definition['provider']])) {
continue;
}
foreach ($handlers as $handler => $handler_class) {
$service_name = "group.relation_handler.{$handler}.{$plugin_id}";
if (!$container
->has($service_name)) {
// Define the service and pass it the default one to decorate.
$definition = new Definition($handler_class, [
new Reference("group.relation_handler.{$handler}"),
]);
$definition
->setShared(FALSE);
$container
->setDefinition($service_name, $definition);
}
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
GroupServiceProvider:: |
public | function |
Modifies existing service definitions. Overrides ServiceProviderBase:: |
|
ServiceProviderBase:: |
public | function |
Registers services to the container. Overrides ServiceProviderInterface:: |
1 |