You are here

public function AssignUserForm::getFormOptions in Workbench Access 8

Gets available form options for this administrative user.

Parameters

\Drupal\workbench_access\Entity\AccessSchemeInterface $scheme: The access scheme being processed by the form.

1 call to AssignUserForm::getFormOptions()
AssignUserForm::buildForm in src/Form/AssignUserForm.php
Form constructor.

File

src/Form/AssignUserForm.php, line 221

Class

AssignUserForm
Builds the workbench_access set switch form.

Namespace

Drupal\workbench_access\Form

Code

public function getFormOptions(AccessSchemeInterface $scheme) {
  $options = [];
  $access_scheme = $scheme
    ->getAccessScheme();
  if ($this->manager
    ->userInAll($scheme)) {
    $list = $this->manager
      ->getAllSections($scheme, FALSE);
  }
  else {

    // @TODO: new method needed?
    $list = $this->userSectionStorage
      ->getUserSections($scheme);
    $list = $this
      ->getChildren($access_scheme, $list);
  }
  foreach ($list as $id) {
    if ($section = $access_scheme
      ->load($id)) {
      $options[$id] = str_repeat('-', $section['depth']) . ' ' . $section['label'];
    }
  }
  return $options;
}