You are here

protected function AssignUserForm::getChildren in Workbench Access 8

Gets the child sections of a base section.

Parameters

\Drupal\workbench_access\AccessControlHierarchyInterface $access_scheme: The access scheme being processed by the form.

array $values: Defined or selected values.

Return value

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

1 call to AssignUserForm::getChildren()
AssignUserForm::getFormOptions in src/Form/AssignUserForm.php
Gets available form options for this administrative user.

File

src/Form/AssignUserForm.php, line 251

Class

AssignUserForm
Builds the workbench_access set switch form.

Namespace

Drupal\workbench_access\Form

Code

protected function getChildren(AccessControlHierarchyInterface $access_scheme, array $values) {
  $tree = $access_scheme
    ->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;
}