ConfigTranslationTestSubscriber.php

Same filename in other branches
  1. 9 core/modules/config_translation/tests/modules/config_translation_test/src/EventSubscriber/ConfigTranslationTestSubscriber.php
  2. 8.9.x core/modules/config_translation/tests/modules/config_translation_test/src/EventSubscriber/ConfigTranslationTestSubscriber.php
  3. 11.x core/modules/config_translation/tests/modules/config_translation_test/src/EventSubscriber/ConfigTranslationTestSubscriber.php

Namespace

Drupal\config_translation_test\EventSubscriber

File

core/modules/config_translation/tests/modules/config_translation_test/src/EventSubscriber/ConfigTranslationTestSubscriber.php

View source
<?php

namespace Drupal\config_translation_test\EventSubscriber;

use Drupal\config_translation\Event\ConfigMapperPopulateEvent;
use Drupal\config_translation\Event\ConfigTranslationEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

/**
 * Adds configuration names to configuration mapper on POPULATE_MAPPER event.
 */
class ConfigTranslationTestSubscriber implements EventSubscriberInterface {
    
    /**
     * {@inheritdoc}
     */
    public static function getSubscribedEvents() : array {
        return [
            ConfigTranslationEvents::POPULATE_MAPPER => [
                [
                    'addConfigNames',
                ],
            ],
        ];
    }
    
    /**
     * 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->getBaseRouteName() === 'system.site_information_settings' && $mapper->getLangcode() === 'en') {
            $mapper->addConfigName('config_translation_test.content');
        }
    }

}

Classes

Title Deprecated Summary
ConfigTranslationTestSubscriber Adds configuration names to configuration mapper on POPULATE_MAPPER event.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.