Commit ba4d4a88 authored by alexpott's avatar alexpott

Issue #2002144 by phenaproxima, connork, rdrh555, zschmid, elvis2, drupalway,...

Issue #2002144 by phenaproxima, connork, rdrh555, zschmid, elvis2, drupalway, heddn: Rename Views method add_field() to addField().
parent b48343a2
......@@ -42,10 +42,10 @@ public function query() {
// ncs_user alias so this can work with the sort handler, below.
$this->user_table = $this->query->ensure_table('ncs_users', $this->relationship, $join);
$this->field_alias = $this->query->add_field(NULL, "COALESCE($this->user_table.name, $this->tableAlias.$this->field)", $this->tableAlias . '_' . $this->field);
$this->field_alias = $this->query->addField(NULL, "COALESCE($this->user_table.name, $this->tableAlias.$this->field)", $this->tableAlias . '_' . $this->field);
$this->user_field = $this->query->add_field($this->user_table, 'name');
$this->uid = $this->query->add_field($this->tableAlias, 'last_comment_uid');
$this->user_field = $this->query->addField($this->user_table, 'name');
$this->uid = $this->query->addField($this->tableAlias, 'last_comment_uid');
}
protected function defineOptions() {
......
......@@ -22,7 +22,7 @@ class NcsLastUpdated extends Date {
public function query() {
$this->ensureMyTable();
$this->node_table = $this->query->ensure_table('node', $this->relationship);
$this->field_alias = $this->query->add_field(NULL, "GREATEST(" . $this->node_table . ".changed, " . $this->tableAlias . ".last_comment_timestamp)", $this->tableAlias . '_' . $this->field);
$this->field_alias = $this->query->addField(NULL, "GREATEST(" . $this->node_table . ".changed, " . $this->tableAlias . ".last_comment_timestamp)", $this->tableAlias . '_' . $this->field);
}
}
......@@ -34,7 +34,7 @@ public function query() {
// the table alias. Though if we did that we'd be guessing the relationship name
// so that doesn't matter that much.
$this->user_table = $this->query->ensure_table('ncs_users', $this->relationship, $join);
$this->user_field = $this->query->add_field($this->user_table, 'name');
$this->user_field = $this->query->addField($this->user_table, 'name');
// Add the field.
$this->query->add_orderby(NULL, "LOWER(COALESCE($this->user_table.name, $this->tableAlias.$this->field))", $this->options['order'], $this->tableAlias . '_' . $this->field);
......
......@@ -122,7 +122,7 @@ public function query() {
// Make sure the id field is included in the results.
$id_field = $this->view->storage->get('base_field');
$this->id_field_alias = $this->view->query->add_field($this->view->storage->get('base_table'), $id_field);
$this->id_field_alias = $this->view->query->addField($this->view->storage->get('base_table'), $id_field);
$options = $this->getOption('entity_reference_options');
......
......@@ -68,7 +68,7 @@ public function query($group_by = FALSE) {
$join = drupal_container()->get('plugin.manager.views.join')->createInstance('standard', $definition);
$search_total = $this->query->addRelationship('search_total', $join, $search_index);
$this->search_score = $this->query->add_field('', "SUM($search_index.score * $search_total.count)", 'score', array('aggregate' => TRUE));
$this->search_score = $this->query->addField('', "SUM($search_index.score * $search_total.count)", 'score', array('aggregate' => TRUE));
if (empty($this->query->relationships[$this->relationship])) {
$base_table = $this->view->storage->get('base_table');
......
......@@ -149,7 +149,7 @@ public function query() {
$search_total = $this->query->addRelationship('search_total', $join, $search_index);
$this->search_score = $this->query->add_field('', "SUM($search_index.score * $search_total.count)", 'score', array('aggregate' => TRUE));
$this->search_score = $this->query->addField('', "SUM($search_index.score * $search_total.count)", 'score', array('aggregate' => TRUE));
if (empty($this->query->relationships[$this->relationship])) {
$base_table = $this->view->storage->get('base_table');
......
......@@ -796,7 +796,7 @@ protected function defaultSummary() {
*
* This must:
* - add_groupby: group on this field in order to create summaries.
* - add_field: add a 'num_nodes' field for the count. Usually it will
* - addField: add a 'num_nodes' field for the count. Usually it will
* be a count on $view->base_field
* - set_count_field: Reset the count field so we get the right paging.
*
......@@ -806,7 +806,7 @@ protected function defaultSummary() {
protected function summaryQuery() {
$this->ensureMyTable();
// Add the field.
$this->base_alias = $this->query->add_field($this->tableAlias, $this->realField);
$this->base_alias = $this->query->addField($this->tableAlias, $this->realField);
$this->summaryNameField();
return $this->summaryBasics();
......@@ -840,7 +840,7 @@ protected function summaryNameField() {
}
if (isset($this->name_field)) {
$this->name_alias = $this->query->add_field($this->name_table_alias, $this->name_field);
$this->name_alias = $this->query->addField($this->name_table_alias, $this->name_field);
}
else {
$this->name_alias = $this->base_alias;
......@@ -855,7 +855,7 @@ public function summaryBasics($count_field = TRUE) {
// Add the number of nodes counter
$distinct = ($this->view->display_handler->getOption('distinct') && empty($this->query->no_distinct));
$count_alias = $this->query->add_field($this->view->storage->get('base_table'), $this->view->storage->get('base_field'), 'num_records', array('count' => TRUE, 'distinct' => $distinct));
$count_alias = $this->query->addField($this->view->storage->get('base_table'), $this->view->storage->get('base_field'), 'num_records', array('count' => TRUE, 'distinct' => $distinct));
$this->query->add_groupby($this->name_alias);
if ($count_field) {
......
......@@ -51,7 +51,7 @@ protected function summaryQuery() {
$formula = $this->getFormula();
// Add the field.
$this->base_alias = $this->name_alias = $this->query->add_field(NULL, $formula, $this->field);
$this->base_alias = $this->name_alias = $this->query->addField(NULL, $formula, $this->field);
$this->query->set_count_field(NULL, $formula, $this->field);
return $this->summaryBasics(FALSE);
......
......@@ -177,7 +177,7 @@ protected function summaryQuery() {
}
// Add the field.
$this->base_alias = $this->query->add_field($this->tableAlias, $this->realField);
$this->base_alias = $this->query->addField($this->tableAlias, $this->realField);
$this->summaryNameField();
......
......@@ -156,13 +156,13 @@ protected function summaryQuery() {
if (empty($this->options['glossary'])) {
// Add the field.
$this->base_alias = $this->query->add_field($this->tableAlias, $this->realField);
$this->base_alias = $this->query->addField($this->tableAlias, $this->realField);
$this->query->set_count_field($this->tableAlias, $this->realField);
}
else {
// Add the field.
$formula = $this->getFormula();
$this->base_alias = $this->query->add_field(NULL, $formula, $this->field . '_truncated');
$this->base_alias = $this->query->addField(NULL, $formula, $this->field . '_truncated');
$this->query->set_count_field(NULL, $formula, $this->field, $this->field . '_truncated');
}
......
......@@ -100,7 +100,7 @@ public function query() {
$this->ensureMyTable();
// Add the field.
$params = $this->options['group_type'] != 'group' ? array('function' => $this->options['group_type']) : array();
$this->field_alias = $this->query->add_field($this->tableAlias, $this->realField, NULL, $params);
$this->field_alias = $this->query->addField($this->tableAlias, $this->realField, NULL, $params);
$this->addAdditionalFields();
}
......@@ -153,10 +153,10 @@ protected function addAdditionalFields($fields = NULL) {
}
$params += $group_params;
$this->aliases[$identifier] = $this->query->add_field($table_alias, $info['field'], NULL, $params);
$this->aliases[$identifier] = $this->query->addField($table_alias, $info['field'], NULL, $params);
}
else {
$this->aliases[$info] = $this->query->add_field($this->tableAlias, $info, NULL, $group_params);
$this->aliases[$info] = $this->query->addField($this->tableAlias, $info, NULL, $group_params);
}
}
}
......
......@@ -743,7 +743,7 @@ public function getTableInfo($table) {
* @return $name
* The name that this field can be referred to as. Usually this is the alias.
*/
function add_field($table, $field, $alias = '', $params = array()) {
public function addField($table, $field, $alias = '', $params = array()) {
// We check for this specifically because it gets a special alias.
if ($table == $this->view->storage->get('base_table') && $field == $this->view->storage->get('base_field') && empty($alias)) {
$alias = $this->view->storage->get('base_field');
......@@ -946,7 +946,7 @@ public function addHavingExpression($group, $snippet, $args = array()) {
* one will be generated for from the $field; however, if the
* $field is a formula, this alias will likely fail.
* @param $params
* Any params that should be passed through to the add_field.
* Any params that should be passed through to the addField.
*/
function add_orderby($table, $field = NULL, $order = 'ASC', $alias = '', $params = array()) {
// Only ensure the table if it's not the special random key.
......@@ -965,7 +965,7 @@ function add_orderby($table, $field = NULL, $order = 'ASC', $alias = '', $params
}
if ($field) {
$as = $this->add_field($table, $field, $as, $params);
$as = $this->addField($table, $field, $as, $params);
}
$this->orderby[] = array(
......@@ -1002,7 +1002,7 @@ function add_groupby($clause) {
*
* @access protected
*
* @see views_plugin_query_default::add_field()
* @see \Drupal\views\Plugin\views\query\Sql::addField
*/
protected function getFieldAlias($table_alias, $field) {
return isset($this->field_aliases[$table_alias][$field]) ? $this->field_aliases[$table_alias][$field] : FALSE;
......@@ -1200,7 +1200,7 @@ protected function compileFields($query) {
public function query($get_count = FALSE) {
// Check query distinct value.
if (empty($this->no_distinct) && $this->distinct && !empty($this->fields)) {
$base_field_alias = $this->add_field($this->view->storage->get('base_table'), $this->view->storage->get('base_field'));
$base_field_alias = $this->addField($this->view->storage->get('base_table'), $this->view->storage->get('base_field'));
$this->add_groupby($base_field_alias);
$distinct = TRUE;
}
......@@ -1289,7 +1289,7 @@ public function query($get_count = FALSE) {
foreach ($entity_tables as $table_alias => $table) {
$info = entity_get_info($table['entity_type']);
$base_field = empty($table['revision']) ? $info['entity_keys']['id'] : $info['entity_keys']['revision'];
$this->add_field($table_alias, $base_field, '', $params);
$this->addField($table_alias, $base_field, '', $params);
}
}
......@@ -1602,7 +1602,7 @@ function loadEntities(&$results) {
}
public function addSignature(ViewExecutable $view) {
$view->query->add_field(NULL, "'" . $view->storage->id() . ':' . $view->current_display . "'", 'view_name');
$view->query->addField(NULL, "'" . $view->storage->id() . ':' . $view->current_display . "'", 'view_name');
}
public function getAggregationInfo() {
......
......@@ -121,10 +121,10 @@ public function query() {
if (isset($this->base_table)) {
if (isset($this->options['relationship']) && isset($this->view->relationship[$this->options['relationship']])) {
$relationship = $this->view->relationship[$this->options['relationship']];
$this->field_alias = $this->view->query->add_field($relationship->alias, $this->base_field);
$this->field_alias = $this->view->query->addField($relationship->alias, $this->base_field);
}
else {
$this->field_alias = $this->view->query->add_field($this->base_table, $this->base_field);
$this->field_alias = $this->view->query->addField($this->base_table, $this->base_field);
}
}
}
......
......@@ -69,7 +69,7 @@ public function addWhere($group, $field, $value = NULL, $operator = NULL) {
}
public function add_field($table, $field, $alias = '', $params = array()) {
public function addField($table, $field, $alias = '', $params = array()) {
$this->fields[$field] = $field;
return $field;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment