function ViewExecutable::_buildArguments
Same name in other branches
- 9 core/modules/views/src/ViewExecutable.php \Drupal\views\ViewExecutable::_buildArguments()
- 8.9.x core/modules/views/src/ViewExecutable.php \Drupal\views\ViewExecutable::_buildArguments()
- 11.x core/modules/views/src/ViewExecutable.php \Drupal\views\ViewExecutable::_buildArguments()
Builds all the arguments.
Return value
bool TRUE if the arguments were built successfully, FALSE otherwise.
2 calls to ViewExecutable::_buildArguments()
- 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.
File
-
core/
modules/ views/ src/ ViewExecutable.php, line 1118
Class
- ViewExecutable
- Represents a view as a whole.
Namespace
Drupal\viewsCode
protected function _buildArguments() {
// Initially, we want to build sorts and fields. This can change, though,
// if we get a summary view.
if (empty($this->argument)) {
return TRUE;
}
// Build arguments.
$position = -1;
$substitutions = [];
$status = TRUE;
// Get the title.
$title = $this->display_handler
->getOption('title');
// Iterate through each argument and process.
foreach ($this->argument as $id => $arg) {
$position++;
$argument = $this->argument[$id];
if ($argument->broken()) {
continue;
}
$argument->setRelationship();
$arg = $this->args[$position] ?? NULL;
$argument->position = $position;
if (isset($arg) || $argument->hasDefaultArgument()) {
if (!isset($arg)) {
$arg = $argument->getDefaultArgument();
// Make sure default args get put back.
if (isset($arg)) {
$this->args[$position] = $arg;
}
// Remember that this argument was computed, not passed on the URL.
$argument->is_default = TRUE;
}
// Set the argument, which ensures that the argument is valid and
// possibly transforms the value.
if (!$argument->setArgument($arg)) {
$status = $argument->validateFail($arg);
break;
}
if ($argument->isException()) {
$arg_title = $argument->exceptionTitle();
}
else {
$arg_title = $argument->getTitle();
$argument->query($this->display_handler
->useGroupBy());
}
// Add this argument's substitution.
$substitutions["{{ arguments.{$id} }}"] = $arg_title;
// Since argument validator plugins can potentially transform the value,
// use whatever value the argument handler now has, not the raw value.
$substitutions["{{ raw_arguments.{$id} }}"] = strip_tags(Html::decodeEntities($argument->getValue()));
// Test to see if we should use this argument's title
if (!empty($argument->options['title_enable']) && !empty($argument->options['title'])) {
$title = $argument->options['title'];
}
}
else {
// Determine default condition and handle.
$status = $argument->defaultAction();
break;
}
// Be safe with references and loops:
unset($argument);
}
// Set the title in the build info.
if (!empty($title)) {
$this->build_info['title'] = $title;
}
// Store the arguments for later use.
$this->build_info['substitutions'] = $substitutions;
return $status;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.