Mercurial > hg > isophonics-drupal-site
view core/modules/field_ui/src/Routing/FieldUiRouteEnhancer.php @ 13:5fb285c0d0e3
Update Drupal core to 8.4.7 via Composer. Security update; I *think* we've
been lucky to get away with this so far, as we don't support self-registration
which seems to be used by the so-called "drupalgeddon 2" attack that 8.4.5
was vulnerable to.
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:33:26 +0100 |
parents | 4c8ae668cc8c |
children | 1fec387a4317 |
line wrap: on
line source
<?php namespace Drupal\field_ui\Routing; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Routing\Enhancer\RouteEnhancerInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Route; /** * Enhances Field UI routes by adding proper information about the bundle name. */ class FieldUiRouteEnhancer implements RouteEnhancerInterface { /** * The entity manager. * * @var \Drupal\Core\Entity\EntityManagerInterface */ protected $entityManager; /** * Constructs a FieldUiRouteEnhancer object. * * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager * The entity manager. */ public function __construct(EntityManagerInterface $entity_manager) { $this->entityManager = $entity_manager; } /** * {@inheritdoc} */ public function enhance(array $defaults, Request $request) { if (($bundle = $this->entityManager->getDefinition($defaults['entity_type_id'])->getBundleEntityType()) && isset($defaults[$bundle])) { // Field UI forms only need the actual name of the bundle they're dealing // with, not an upcasted entity object, so provide a simple way for them // to get it. $defaults['bundle'] = $defaults['_raw_variables']->get($bundle); } return $defaults; } /** * {@inheritdoc} */ public function applies(Route $route) { return ($route->hasOption('_field_ui')); } }