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()
- 8.9.x 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()
Gets the date default argument, formatted appropriately for this argument.
Overrides ArgumentPluginBase::getDefaultArgument
File
-
core/
modules/ views/ src/ Plugin/ views/ argument/ Date.php, line 125
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, $this->time
->getRequestTime());
}
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();
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.