AdminHtmlRouteProvider.php

Same filename in other branches
  1. 8.9.x core/lib/Drupal/Core/Entity/Routing/AdminHtmlRouteProvider.php
  2. 10 core/lib/Drupal/Core/Entity/Routing/AdminHtmlRouteProvider.php
  3. 11.x core/lib/Drupal/Core/Entity/Routing/AdminHtmlRouteProvider.php

Namespace

Drupal\Core\Entity\Routing

File

core/lib/Drupal/Core/Entity/Routing/AdminHtmlRouteProvider.php

View source
<?php

namespace Drupal\Core\Entity\Routing;

use Drupal\Core\Entity\EntityTypeInterface;

/**
 * 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.
 *
 * @see \Drupal\Core\Entity\Routing\DefaultHtmlRouteProvider.
 */
class AdminHtmlRouteProvider extends DefaultHtmlRouteProvider {
    
    /**
     * {@inheritdoc}
     */
    protected function getAddPageRoute(EntityTypeInterface $entity_type) {
        if ($route = parent::getAddPageRoute($entity_type)) {
            $route->setOption('_admin_route', TRUE);
            return $route;
        }
    }
    
    /**
     * {@inheritdoc}
     */
    protected function getAddFormRoute(EntityTypeInterface $entity_type) {
        if ($route = parent::getAddFormRoute($entity_type)) {
            $route->setOption('_admin_route', TRUE);
            return $route;
        }
    }
    
    /**
     * {@inheritdoc}
     */
    protected function getEditFormRoute(EntityTypeInterface $entity_type) {
        if ($route = parent::getEditFormRoute($entity_type)) {
            $route->setOption('_admin_route', TRUE);
            return $route;
        }
    }
    
    /**
     * {@inheritdoc}
     */
    protected function getDeleteFormRoute(EntityTypeInterface $entity_type) {
        if ($route = parent::getDeleteFormRoute($entity_type)) {
            $route->setOption('_admin_route', TRUE);
            return $route;
        }
    }
    
    /**
     * {@inheritdoc}
     */
    protected function getDeleteMultipleFormRoute(EntityTypeInterface $entity_type) {
        if ($route = parent::getDeleteMultipleFormRoute($entity_type)) {
            $route->setOption('_admin_route', TRUE);
            return $route;
        }
    }

}

Classes

Title Deprecated Summary
AdminHtmlRouteProvider Provides HTML routes for entities with administrative add/edit/delete pages.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.