public function SearchApiDate::title in Search API 8
Get the title this argument will assign the view, given the argument.
This usually needs to be overridden to provide a proper title.
Overrides ArgumentPluginBase::title
File
- src/
Plugin/ views/ argument/ SearchApiDate.php, line 114
Class
- SearchApiDate
- Defines a contextual filter for conditions on date fields.
Namespace
Drupal\search_api\Plugin\views\argumentCode
public function title() {
if (!empty($this->argument)) {
$this
->fillValue();
$dates = [];
foreach ($this->value as $date) {
$date_parts = explode(';', $date);
$ts = $this
->getTimestamp($date_parts[0]);
$date_string = $this
->getDateFormatter()
->format($ts, 'short');
if (count($date_parts) > 1) {
$ts = $this
->getTimestamp($date_parts[1]);
$date_string .= ' – ' . $this
->getDateFormatter()
->format($ts, 'short');
}
if ($date_string) {
$dates[] = $date_string;
}
}
return $dates ? implode(', ', $dates) : $this->argument;
}
return $this->argument;
}