class EditorConfigTranslationSubscriber
Same name in other branches
- 9 core/modules/editor/src/EventSubscriber/EditorConfigTranslationSubscriber.php \Drupal\editor\EventSubscriber\EditorConfigTranslationSubscriber
- 8.9.x core/modules/editor/src/EventSubscriber/EditorConfigTranslationSubscriber.php \Drupal\editor\EventSubscriber\EditorConfigTranslationSubscriber
- 10 core/modules/editor/src/EventSubscriber/EditorConfigTranslationSubscriber.php \Drupal\editor\EventSubscriber\EditorConfigTranslationSubscriber
Adds configuration names to configuration mapper on POPULATE_MAPPER event.
Hierarchy
- class \Drupal\editor\EventSubscriber\EditorConfigTranslationSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of EditorConfigTranslationSubscriber
1 string reference to 'EditorConfigTranslationSubscriber'
- editor.services.yml in core/
modules/ editor/ editor.services.yml - core/modules/editor/editor.services.yml
1 service uses EditorConfigTranslationSubscriber
File
-
core/
modules/ editor/ src/ EventSubscriber/ EditorConfigTranslationSubscriber.php, line 14
Namespace
Drupal\editor\EventSubscriberView source
class EditorConfigTranslationSubscriber implements EventSubscriberInterface {
/**
* The config factory.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected $configFactory;
/**
* EditorConfigTranslationSubscriber constructor.
*
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The factory for configuration objects.
*/
public function __construct(ConfigFactoryInterface $config_factory) {
$this->configFactory = $config_factory;
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() : array {
$events = [];
if (class_exists('Drupal\\config_translation\\Event\\ConfigTranslationEvents')) {
$events[ConfigTranslationEvents::POPULATE_MAPPER][] = [
'addConfigNames',
];
}
return $events;
}
/**
* Reacts to the populating of a configuration mapper.
*
* @param \Drupal\config_translation\Event\ConfigMapperPopulateEvent $event
* The configuration mapper event.
*/
public function addConfigNames(ConfigMapperPopulateEvent $event) {
$mapper = $event->getMapper();
if ($mapper instanceof ConfigEntityMapperInterface && $mapper->getType() == 'filter_format') {
$editor_config_name = 'editor.editor.' . $mapper->getEntity()
->id();
// Only add the text editor config if it exists, otherwise we assume no
// editor has been set for this text format.
if (!$this->configFactory
->get($editor_config_name)
->isNew()) {
$mapper->addConfigName($editor_config_name);
}
}
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
EditorConfigTranslationSubscriber::$configFactory | protected | property | The config factory. |
EditorConfigTranslationSubscriber::addConfigNames | public | function | Reacts to the populating of a configuration mapper. |
EditorConfigTranslationSubscriber::getSubscribedEvents | public static | function | |
EditorConfigTranslationSubscriber::__construct | public | function | EditorConfigTranslationSubscriber constructor. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.