function FieldPluginBase::add_additional_fields in Views (for Drupal 7) 8.3
Add 'additional' fields to the query.
array(
'table' => $tablename,
'field' => $fieldname,
);
Parameters
$fields: An array of fields. The key is an identifier used to later find the field alias used. The value is either a string in which case it's assumed to be a field on this handler's table; or it's an array in the form of
12 calls to FieldPluginBase::add_additional_fields()
- Field::query in lib/
Views/ field/ Plugin/ views/ field/ Field.php - Called to add the field to a query.
- FieldPluginBase::query in lib/
Drupal/ views/ Plugin/ views/ field/ FieldPluginBase.php - Called to add the field to a query.
- FormatName::query in lib/
Views/ filter/ Plugin/ views/ field/ FormatName.php - Called to add the field to a query.
- Link::query in lib/
Views/ user/ Plugin/ views/ field/ Link.php - Called to add the field to a query.
- LinkEdit::query in lib/
Views/ locale/ Plugin/ views/ field/ LinkEdit.php - Called to add the field to a query.
File
- lib/
Drupal/ views/ Plugin/ views/ field/ FieldPluginBase.php, line 118 - Definition of Drupal\views\Plugin\views\field\FieldPluginBase.
Class
- FieldPluginBase
- Base field handler that has no options and renders an unformatted field.
Namespace
Drupal\views\Plugin\views\fieldCode
function add_additional_fields($fields = NULL) {
if (!isset($fields)) {
// notice check
if (empty($this->additional_fields)) {
return;
}
$fields = $this->additional_fields;
}
$group_params = array();
if ($this->options['group_type'] != 'group') {
$group_params = array(
'function' => $this->options['group_type'],
);
}
if (!empty($fields) && is_array($fields)) {
foreach ($fields as $identifier => $info) {
if (is_array($info)) {
if (isset($info['table'])) {
$table_alias = $this->query
->ensure_table($info['table'], $this->relationship);
}
else {
$table_alias = $this->tableAlias;
}
if (empty($table_alias)) {
debug(t('Handler @handler tried to add additional_field @identifier but @table could not be added!', array(
'@handler' => $this->definition['handler'],
'@identifier' => $identifier,
'@table' => $info['table'],
)));
$this->aliases[$identifier] = 'broken';
continue;
}
$params = array();
if (!empty($info['params'])) {
$params = $info['params'];
}
$params += $group_params;
$this->aliases[$identifier] = $this->query
->add_field($table_alias, $info['field'], NULL, $params);
}
else {
$this->aliases[$info] = $this->query
->add_field($this->tableAlias, $info, NULL, $group_params);
}
}
}
}