class Access in Open Social 10.2.x
Same name and namespace in other branches
- 8.9 modules/custom/social_language/src/Access.php \Drupal\social_language\Access
- 8 modules/custom/social_language/src/Access.php \Drupal\social_language\Access
- 8.2 modules/custom/social_language/src/Access.php \Drupal\social_language\Access
- 8.3 modules/custom/social_language/src/Access.php \Drupal\social_language\Access
- 8.4 modules/custom/social_language/src/Access.php \Drupal\social_language\Access
- 8.5 modules/custom/social_language/src/Access.php \Drupal\social_language\Access
- 8.6 modules/custom/social_language/src/Access.php \Drupal\social_language\Access
- 8.7 modules/custom/social_language/src/Access.php \Drupal\social_language\Access
- 8.8 modules/custom/social_language/src/Access.php \Drupal\social_language\Access
- 10.3.x modules/custom/social_language/src/Access.php \Drupal\social_language\Access
- 10.0.x modules/custom/social_language/src/Access.php \Drupal\social_language\Access
- 10.1.x modules/custom/social_language/src/Access.php \Drupal\social_language\Access
Class Access.
@package Drupal\social_language
Hierarchy
- class \Drupal\social_language\Access implements AccessInterface
Expanded class hierarchy of Access
1 string reference to 'Access'
- social_language.services.yml in modules/
custom/ social_language/ social_language.services.yml - modules/custom/social_language/social_language.services.yml
1 service uses Access
- social_language.access in modules/
custom/ social_language/ social_language.services.yml - Drupal\social_language\Access
File
- modules/
custom/ social_language/ src/ Access.php, line 16
Namespace
Drupal\social_languageView source
class Access implements AccessInterface {
/**
* The language manager.
*
* @var \Drupal\Core\Language\LanguageManagerInterface
*/
protected $languageManager;
/**
* Constructs a Access object.
*
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
* The language manager service.
*/
public function __construct(LanguageManagerInterface $language_manager) {
$this->languageManager = $language_manager;
}
/**
* Checks access to the overview based on permissions and translatability.
*
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
* The route_match to check against.
* @param \Drupal\Core\Session\AccountInterface $account
* The account to check access for.
* @param string $permission
* (optional) The permission.
*
* @codingStandardsIgnoreStart until https://www.drupal.org/project/coder/issues/3013953 is fixed
* @return \Drupal\Core\Access\AccessResult
* Whether to grant or deny access.
* @codingStandardsIgnoreEnd
*/
public function access(RouteMatchInterface $route_match, AccountInterface $account, $permission = NULL) {
if (count($this->languageManager
->getLanguages()) > 1) {
if (!empty($permission)) {
return AccessResult::allowedIfHasPermission($account, $permission);
}
else {
return AccessResult::allowed();
}
}
return AccessResult::forbidden();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
Access:: |
protected | property | The language manager. | |
Access:: |
public | function | Checks access to the overview based on permissions and translatability. | |
Access:: |
public | function | Constructs a Access object. |