function DataFieldRow::extractFromOptionsArray

Same name and namespace in other branches
  1. 8.9.x core/modules/rest/src/Plugin/views/row/DataFieldRow.php \Drupal\rest\Plugin\views\row\DataFieldRow::extractFromOptionsArray()
  2. 10 core/modules/rest/src/Plugin/views/row/DataFieldRow.php \Drupal\rest\Plugin\views\row\DataFieldRow::extractFromOptionsArray()
  3. 11.x core/modules/rest/src/Plugin/views/row/DataFieldRow.php \Drupal\rest\Plugin\views\row\DataFieldRow::extractFromOptionsArray()

Extracts a set of option values from a nested options array.

Parameters

string $key: The key to extract from each array item.

array $options: The options array to return values from.

Return value

array A regular one dimensional array of values.

2 calls to DataFieldRow::extractFromOptionsArray()
DataFieldRow::init in core/modules/rest/src/Plugin/views/row/DataFieldRow.php
Initialize the plugin.
DataFieldRow::validateOptionsForm in core/modules/rest/src/Plugin/views/row/DataFieldRow.php
Validate the options form.

File

core/modules/rest/src/Plugin/views/row/DataFieldRow.php, line 190

Class

DataFieldRow
Plugin which displays fields as raw data.

Namespace

Drupal\rest\Plugin\views\row

Code

protected static function extractFromOptionsArray($key, $options) {
    return array_map(function ($item) use ($key) {
        return $item[$key] ?? NULL;
    }, $options);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.