public function ViewModeAccessCheck::access in Panelizer 8.3
Same name and namespace in other branches
- 8.5 src/Access/ViewModeAccessCheck.php \Drupal\panelizer\Access\ViewModeAccessCheck::access()
- 8.4 src/Access/ViewModeAccessCheck.php \Drupal\panelizer\Access\ViewModeAccessCheck::access()
Adapt the panelizer defaults access check to correspond to field ui.
Parameters
\Symfony\Component\Routing\Route $route: The original route definition.
\Drupal\Core\Routing\RouteMatchInterface $route_match: The route matched.
\Drupal\Core\Session\AccountInterface $account: The current user's account.
string $machine_name: The machine name of the panelizer default.
Return value
\Drupal\Core\Access\AccessResultInterface
Throws
\Exception
File
- src/
Access/ ViewModeAccessCheck.php, line 47
Class
- ViewModeAccessCheck
- An access check as an adapter around field_ui's custom access check.
Namespace
Drupal\panelizer\AccessCode
public function access(Route $route, RouteMatchInterface $route_match, AccountInterface $account, $machine_name) {
$parts = explode('__', $machine_name);
if (count($parts) != 4) {
throw new \Exception('The provided machine_name is not well formed.');
}
list($entity_type_id, $bundle, $view_mode) = $parts;
$defaults = [
'entity_type_id' => $entity_type_id,
] + $route
->getDefaults();
$route
->setDefaults($defaults);
$route
->setRequirement('_field_ui_view_mode_access', 'administer ' . $entity_type_id . ' display');
return $this->accessCheck
->access($route, $route_match, $account, $view_mode, $bundle);
}