You are here

class Access in Open Social 8

Same name and namespace in other branches
  1. 8.9 modules/custom/social_language/src/Access.php \Drupal\social_language\Access
  2. 8.2 modules/custom/social_language/src/Access.php \Drupal\social_language\Access
  3. 8.3 modules/custom/social_language/src/Access.php \Drupal\social_language\Access
  4. 8.4 modules/custom/social_language/src/Access.php \Drupal\social_language\Access
  5. 8.5 modules/custom/social_language/src/Access.php \Drupal\social_language\Access
  6. 8.6 modules/custom/social_language/src/Access.php \Drupal\social_language\Access
  7. 8.7 modules/custom/social_language/src/Access.php \Drupal\social_language\Access
  8. 8.8 modules/custom/social_language/src/Access.php \Drupal\social_language\Access
  9. 10.3.x modules/custom/social_language/src/Access.php \Drupal\social_language\Access
  10. 10.0.x modules/custom/social_language/src/Access.php \Drupal\social_language\Access
  11. 10.1.x modules/custom/social_language/src/Access.php \Drupal\social_language\Access
  12. 10.2.x modules/custom/social_language/src/Access.php \Drupal\social_language\Access

Class Access.

@package Drupal\social_language

Hierarchy

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_language
View 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.
   */
  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

Namesort descending Modifiers Type Description Overrides
Access::$languageManager protected property The language manager.
Access::access public function Checks access to the overview based on permissions and translatability.
Access::__construct public function Constructs a Access object.