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 class DeleteMultipleRouteProvider implements EntityRouteProviderInterface {
18 public function getRoutes(EntityTypeInterface $entity_type) {
19 $routes = new RouteCollection();
20 if ($route = $this->deleteMultipleFormRoute($entity_type)) {
21 $routes->add('entity.' . $entity_type->id() . '.delete_multiple_form', $route);
28 * Returns the delete multiple form route.
30 * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
33 * @return \Symfony\Component\Routing\Route|null
34 * The generated route, if available.
36 protected function deleteMultipleFormRoute(EntityTypeInterface $entity_type) {
37 if ($entity_type->hasLinkTemplate('delete-multiple-form')) {
38 $route = new Route($entity_type->getLinkTemplate('delete-multiple-form'));
39 $route->setDefault('_form', '\Drupal\entity\Form\DeleteMultipleForm');
40 $route->setDefault('entity_type_id', $entity_type->id());
41 $route->setRequirement('_entity_delete_multiple_access', $entity_type->id());