getEntityPermissionsRoute example


  }

  /** * {@inheritdoc} */
  public function getRoutes(EntityTypeInterface $entity_type) {
    $collection = new RouteCollection();

    $entity_type_id = $entity_type->id();

    if ($entity_permissions_route = $this->getEntityPermissionsRoute($entity_type)) {
      $collection->add("entity.$entity_type_id.entity_permissions_form", $entity_permissions_route);
    }

    return $collection;
  }

  /** * Gets the entity permissions route. * * Built only for entity types that are bundles of other entity types and * define the 'entity-permissions-form' link template. * * @param \Drupal\Core\Entity\EntityTypeInterface $entity_type * The entity type. * * @return \Symfony\Component\Routing\Route|null * The generated route, if available. */

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;
  }

}
Home | Imprint | This part of the site doesn't use cookies.