You are here

class ContentAccessAdminSettingsAccessCheck in Content Access 8

Class ContentAccessAdminSettingsAccessCheck.

Determines access to routes based on permissions defined via $module.permissions.yml files.

Hierarchy

Expanded class hierarchy of ContentAccessAdminSettingsAccessCheck

1 string reference to 'ContentAccessAdminSettingsAccessCheck'
content_access.services.yml in ./content_access.services.yml
content_access.services.yml
1 service uses ContentAccessAdminSettingsAccessCheck
access_check.content_access_admin_settings_access in ./content_access.services.yml
Drupal\content_access\Access\ContentAccessAdminSettingsAccessCheck

File

src/Access/ContentAccessAdminSettingsAccessCheck.php, line 17

Namespace

Drupal\content_access\Access
View source
class ContentAccessAdminSettingsAccessCheck implements AccessInterface {

  /**
   * The entity type manager.
   *
   * @var \Drupal\Core\Entity\EntityTypeManagerInterface
   */
  protected $entityTypeManager;

  /**
   * Constructs a ContentAccessAdminSettingsAccessCheck object.
   *
   * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
   *   The entity type manager.
   */
  public function __construct(EntityTypeManagerInterface $entity_type_manager) {
    $this->entityTypeManager = $entity_type_manager;
  }

  /**
   * {@inheritdoc}
   */
  public function access(AccountInterface $account, RouteMatchInterface $route_match) {
    $node_type_id = $route_match
      ->getParameter('node_type');
    $node_type = $this->entityTypeManager
      ->getStorage('node_type')
      ->load($node_type_id);
    $permission_match = $account
      ->hasPermission('bypass node access') && $account
      ->hasPermission('administer content types');
    return AccessResult::allowedIf($permission_match && $node_type);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ContentAccessAdminSettingsAccessCheck::$entityTypeManager protected property The entity type manager.
ContentAccessAdminSettingsAccessCheck::access public function
ContentAccessAdminSettingsAccessCheck::__construct public function Constructs a ContentAccessAdminSettingsAccessCheck object.