comparison core/modules/config_translation/src/ConfigEntityMapper.php @ 5:12f9dff5fda9 tip

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:34:47 +0100
parents a9cd425dd02b
children
comparison
equal deleted inserted replaced
4:a9cd425dd02b 5:12f9dff5fda9
3 namespace Drupal\config_translation; 3 namespace Drupal\config_translation;
4 4
5 use Drupal\Core\Config\ConfigFactoryInterface; 5 use Drupal\Core\Config\ConfigFactoryInterface;
6 use Drupal\Core\Config\Entity\ConfigEntityInterface; 6 use Drupal\Core\Config\Entity\ConfigEntityInterface;
7 use Drupal\Core\Config\TypedConfigManagerInterface; 7 use Drupal\Core\Config\TypedConfigManagerInterface;
8 use Drupal\Core\Entity\EntityManagerInterface; 8 use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait;
9 use Drupal\Core\Entity\EntityTypeManagerInterface;
9 use Drupal\Core\Language\LanguageManagerInterface; 10 use Drupal\Core\Language\LanguageManagerInterface;
10 use Drupal\Core\Routing\RouteMatchInterface; 11 use Drupal\Core\Routing\RouteMatchInterface;
11 use Drupal\Core\Routing\RouteProviderInterface; 12 use Drupal\Core\Routing\RouteProviderInterface;
12 use Drupal\Core\StringTranslation\TranslationInterface; 13 use Drupal\Core\StringTranslation\TranslationInterface;
13 use Drupal\Core\Url; 14 use Drupal\Core\Url;
19 /** 20 /**
20 * Configuration mapper for configuration entities. 21 * Configuration mapper for configuration entities.
21 */ 22 */
22 class ConfigEntityMapper extends ConfigNamesMapper { 23 class ConfigEntityMapper extends ConfigNamesMapper {
23 24
25 use DeprecatedServicePropertyTrait;
26
27 /**
28 * {@inheritdoc}
29 */
30 protected $deprecatedProperties = [
31 'entityManager' => 'entity.manager',
32 ];
33
24 /** 34 /**
25 * The entity manager. 35 * The entity manager.
26 * 36 *
27 * @var \Drupal\Core\Entity\EntityManagerInterface 37 * @var \Drupal\Core\Entity\EntityTypeManagerInterface
28 */ 38 */
29 protected $entityManager; 39 protected $entityTypeManager;
30 40
31 /** 41 /**
32 * Configuration entity type name. 42 * Configuration entity type name.
33 * 43 *
34 * @var string 44 * @var string
68 * The mapper plugin discovery service. 78 * The mapper plugin discovery service.
69 * @param \Drupal\Core\Routing\RouteProviderInterface $route_provider 79 * @param \Drupal\Core\Routing\RouteProviderInterface $route_provider
70 * The route provider. 80 * The route provider.
71 * @param \Drupal\Core\StringTranslation\TranslationInterface $translation_manager 81 * @param \Drupal\Core\StringTranslation\TranslationInterface $translation_manager
72 * The string translation manager. 82 * The string translation manager.
73 * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager 83 * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
74 * The entity manager. 84 * The entity manager.
75 * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager 85 * @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
76 * The language manager. 86 * The language manager.
77 * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher 87 * @param \Symfony\Component\EventDispatcher\EventDispatcherInterface $event_dispatcher
78 * The event dispatcher. 88 * The event dispatcher.
79 */ 89 */
80 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 $translation_manager, EntityManagerInterface $entity_manager, LanguageManagerInterface $language_manager, EventDispatcherInterface $event_dispatcher = NULL) { 90 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 $translation_manager, EntityTypeManagerInterface $entity_type_manager, LanguageManagerInterface $language_manager, EventDispatcherInterface $event_dispatcher = NULL) {
81 parent::__construct($plugin_id, $plugin_definition, $config_factory, $typed_config, $locale_config_manager, $config_mapper_manager, $route_provider, $translation_manager, $language_manager, $event_dispatcher); 91 parent::__construct($plugin_id, $plugin_definition, $config_factory, $typed_config, $locale_config_manager, $config_mapper_manager, $route_provider, $translation_manager, $language_manager, $event_dispatcher);
82 $this->setType($plugin_definition['entity_type']); 92 $this->setType($plugin_definition['entity_type']);
83 93
84 $this->entityManager = $entity_manager; 94 $this->entityTypeManager = $entity_type_manager;
85 } 95 }
86 96
87 /** 97 /**
88 * {@inheritdoc} 98 * {@inheritdoc}
89 */ 99 */
90 public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { 100 public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
91 // Note that we ignore the plugin $configuration because mappers have 101 // Note that we ignore the plugin $configuration because mappers have
92 // nothing to configure in themselves. 102 // nothing to configure in themselves.
93 return new static ( 103 return new static(
94 $plugin_id, 104 $plugin_id,
95 $plugin_definition, 105 $plugin_definition,
96 $container->get('config.factory'), 106 $container->get('config.factory'),
97 $container->get('config.typed'), 107 $container->get('config.typed'),
98 $container->get('locale.config_manager'), 108 $container->get('locale.config_manager'),
99 $container->get('plugin.manager.config_translation.mapper'), 109 $container->get('plugin.manager.config_translation.mapper'),
100 $container->get('router.route_provider'), 110 $container->get('router.route_provider'),
101 $container->get('string_translation'), 111 $container->get('string_translation'),
102 $container->get('entity.manager'), 112 $container->get('entity_type.manager'),
103 $container->get('language_manager'), 113 $container->get('language_manager'),
104 $container->get('event_dispatcher') 114 $container->get('event_dispatcher')
105 ); 115 );
106 } 116 }
107 117
150 // possibly existing list of names. This allows modules to alter the entity 160 // possibly existing list of names. This allows modules to alter the entity
151 // page with more names if form altering added more configuration to an 161 // page with more names if form altering added more configuration to an
152 // entity. This is not a Drupal 8 best practice (ideally the configuration 162 // entity. This is not a Drupal 8 best practice (ideally the configuration
153 // would have pluggable components), but this may happen as well. 163 // would have pluggable components), but this may happen as well.
154 /** @var \Drupal\Core\Config\Entity\ConfigEntityTypeInterface $entity_type_info */ 164 /** @var \Drupal\Core\Config\Entity\ConfigEntityTypeInterface $entity_type_info */
155 $entity_type_info = $this->entityManager->getDefinition($this->entityType); 165 $entity_type_info = $this->entityTypeManager->getDefinition($this->entityType);
156 $this->addConfigName($entity_type_info->getConfigPrefix() . '.' . $entity->id()); 166 $this->addConfigName($entity_type_info->getConfigPrefix() . '.' . $entity->id());
157 167
158 return TRUE; 168 return TRUE;
159 } 169 }
160 170
206 216
207 /** 217 /**
208 * {@inheritdoc} 218 * {@inheritdoc}
209 */ 219 */
210 public function getTypeName() { 220 public function getTypeName() {
211 $entity_type_info = $this->entityManager->getDefinition($this->entityType); 221 $entity_type_info = $this->entityTypeManager->getDefinition($this->entityType);
212 return $entity_type_info->getLabel(); 222 return $entity_type_info->getLabel();
213 } 223 }
214 224
215 /** 225 /**
216 * {@inheritdoc} 226 * {@inheritdoc}
217 */ 227 */
218 public function getTypeLabel() { 228 public function getTypeLabel() {
219 $entityType = $this->entityManager->getDefinition($this->entityType); 229 $entityType = $this->entityTypeManager->getDefinition($this->entityType);
220 return $entityType->getLabel(); 230 return $entityType->getLabel();
221 } 231 }
222 232
223 /** 233 /**
224 * {@inheritdoc} 234 * {@inheritdoc}