RefinableDependentAccessTrait.php in Drupal 10
File
core/modules/block_content/src/Access/RefinableDependentAccessTrait.php
View source
<?php
namespace Drupal\block_content\Access;
use Drupal\Core\Access\AccessibleInterface;
trait RefinableDependentAccessTrait {
protected $accessDependency;
public function setAccessDependency(AccessibleInterface $access_dependency) {
$this->accessDependency = $access_dependency;
return $this;
}
public function getAccessDependency() {
return $this->accessDependency;
}
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;
}
}