diff 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
line wrap: on
line diff
--- a/core/modules/field_ui/src/Routing/FieldUiRouteEnhancer.php	Mon Apr 23 09:33:26 2018 +0100
+++ b/core/modules/field_ui/src/Routing/FieldUiRouteEnhancer.php	Mon Apr 23 09:46:53 2018 +0100
@@ -3,14 +3,15 @@
 namespace Drupal\field_ui\Routing;
 
 use Drupal\Core\Entity\EntityManagerInterface;
-use Drupal\Core\Routing\Enhancer\RouteEnhancerInterface;
+use Drupal\Core\Routing\EnhancerInterface;
+use Symfony\Cmf\Component\Routing\RouteObjectInterface;
 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 {
+class FieldUiRouteEnhancer implements EnhancerInterface {
 
   /**
    * The entity manager.
@@ -33,6 +34,10 @@
    * {@inheritdoc}
    */
   public function enhance(array $defaults, Request $request) {
+    if (!$this->applies($defaults[RouteObjectInterface::ROUTE_OBJECT])) {
+      return $defaults;
+    }
+
     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
@@ -46,7 +51,7 @@
   /**
    * {@inheritdoc}
    */
-  public function applies(Route $route) {
+  protected function applies(Route $route) {
     return ($route->hasOption('_field_ui'));
   }