You are here

protected static function ShsTermSelect::buildCachedTermOptions in Webform Simple Hierarchical Select 8

Build a cached list of term options for provided vocabulary.

Parameters

string $vid: Vocabulary id.

Return value

array Cached list of term options.

Throws

\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException

1 call to ShsTermSelect::buildCachedTermOptions()
ShsTermSelect::buildOptions in src/Element/ShsTermSelect.php
Build a list of term options for provided vocabulary.

File

src/Element/ShsTermSelect.php, line 245

Class

ShsTermSelect
Provides a webform element for an shs term select menu.

Namespace

Drupal\webform_shs\Element

Code

protected static function buildCachedTermOptions($vid) {
  $cid = self::getOptionsCacheId($vid);
  if ($cache = \Drupal::cache()
    ->get($cid)) {
    $options = $cache->data;
  }
  else {
    $options = self::buildTermOptions($vid);
    \Drupal::cache()
      ->set($cid, $options, Cache::PERMANENT);
  }
  return $options;
}