You are here

class AdminHtmlRouteProvider in Entity API 8

Provides HTML routes for entities with administrative add/edit/delete pages.

Use this class if the add/edit/delete form routes should use the administrative theme.

Hierarchy

Expanded class hierarchy of AdminHtmlRouteProvider

File

src/Routing/AdminHtmlRouteProvider.php, line 13

Namespace

Drupal\entity\Routing
View source
class AdminHtmlRouteProvider extends DefaultHtmlRouteProvider {

  /**
   * {@inheritdoc}
   */
  public function getRoutes(EntityTypeInterface $entity_type) {
    $collection = parent::getRoutes($entity_type);
    $entity_type_id = $entity_type
      ->id();
    $admin_route_names = [
      "entity.{$entity_type_id}.add_page",
      "entity.{$entity_type_id}.add_form",
      "entity.{$entity_type_id}.edit_form",
      "entity.{$entity_type_id}.delete_form",
      "entity.{$entity_type_id}.delete_multiple_form",
      "entity.{$entity_type_id}.duplicate_form",
    ];
    foreach ($admin_route_names as $admin_route_name) {
      if ($route = $collection
        ->get($admin_route_name)) {
        $route
          ->setOption('_admin_route', TRUE);
      }
    }
    return $collection;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AdminHtmlRouteProvider::getRoutes public function Provides routes for entities. Overrides DefaultHtmlRouteProvider::getRoutes
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::getAddFormRoute protected function Gets the add-form route. 2
DefaultHtmlRouteProvider::getAddPageRoute protected function Gets the add page route. 2
DefaultHtmlRouteProvider::getCanonicalRoute protected function Gets the canonical route. 3
DefaultHtmlRouteProvider::getCollectionRoute protected function Gets the collection route. Overrides DefaultHtmlRouteProvider::getCollectionRoute
DefaultHtmlRouteProvider::getDeleteFormRoute protected function Gets the delete-form route. 1
DefaultHtmlRouteProvider::getDeleteMultipleFormRoute protected function Returns the delete multiple form route. 1
DefaultHtmlRouteProvider::getDuplicateFormRoute protected function Gets the duplicate-form route.
DefaultHtmlRouteProvider::getEditFormRoute protected function Gets the edit-form route. 1
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