Mercurial > hg > isophonics-drupal-site
comparison core/modules/config_translation/src/ConfigNamesMapper.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 7a779792577d |
children | af1871eacc83 |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
1 <?php | 1 <?php |
2 | 2 |
3 namespace Drupal\config_translation; | 3 namespace Drupal\config_translation; |
4 | 4 |
5 use Drupal\config_translation\Event\ConfigMapperPopulateEvent; | |
6 use Drupal\config_translation\Event\ConfigTranslationEvents; | |
5 use Drupal\config_translation\Exception\ConfigMapperLanguageException; | 7 use Drupal\config_translation\Exception\ConfigMapperLanguageException; |
6 use Drupal\Core\Config\ConfigFactoryInterface; | 8 use Drupal\Core\Config\ConfigFactoryInterface; |
7 use Drupal\Core\Config\TypedConfigManagerInterface; | 9 use Drupal\Core\Config\TypedConfigManagerInterface; |
8 use Drupal\Core\Language\LanguageInterface; | 10 use Drupal\Core\Language\LanguageInterface; |
9 use Drupal\Core\Language\LanguageManagerInterface; | 11 use Drupal\Core\Language\LanguageManagerInterface; |
13 use Drupal\Core\StringTranslation\TranslationInterface; | 15 use Drupal\Core\StringTranslation\TranslationInterface; |
14 use Drupal\Core\Plugin\ContainerFactoryPluginInterface; | 16 use Drupal\Core\Plugin\ContainerFactoryPluginInterface; |
15 use Drupal\Core\Url; | 17 use Drupal\Core\Url; |
16 use Drupal\locale\LocaleConfigManager; | 18 use Drupal\locale\LocaleConfigManager; |
17 use Symfony\Component\DependencyInjection\ContainerInterface; | 19 use Symfony\Component\DependencyInjection\ContainerInterface; |
20 use Symfony\Component\EventDispatcher\EventDispatcherInterface; | |
18 use Symfony\Component\Routing\Route; | 21 use Symfony\Component\Routing\Route; |
19 use Symfony\Component\Routing\RouteCollection; | 22 use Symfony\Component\Routing\RouteCollection; |
20 | 23 |
21 /** | 24 /** |
22 * Configuration mapper base implementation. | 25 * Configuration mapper base implementation. |
83 * The language manager. | 86 * The language manager. |
84 * | 87 * |
85 * @var \Drupal\Core\Language\LanguageManagerInterface | 88 * @var \Drupal\Core\Language\LanguageManagerInterface |
86 */ | 89 */ |
87 protected $languageManager; | 90 protected $languageManager; |
91 | |
92 /** | |
93 * The event dispatcher. | |
94 * | |
95 * @var \Symfony\Component\EventDispatcher\EventDispatcherInterface | |
96 */ | |
97 protected $eventDispatcher; | |
88 | 98 |
89 /** | 99 /** |
90 * Constructs a ConfigNamesMapper. | 100 * Constructs a ConfigNamesMapper. |
91 * | 101 * |
92 * @param $plugin_id | 102 * @param $plugin_id |
113 * The route provider. | 123 * The route provider. |
114 * @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation | 124 * @param \Drupal\Core\StringTranslation\TranslationInterface $string_translation |
115 * The string translation manager. | 125 * The string translation manager. |
116 * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager | 126 * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager |
117 * The language manager. | 127 * The language manager. |
128 * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher | |
129 * (optional) The event dispatcher. | |
118 * | 130 * |
119 * @throws \Symfony\Component\Routing\Exception\RouteNotFoundException | 131 * @throws \Symfony\Component\Routing\Exception\RouteNotFoundException |
120 * Throws an exception if the route specified by the 'base_route_name' in | 132 * Throws an exception if the route specified by the 'base_route_name' in |
121 * the plugin definition could not be found by the route provider. | 133 * the plugin definition could not be found by the route provider. |
122 */ | 134 */ |
123 public function __construct($plugin_id, $plugin_definition, ConfigFactoryInterface $config_factory, TypedConfigManagerInterface $typed_config, LocaleConfigManager $locale_config_manager, ConfigMapperManagerInterface $config_mapper_manager, RouteProviderInterface $route_provider, TranslationInterface $string_translation, LanguageManagerInterface $language_manager) { | 135 public function __construct($plugin_id, $plugin_definition, ConfigFactoryInterface $config_factory, TypedConfigManagerInterface $typed_config, LocaleConfigManager $locale_config_manager, ConfigMapperManagerInterface $config_mapper_manager, RouteProviderInterface $route_provider, TranslationInterface $string_translation, LanguageManagerInterface $language_manager, EventDispatcherInterface $event_dispatcher = NULL) { |
124 $this->pluginId = $plugin_id; | 136 $this->pluginId = $plugin_id; |
125 $this->pluginDefinition = $plugin_definition; | 137 $this->pluginDefinition = $plugin_definition; |
126 $this->routeProvider = $route_provider; | 138 $this->routeProvider = $route_provider; |
127 | 139 |
128 $this->configFactory = $config_factory; | 140 $this->configFactory = $config_factory; |
130 $this->localeConfigManager = $locale_config_manager; | 142 $this->localeConfigManager = $locale_config_manager; |
131 $this->configMapperManager = $config_mapper_manager; | 143 $this->configMapperManager = $config_mapper_manager; |
132 | 144 |
133 $this->stringTranslation = $string_translation; | 145 $this->stringTranslation = $string_translation; |
134 $this->languageManager = $language_manager; | 146 $this->languageManager = $language_manager; |
147 $this->eventDispatcher = $event_dispatcher ?: \Drupal::service('event_dispatcher'); | |
135 } | 148 } |
136 | 149 |
137 /** | 150 /** |
138 * {@inheritdoc} | 151 * {@inheritdoc} |
139 */ | 152 */ |
147 $container->get('config.typed'), | 160 $container->get('config.typed'), |
148 $container->get('locale.config_manager'), | 161 $container->get('locale.config_manager'), |
149 $container->get('plugin.manager.config_translation.mapper'), | 162 $container->get('plugin.manager.config_translation.mapper'), |
150 $container->get('router.route_provider'), | 163 $container->get('router.route_provider'), |
151 $container->get('string_translation'), | 164 $container->get('string_translation'), |
152 $container->get('language_manager') | 165 $container->get('language_manager'), |
166 $container->get('event_dispatcher') | |
153 ); | 167 ); |
154 } | 168 } |
155 | 169 |
156 /** | 170 /** |
157 * {@inheritdoc} | 171 * {@inheritdoc} |
366 /** | 380 /** |
367 * {@inheritdoc} | 381 * {@inheritdoc} |
368 */ | 382 */ |
369 public function populateFromRouteMatch(RouteMatchInterface $route_match) { | 383 public function populateFromRouteMatch(RouteMatchInterface $route_match) { |
370 $this->langcode = $route_match->getParameter('langcode'); | 384 $this->langcode = $route_match->getParameter('langcode'); |
385 | |
386 $event = new ConfigMapperPopulateEvent($this, $route_match); | |
387 $this->eventDispatcher->dispatch(ConfigTranslationEvents::POPULATE_MAPPER, $event); | |
371 } | 388 } |
372 | 389 |
373 /** | 390 /** |
374 * {@inheritdoc} | 391 * {@inheritdoc} |
375 */ | 392 */ |