You are here

protected function Section::getChildren in Workbench Access 8

Gets the child sections of a base section.

Parameters

array $values: Defined or selected values.

Return value

array An array of section ids that this user may see.

2 calls to Section::getChildren()
Section::getValueOptions in src/Plugin/views/filter/Section.php
Child classes should be used to override this function and set the 'value options', unless 'options callback' is defined as a valid function or static public method to generate these values.
Section::query in src/Plugin/views/filter/Section.php
Add this filter to the query.

File

src/Plugin/views/filter/Section.php, line 318

Class

Section
Filter by assigned section.

Namespace

Drupal\workbench_access\Plugin\views\filter

Code

protected function getChildren(array $values) {
  $tree = $this->scheme
    ->getAccessScheme()
    ->getTree();
  $children = [];
  foreach ($values as $id) {
    foreach ($tree as $key => $data) {
      if ($id == $key) {
        $children += array_keys($data);
      }
      else {
        foreach ($data as $iid => $item) {
          if ($iid == $id || in_array($id, $item['parents'])) {
            $children[] = $iid;
          }
        }
      }
    }
  }
  return $children;
}