You are here

class EntityExportCsvHtmlRouteProvider in Entity Export CSV 8

Provides routes for Entity export csv entities.

Hierarchy

Expanded class hierarchy of EntityExportCsvHtmlRouteProvider

See also

\Drupal\Core\Entity\Routing\AdminHtmlRouteProvider

\Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider

File

src/EntityExportCsvHtmlRouteProvider.php, line 15

Namespace

Drupal\entity_export_csv
View source
class EntityExportCsvHtmlRouteProvider extends AdminHtmlRouteProvider {

  /**
   * {@inheritdoc}
   */
  public function getRoutes(EntityTypeInterface $entity_type) {
    $collection = parent::getRoutes($entity_type);
    $entity_type_id = $entity_type
      ->id();
    if ($enable_form_route = $this
      ->getFormRoute($entity_type, 'enable')) {
      $collection
        ->add("entity.{$entity_type_id}.enable", $enable_form_route);
    }
    if ($disable_form_route = $this
      ->getFormRoute($entity_type, 'disable')) {
      $collection
        ->add("entity.{$entity_type_id}.disable", $disable_form_route);
    }
    if ($duplicate_form_route = $this
      ->getFormRoute($entity_type, 'duplicate')) {
      $collection
        ->add("entity.{$entity_type_id}.duplicate", $duplicate_form_route);
    }
    return $collection;
  }

  /**
   * Gets the form route.
   *
   * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
   *   The entity type.
   * @param string $action
   *   The action form.
   *
   * @return \Symfony\Component\Routing\Route|null
   *   The generated route, if available.
   */
  protected function getFormRoute(EntityTypeInterface $entity_type, $action) {
    $link_template = $action;
    if ($entity_type
      ->hasLinkTemplate($link_template)) {
      $entity_type_id = $entity_type
        ->id();
      $route = new Route($entity_type
        ->getLinkTemplate($link_template));
      $operation = 'default';
      if ($entity_type
        ->getFormClass($action)) {
        $operation = $action;
      }
      $route
        ->setDefaults([
        '_entity_form' => "{$entity_type_id}.{$operation}",
        '_title_callback' => '\\Drupal\\Core\\Entity\\Controller\\EntityController::editTitle',
      ])
        ->setRequirement('_entity_access', "{$entity_type_id}.update")
        ->setOption('parameters', [
        $entity_type_id => [
          'type' => 'entity:' . $entity_type_id,
        ],
      ]);
      return $route;
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AdminHtmlRouteProvider::getAddFormRoute protected function Gets the add-form route. Overrides DefaultHtmlRouteProvider::getAddFormRoute
AdminHtmlRouteProvider::getAddPageRoute protected function Gets the add page route. Overrides DefaultHtmlRouteProvider::getAddPageRoute
AdminHtmlRouteProvider::getDeleteFormRoute protected function Gets the delete-form route. Overrides DefaultHtmlRouteProvider::getDeleteFormRoute
AdminHtmlRouteProvider::getDeleteMultipleFormRoute protected function Returns the delete multiple form route. Overrides DefaultHtmlRouteProvider::getDeleteMultipleFormRoute
AdminHtmlRouteProvider::getEditFormRoute protected function Gets the edit-form route. Overrides DefaultHtmlRouteProvider::getEditFormRoute 1
DefaultHtmlRouteProvider::$entityFieldManager protected property The entity field manager.
DefaultHtmlRouteProvider::$entityTypeManager protected property The entity type manager.
DefaultHtmlRouteProvider::createInstance public static function Instantiates a new instance of this entity handler. Overrides EntityHandlerInterface::createInstance 1
DefaultHtmlRouteProvider::getCanonicalRoute protected function Gets the canonical route. 3
DefaultHtmlRouteProvider::getCollectionRoute protected function Gets the collection route. 2
DefaultHtmlRouteProvider::getEntityTypeIdKeyType protected function Gets the type of the ID key for a given entity type. 1
DefaultHtmlRouteProvider::__construct public function Constructs a new DefaultHtmlRouteProvider. 1
EntityExportCsvHtmlRouteProvider::getFormRoute protected function Gets the form route.
EntityExportCsvHtmlRouteProvider::getRoutes public function Provides routes for entities. Overrides DefaultHtmlRouteProvider::getRoutes