You are here

public function Section::getValueOptions in Workbench Access 8

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.

This can use a guard to be used to reduce database hits as much as possible.

Return value

array|null The stored values from $this->valueOptions.

Overrides InOperator::getValueOptions

File

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

Class

Section
Filter by assigned section.

Namespace

Drupal\workbench_access\Plugin\views\filter

Code

public function getValueOptions() {
  if (isset($this->valueOptions)) {
    return $this->valueOptions;
  }
  $this->valueOptions = [];
  if (!empty($this->scheme)) {
    $scheme = $this->scheme
      ->getAccessScheme();
    if ($this->manager
      ->userInAll($this->scheme)) {
      $list = WorkbenchAccessManager::getAllSections($this->scheme, FALSE);
    }
    else {
      $list = $this->userSectionStorage
        ->getUserSections($this->scheme);
      if (!empty($this->options['section_filter']['show_hierarchy'])) {
        $list = $this
          ->getChildren($list);
      }
    }
    foreach ($list as $id) {
      if ($section = $scheme
        ->load($id)) {
        $this->valueOptions[$id] = str_repeat('-', $section['depth']) . ' ' . $section['label'];
      }
    }
  }
  return $this->valueOptions;
}