You are here

class DeleteMultipleRouteProvider in Entity API 8.0

Same name and namespace in other branches
  1. 8 src/Routing/DeleteMultipleRouteProvider.php \Drupal\entity\Routing\DeleteMultipleRouteProvider

Provides the HTML route for deleting multiple entities.

Hierarchy

Expanded class hierarchy of DeleteMultipleRouteProvider

File

src/Routing/DeleteMultipleRouteProvider.php, line 18
Contains \Drupal\entity\Routing\DeleteMultipleRouteProvider.

Namespace

Drupal\entity\Routing
View source
class DeleteMultipleRouteProvider implements EntityRouteProviderInterface {

  /**
   * {@inheritdoc}
   */
  public function getRoutes(EntityTypeInterface $entity_type) {
    $routes = new RouteCollection();
    if ($route = $this
      ->deleteMultipleFormRoute($entity_type)) {
      $routes
        ->add('entity.' . $entity_type
        ->id() . '.delete_multiple_form', $route);
    }
    return $routes;
  }

  /**
   * 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 deleteMultipleFormRoute(EntityTypeInterface $entity_type) {
    if ($entity_type
      ->hasLinkTemplate('delete-multiple-form')) {
      $route = new Route($entity_type
        ->getLinkTemplate('delete-multiple-form'));
      $route
        ->setDefault('_form', '\\Drupal\\entity\\Form\\DeleteMultiple');
      $route
        ->setDefault('entity_type_id', $entity_type
        ->id());
      $route
        ->setRequirement('_permission', $entity_type
        ->getAdminPermission());
      return $route;
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DeleteMultipleRouteProvider::deleteMultipleFormRoute protected function Returns the delete multiple form route.
DeleteMultipleRouteProvider::getRoutes public function Provides routes for entities. Overrides EntityRouteProviderInterface::getRoutes