public function ItemCount::query in Translation Management Tool 8
Called to add the field to a query.
Overrides FieldPluginBase::query
File
- translators/
tmgmt_local/ src/ Plugin/ views/ field/ ItemCount.php, line 59
Class
- ItemCount
- Field handler to show the amount of job items per task.
Namespace
Drupal\tmgmt_local\Plugin\views\fieldCode
public function query() {
$this
->ensureMyTable();
// Therefore construct the join.
// Add the join for the tmgmt_job_item table.
$configuration = array(
'table' => 'tmgmt_job_item',
'field' => 'tjid',
'left_table' => $this->tableAlias,
'left_field' => 'tjid',
'operator' => '=',
);
if (!empty($this->options['state'])) {
$configuration['extra'] = [
[
'field' => 'state',
'value' => $this->options['state'],
],
];
}
/** @var \Drupal\views\Plugin\views\join\Standard $join */
$join = Views::pluginManager('join')
->createInstance('standard', $configuration);
// Add the join to the tmgmt_job_item table.
$this->tableAlias = $this->query
->addTable('tmgmt_job_item', $this->relationship, $join);
// And finally add the count of the job items field.
$params = array(
'function' => 'count',
);
$this->field_alias = $this->query
->addField($this->tableAlias, 'tjiid', NULL, $params);
$this
->addAdditionalFields();
}