You are here

public function Pool::getValueOptions in CMS Content Sync 2.0.x

Same name and namespace in other branches
  1. 8 modules/cms_content_sync_views/src/Plugin/views/filter/Pool.php \Drupal\cms_content_sync_views\Plugin\views\filter\Pool::getValueOptions()
  2. 2.1.x modules/cms_content_sync_views/src/Plugin/views/filter/Pool.php \Drupal\cms_content_sync_views\Plugin\views\filter\Pool::getValueOptions()

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

modules/cms_content_sync_views/src/Plugin/views/filter/Pool.php, line 20

Class

Pool
Provides a view filter to filter on the sync state entity.

Namespace

Drupal\cms_content_sync_views\Plugin\views\filter

Code

public function getValueOptions() {
  if (!isset($this->valueOptions)) {
    $this->valueTitle = $this
      ->t('Pools');

    // @codingStandardsIgnoreStarts
    $pools = \Drupal\cms_content_sync\Entity\Pool::getAll();

    // @codingStandardsIgnoreEnd
    if (!empty($pools)) {
      foreach ($pools as $pool_name => $pool) {
        $this->valueOptions[$pool_name] = $pool
          ->label();
      }
      return $this->valueOptions;
    }
  }
  return $this->valueOptions['none'] = $this
    ->t('None');
}