Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / block_content / src / Access / RefinableDependentAccessTrait.php
diff --git a/web/core/modules/block_content/src/Access/RefinableDependentAccessTrait.php b/web/core/modules/block_content/src/Access/RefinableDependentAccessTrait.php
new file mode 100644 (file)
index 0000000..98b2a54
--- /dev/null
@@ -0,0 +1,52 @@
+<?php
+
+namespace Drupal\block_content\Access;
+
+use Drupal\Core\Access\AccessibleInterface;
+
+/**
+ * Trait for \Drupal\block_content\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;
+  }
+
+}