Checks whether the given account has access to the given style name.
array $style_definition: The style definition.
\Drupal\Core\Session\AccountProxyInterface|null $account: (optional) The account to check access for. Defaults to current user.
bool TRUE if the user has access to the style. Otherwise, FALSE.
Overrides StyleDiscoveryInterface::isAllowedAccess
public function isAllowedAccess(array $style_definition, AccountProxyInterface $account = NULL) {
// The style does not define permission property. Allow access.
if (empty($style_definition['permission']) || $style_definition['permission'] !== TRUE) {
return TRUE;
}
$account = $account ?: $this->currentUser;
$style_permission = 'use ' . $style_definition['name'] . ' style';
// Check whether the user has a dedicated style permission.
return $account
->hasPermission($style_permission);
}