You are here

class EntityPermissionsRouteProviderWithCheck in Drupal 10

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.

Hierarchy

Expanded class hierarchy of EntityPermissionsRouteProviderWithCheck

File

core/modules/user/src/Entity/EntityPermissionsRouteProviderWithCheck.php, line 18

Namespace

Drupal\user\Entity
View source
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;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EntityPermissionsRouteProvider::$entityTypeManager protected property The entity type manager.
EntityPermissionsRouteProvider::createInstance public static function Instantiates a new instance of this entity handler. Overrides EntityHandlerInterface::createInstance
EntityPermissionsRouteProvider::getRoutes public function Provides routes for entities. Overrides EntityRouteProviderInterface::getRoutes
EntityPermissionsRouteProvider::__construct public function Constructs a new EntityPermissionsRouteProvider.
EntityPermissionsRouteProviderWithCheck::getEntityPermissionsRoute protected function Gets the entity permissions route. Overrides EntityPermissionsRouteProvider::getEntityPermissionsRoute