function ViewExecutable::initQuery
Same name in other branches
- 9 core/modules/views/src/ViewExecutable.php \Drupal\views\ViewExecutable::initQuery()
- 10 core/modules/views/src/ViewExecutable.php \Drupal\views\ViewExecutable::initQuery()
- 11.x core/modules/views/src/ViewExecutable.php \Drupal\views\ViewExecutable::initQuery()
Initializes the query object for the view.
Return value
true Always returns TRUE.
3 calls to ViewExecutable::initQuery()
- ViewExecutable::build in core/
modules/ views/ src/ ViewExecutable.php - Builds the query for the view.
- ViewExecutable::buildTitle in core/
modules/ views/ src/ ViewExecutable.php - Forces the view to build a title.
- ViewExecutable::getQuery in core/
modules/ views/ src/ ViewExecutable.php - Gets the current query plugin.
File
-
core/
modules/ views/ src/ ViewExecutable.php, line 1166
Class
- ViewExecutable
- Represents a view as a whole.
Namespace
Drupal\viewsCode
public function initQuery() {
if (!empty($this->query)) {
$class = get_class($this->query);
if ($class && $class != 'stdClass') {
// return if query is already initialized.
return TRUE;
}
}
// Create and initialize the query object.
$views_data = Views::viewsData()->get($this->storage
->get('base_table'));
$this->storage
->set('base_field', !empty($views_data['table']['base']['field']) ? $views_data['table']['base']['field'] : '');
if (!empty($views_data['table']['base']['database'])) {
$this->base_database = $views_data['table']['base']['database'];
}
$this->query = $this->display_handler
->getPlugin('query');
return TRUE;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.