comparison core/modules/field_ui/src/Routing/FieldUiRouteEnhancer.php @ 5:12f9dff5fda9 tip

Update to Drupal core 8.7.1
author Chris Cannam
date Thu, 09 May 2019 15:34:47 +0100
parents c75dbcec494b
children
comparison
equal deleted inserted replaced
4:a9cd425dd02b 5:12f9dff5fda9
1 <?php 1 <?php
2 2
3 namespace Drupal\field_ui\Routing; 3 namespace Drupal\field_ui\Routing;
4 4
5 use Drupal\Core\Entity\EntityManagerInterface; 5 use Drupal\Core\DependencyInjection\DeprecatedServicePropertyTrait;
6 use Drupal\Core\Routing\EnhancerInterface; 6 use Drupal\Core\Routing\EnhancerInterface;
7 use Symfony\Cmf\Component\Routing\RouteObjectInterface; 7 use Symfony\Cmf\Component\Routing\RouteObjectInterface;
8 use Drupal\Core\Entity\EntityTypeManagerInterface;
8 use Symfony\Component\HttpFoundation\Request; 9 use Symfony\Component\HttpFoundation\Request;
9 use Symfony\Component\Routing\Route; 10 use Symfony\Component\Routing\Route;
10 11
11 /** 12 /**
12 * Enhances Field UI routes by adding proper information about the bundle name. 13 * Enhances Field UI routes by adding proper information about the bundle name.
13 */ 14 */
14 class FieldUiRouteEnhancer implements EnhancerInterface { 15 class FieldUiRouteEnhancer implements EnhancerInterface {
16 use DeprecatedServicePropertyTrait;
15 17
16 /** 18 /**
17 * The entity manager. 19 * {@inheritdoc}
20 */
21 protected $deprecatedProperties = ['entityManager' => 'entity.manager'];
22
23 /**
24 * The entity type manager service.
18 * 25 *
19 * @var \Drupal\Core\Entity\EntityManagerInterface 26 * @var \Drupal\Core\Entity\EntityTypeManagerInterface
20 */ 27 */
21 protected $entityManager; 28 protected $entityTypeManager;
22 29
23 /** 30 /**
24 * Constructs a FieldUiRouteEnhancer object. 31 * Constructs a FieldUiRouteEnhancer object.
25 * 32 *
26 * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager 33 * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
27 * The entity manager. 34 * The entity type manager service.
28 */ 35 */
29 public function __construct(EntityManagerInterface $entity_manager) { 36 public function __construct(EntityTypeManagerInterface $entity_type_manager) {
30 $this->entityManager = $entity_manager; 37 $this->entityTypeManager = $entity_type_manager;
31 } 38 }
32 39
33 /** 40 /**
34 * {@inheritdoc} 41 * {@inheritdoc}
35 */ 42 */
36 public function enhance(array $defaults, Request $request) { 43 public function enhance(array $defaults, Request $request) {
37 if (!$this->applies($defaults[RouteObjectInterface::ROUTE_OBJECT])) { 44 if (!$this->applies($defaults[RouteObjectInterface::ROUTE_OBJECT])) {
38 return $defaults; 45 return $defaults;
39 } 46 }
40 47 if (($bundle = $this->entityTypeManager->getDefinition($defaults['entity_type_id'])->getBundleEntityType()) && isset($defaults[$bundle])) {
41 if (($bundle = $this->entityManager->getDefinition($defaults['entity_type_id'])->getBundleEntityType()) && isset($defaults[$bundle])) {
42 // Field UI forms only need the actual name of the bundle they're dealing 48 // Field UI forms only need the actual name of the bundle they're dealing
43 // with, not an upcasted entity object, so provide a simple way for them 49 // with, not an upcasted entity object, so provide a simple way for them
44 // to get it. 50 // to get it.
45 $defaults['bundle'] = $defaults['_raw_variables']->get($bundle); 51 $defaults['bundle'] = $defaults['_raw_variables']->get($bundle);
46 } 52 }