EntityPermissionsRouteProviderWithCheck.php

Same filename in other branches
  1. 9 core/modules/user/src/Entity/EntityPermissionsRouteProviderWithCheck.php
  2. 11.x core/modules/user/src/Entity/EntityPermissionsRouteProviderWithCheck.php

Namespace

Drupal\user\Entity

File

core/modules/user/src/Entity/EntityPermissionsRouteProviderWithCheck.php

View source
<?php

namespace Drupal\user\Entity;

use Drupal\Core\Entity\EntityTypeInterface;
use Symfony\Component\Routing\Route;

/**
 * Provides routes for the entity permissions form with a custom access check.
 *
 * Use this class or EntityPermissionsRouteProvider as a route provider for an
 * entity type such as BlockContentType. Either one will provide routes for the
 * entity permissions form. This class provides a custom access check: it denies
 * access if there are no entity-specific permissions. If you know that each
 * entity has permissions, or if the check is too expensive, then use
 * EntityPermissionsRouteProvider instead of this class.
 */
class EntityPermissionsRouteProviderWithCheck extends EntityPermissionsRouteProvider {
    
    /**
     * {@inheritdoc}
     */
    protected function getEntityPermissionsRoute(EntityTypeInterface $entity_type) : ?Route {
        $route = parent::getEntityPermissionsRoute($entity_type);
        if ($route) {
            $route->setRequirement('_custom_access', '\\Drupal\\user\\Form\\EntityPermissionsForm::access');
        }
        return $route;
    }

}

Classes

Title Deprecated Summary
EntityPermissionsRouteProviderWithCheck Provides routes for the entity permissions form with a custom access check.

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