public function AccessController::access in Theme permission 8
Check permission.
Parameters
Drupal\Core\Session\AccountInterface $account: Get Account.
string $theme: Theme Name.
Return value
\Drupal\Core\Access\AccessResultInterface The access result.
File
- src/
Controller/ AccessController.php, line 96
Class
- AccessController
- Access Controller.
Namespace
Drupal\theme_permission\ControllerCode
public function access(AccountInterface $account, $theme = NULL) {
if (empty($theme)) {
$theme = $this->requestStack
->getCurrentRequest()->query
->get('theme');
}
$auth = $account
->hasPermission("administer themes {$theme}");
if ($auth) {
return AccessResult::allowed();
}
else {
return AccessResult::forbidden();
}
}