function Date::getDefaultArgument
Same name in other branches
- 9 core/modules/views/src/Plugin/views/argument/Date.php \Drupal\views\Plugin\views\argument\Date::getDefaultArgument()
- 10 core/modules/views/src/Plugin/views/argument/Date.php \Drupal\views\Plugin\views\argument\Date::getDefaultArgument()
- 11.x core/modules/views/src/Plugin/views/argument/Date.php \Drupal\views\Plugin\views\argument\Date::getDefaultArgument()
Set the empty argument value to the current date, formatted appropriately for this argument.
Overrides ArgumentPluginBase::getDefaultArgument
File
-
core/
modules/ views/ src/ Plugin/ views/ argument/ Date.php, line 108
Class
- Date
- Argument handler for dates.
Namespace
Drupal\views\Plugin\views\argumentCode
public function getDefaultArgument($raw = FALSE) {
if (!$raw && $this->options['default_argument_type'] == 'date') {
return date($this->argFormat, REQUEST_TIME);
}
elseif (!$raw && in_array($this->options['default_argument_type'], [
'node_created',
'node_changed',
])) {
$node = $this->routeMatch
->getParameter('node');
if (!$node instanceof NodeInterface) {
return parent::getDefaultArgument();
}
elseif ($this->options['default_argument_type'] == 'node_created') {
return date($this->argFormat, $node->getCreatedTime());
}
elseif ($this->options['default_argument_type'] == 'node_changed') {
return date($this->argFormat, $node->getChangedTime());
}
}
return parent::getDefaultArgument($raw);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.