3 namespace Drupal\entity\Routing;
5 use Drupal\Core\Entity\EntityTypeInterface;
6 use Drupal\Core\Entity\Routing\EntityRouteProviderInterface;
7 use Symfony\Component\Routing\Route;
8 use Symfony\Component\Routing\RouteCollection;
11 * Provides the HTML route for deleting multiple entities.
13 * @deprecated Since Drupal 8.6.x the core DefaultHtmlRouteProvider provides
14 * the route for any entity type with a "delete-multiple-form" link template
15 * and a "delete-multiple-confirm" form.
17 class DeleteMultipleRouteProvider implements EntityRouteProviderInterface {
22 public function getRoutes(EntityTypeInterface $entity_type) {
23 $routes = new RouteCollection();
24 if ($route = $this->deleteMultipleFormRoute($entity_type)) {
25 $routes->add('entity.' . $entity_type->id() . '.delete_multiple_form', $route);
32 * Returns the delete multiple form route.
34 * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
37 * @return \Symfony\Component\Routing\Route|null
38 * The generated route, if available.
40 protected function deleteMultipleFormRoute(EntityTypeInterface $entity_type) {
41 // Core requires a "delete-multiple-confirm" form to be declared as well,
42 // if it's missing, it's safe to assume that the entity type is still
43 // relying on previous Entity API contrib behavior.
44 if ($entity_type->hasLinkTemplate('delete-multiple-form') && !$entity_type->hasHandlerClass('form', 'delete-multiple-confirm')) {
45 $route = new Route($entity_type->getLinkTemplate('delete-multiple-form'));
46 $route->setDefault('_form', '\Drupal\entity\Form\DeleteMultipleForm');
47 $route->setDefault('entity_type_id', $entity_type->id());
48 $route->setRequirement('_entity_delete_multiple_access', $entity_type->id());