RefinableDependentAccessTrait.php

Same filename in this branch
  1. 11.x core/modules/block_content/src/Access/RefinableDependentAccessTrait.php
Same filename and directory in other branches
  1. 9 core/modules/block_content/src/Access/RefinableDependentAccessTrait.php
  2. 8.9.x core/modules/block_content/src/Access/RefinableDependentAccessTrait.php
  3. 10 core/modules/block_content/src/Access/RefinableDependentAccessTrait.php

Namespace

Drupal\Core\Access

File

core/lib/Drupal/Core/Access/RefinableDependentAccessTrait.php

View source
<?php

namespace Drupal\Core\Access;


/**
 * Trait for \Drupal\Core\Access\RefinableDependentAccessInterface.
 *
 * @internal
 */
trait RefinableDependentAccessTrait {
  
  /**
   * The access dependency.
   *
   * @var \Drupal\Core\Access\AccessibleInterface
   */
  protected $accessDependency;
  
  /**
   * {@inheritdoc}
   */
  public function setAccessDependency(AccessibleInterface $access_dependency) {
    $this->accessDependency = $access_dependency;
    return $this;
  }
  
  /**
   * {@inheritdoc}
   */
  public function getAccessDependency() {
    return $this->accessDependency;
  }
  
  /**
   * {@inheritdoc}
   */
  public function addAccessDependency(AccessibleInterface $access_dependency) {
    if (empty($this->accessDependency)) {
      $this->accessDependency = $access_dependency;
      return $this;
    }
    if (!$this->accessDependency instanceof AccessGroupAnd) {
      $accessGroup = new AccessGroupAnd();
      $this->accessDependency = $accessGroup->addDependency($this->accessDependency);
    }
    $this->accessDependency
      ->addDependency($access_dependency);
    return $this;
  }

}

Traits

Title Deprecated Summary
RefinableDependentAccessTrait Trait for \Drupal\Core\Access\RefinableDependentAccessInterface.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.