public function StyleDiscovery::isAllowedAccess in Paragraphs Collection 8
Checks whether the given account has access to the given style name.
Parameters
array $style_definition: The style definition.
\Drupal\Core\Session\AccountProxyInterface|null $account: (optional) The account to check access for. Defaults to current user.
Return value
bool TRUE if the user has access to the style. Otherwise, FALSE.
Overrides StyleDiscoveryInterface::isAllowedAccess
1 call to StyleDiscovery::isAllowedAccess()
- StyleDiscovery::getStyleOptions in src/
StyleDiscovery.php - Gets sorted style titles keyed by their names belonging to the given group.
File
- src/
StyleDiscovery.php, line 187
Class
- StyleDiscovery
- Provides common helper methods for style discovery. @todo Create documentation for style discovery https://www.drupal.org/node/2837995
Namespace
Drupal\paragraphs_collectionCode
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);
}