Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / lib / Drupal / Core / Entity / Routing / DefaultHtmlRouteProvider.php
index fb40fd5b4ac31ec3235f0f35f259b963bc4b8122..1415a1aba66ad13459a94f28d32a4930a5a0eb24 100644 (file)
@@ -24,6 +24,7 @@ use Symfony\Component\Routing\RouteCollection;
  * - edit-form
  * - delete-form
  * - collection
+ * - delete-multiple-form
  *
  * @see \Drupal\Core\Entity\Routing\AdminHtmlRouteProvider.
  */
@@ -98,6 +99,10 @@ class DefaultHtmlRouteProvider implements EntityRouteProviderInterface, EntityHa
       $collection->add("entity.{$entity_type_id}.collection", $collection_route);
     }
 
+    if ($delete_multiple_route = $this->getDeleteMultipleFormRoute($entity_type)) {
+      $collection->add('entity.' . $entity_type->id() . '.delete_multiple_form', $delete_multiple_route);
+    }
+
     return $collection;
   }
 
@@ -253,7 +258,7 @@ class DefaultHtmlRouteProvider implements EntityRouteProviderInterface, EntityHa
       $route
         ->setDefaults([
           '_entity_form' => "{$entity_type_id}.{$operation}",
-          '_title_callback' => '\Drupal\Core\Entity\Controller\EntityController::editTitle'
+          '_title_callback' => '\Drupal\Core\Entity\Controller\EntityController::editTitle',
         ])
         ->setRequirement('_entity_access', "{$entity_type_id}.update")
         ->setOption('parameters', [
@@ -350,4 +355,23 @@ class DefaultHtmlRouteProvider implements EntityRouteProviderInterface, EntityHa
     return $field_storage_definitions[$entity_type->getKey('id')]->getType();
   }
 
+  /**
+   * Returns the delete multiple form route.
+   *
+   * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
+   *   The entity type.
+   *
+   * @return \Symfony\Component\Routing\Route|null
+   *   The generated route, if available.
+   */
+  protected function getDeleteMultipleFormRoute(EntityTypeInterface $entity_type) {
+    if ($entity_type->hasLinkTemplate('delete-multiple-form') && $entity_type->hasHandlerClass('form', 'delete-multiple-confirm')) {
+      $route = new Route($entity_type->getLinkTemplate('delete-multiple-form'));
+      $route->setDefault('_form', $entity_type->getFormClass('delete-multiple-confirm'));
+      $route->setDefault('entity_type_id', $entity_type->id());
+      $route->setRequirement('_entity_delete_multiple_access', $entity_type->id());
+      return $route;
+    }
+  }
+
 }