class ConfigSubscriber in Group 8
Same name and namespace in other branches
- 2.0.x 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 content enabler plugin manager.
*
* @var \Drupal\group\Plugin\GroupContentEnablerManagerInterface
*/
protected $pluginManager;
/**
* Constructs a new ConfigSubscriber object.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
* @param \Drupal\group\Plugin\GroupContentEnablerManagerInterface $plugin_manager
* The group content enabler plugin manager.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager, GroupContentEnablerManagerInterface $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 content enabler plugin manager. | |
ConfigSubscriber:: |
public static | function | Returns an array of event names this subscriber wants to listen to. | |
ConfigSubscriber:: |
public | function | Causes a group role synchronization after importing config. | |
ConfigSubscriber:: |
public | function | Constructs a new ConfigSubscriber object. |