Mercurial > hg > isophonics-drupal-site
comparison core/modules/field_ui/src/Routing/FieldUiRouteEnhancer.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | 4c8ae668cc8c |
children | af1871eacc83 |
comparison
equal
deleted
inserted
replaced
13:5fb285c0d0e3 | 14:1fec387a4317 |
---|---|
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\Entity\EntityManagerInterface; |
6 use Drupal\Core\Routing\Enhancer\RouteEnhancerInterface; | 6 use Drupal\Core\Routing\EnhancerInterface; |
7 use Symfony\Cmf\Component\Routing\RouteObjectInterface; | |
7 use Symfony\Component\HttpFoundation\Request; | 8 use Symfony\Component\HttpFoundation\Request; |
8 use Symfony\Component\Routing\Route; | 9 use Symfony\Component\Routing\Route; |
9 | 10 |
10 /** | 11 /** |
11 * Enhances Field UI routes by adding proper information about the bundle name. | 12 * Enhances Field UI routes by adding proper information about the bundle name. |
12 */ | 13 */ |
13 class FieldUiRouteEnhancer implements RouteEnhancerInterface { | 14 class FieldUiRouteEnhancer implements EnhancerInterface { |
14 | 15 |
15 /** | 16 /** |
16 * The entity manager. | 17 * The entity manager. |
17 * | 18 * |
18 * @var \Drupal\Core\Entity\EntityManagerInterface | 19 * @var \Drupal\Core\Entity\EntityManagerInterface |
31 | 32 |
32 /** | 33 /** |
33 * {@inheritdoc} | 34 * {@inheritdoc} |
34 */ | 35 */ |
35 public function enhance(array $defaults, Request $request) { | 36 public function enhance(array $defaults, Request $request) { |
37 if (!$this->applies($defaults[RouteObjectInterface::ROUTE_OBJECT])) { | |
38 return $defaults; | |
39 } | |
40 | |
36 if (($bundle = $this->entityManager->getDefinition($defaults['entity_type_id'])->getBundleEntityType()) && isset($defaults[$bundle])) { | 41 if (($bundle = $this->entityManager->getDefinition($defaults['entity_type_id'])->getBundleEntityType()) && isset($defaults[$bundle])) { |
37 // Field UI forms only need the actual name of the bundle they're dealing | 42 // Field UI forms only need the actual name of the bundle they're dealing |
38 // with, not an upcasted entity object, so provide a simple way for them | 43 // with, not an upcasted entity object, so provide a simple way for them |
39 // to get it. | 44 // to get it. |
40 $defaults['bundle'] = $defaults['_raw_variables']->get($bundle); | 45 $defaults['bundle'] = $defaults['_raw_variables']->get($bundle); |
44 } | 49 } |
45 | 50 |
46 /** | 51 /** |
47 * {@inheritdoc} | 52 * {@inheritdoc} |
48 */ | 53 */ |
49 public function applies(Route $route) { | 54 protected function applies(Route $route) { |
50 return ($route->hasOption('_field_ui')); | 55 return ($route->hasOption('_field_ui')); |
51 } | 56 } |
52 | 57 |
53 } | 58 } |