You are here

function Version::get_value_options in Views (for Drupal 7) 8.3

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

Return the stored values in $this->value_options if someone expects it.

Overrides InOperator::get_value_options

File

lib/Views/locale/Plugin/views/filter/Version.php, line 25
Definition of Views\locale\Plugin\views\filter\Version.

Class

Version
Filter by version.

Namespace

Views\locale\Plugin\views\filter

Code

function get_value_options() {
  if (!isset($this->value_options)) {
    $this->value_title = t('Version');

    // Enable filtering by the current installed Drupal version.
    $versions = array(
      '***CURRENT_VERSION***' => t('Current installed version'),
    );

    // Uses db_query() rather than db_select() because the query is static and
    // does not include any variables.
    $result = db_query('SELECT DISTINCT(version) FROM {locales_source} ORDER BY version');
    foreach ($result as $row) {
      if (!empty($row->version)) {
        $versions[$row->version] = $row->version;
      }
    }
    $this->value_options = $versions;
  }
}