class ConfigSubscriber in Group 2.0.x
Same name and namespace in other branches
- 8 src/EventSubscriber/ConfigSubscriber.php \Drupal\group\EventSubscriber\ConfigSubscriber
Reacts to configuration imports.
Hierarchy
- class \Drupal\group\EventSubscriber\ConfigSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of ConfigSubscriber
1 string reference to 'ConfigSubscriber'
1 service uses ConfigSubscriber
File
- src/
EventSubscriber/ ConfigSubscriber.php, line 14
Namespace
Drupal\group\EventSubscriberView source
class ConfigSubscriber implements EventSubscriberInterface {
/**
* The entity type manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* The group relation plugin manager.
*
* @var \Drupal\group\Plugin\Group\Relation\GroupRelationManagerInterface
*/
protected $pluginManager;
/**
* Constructs a new ConfigSubscriber object.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
* @param \Drupal\group\Plugin\Group\Relation\GroupRelationManagerInterface $plugin_manager
* The group relation plugin manager.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager, GroupRelationManagerInterface $plugin_manager) {
$this->entityTypeManager = $entity_type_manager;
$this->pluginManager = $plugin_manager;
}
/**
* Causes a group role synchronization after importing config.
*
* @param \Drupal\Core\Config\ConfigImporterEvent $event
* The configuration event.
*/
public function onConfigImport(ConfigImporterEvent $event) {
$this->pluginManager
->installEnforced();
/** @var \Drupal\group\Entity\Storage\GroupRoleStorageInterface $storage */
$storage = $this->entityTypeManager
->getStorage('group_role');
$storage
->createInternal();
$storage
->createSynchronized();
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events[ConfigEvents::IMPORT] = 'onConfigImport';
return $events;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
ConfigSubscriber:: |
protected | property | The entity type manager. | |
ConfigSubscriber:: |
protected | property | The group relation plugin manager. | |
ConfigSubscriber:: |
public static | function | ||
ConfigSubscriber:: |
public | function | Causes a group role synchronization after importing config. | |
ConfigSubscriber:: |
public | function | Constructs a new ConfigSubscriber object. |