private static function ContextualRangeFilter::split in Views Contextual Range Filter 8
Split a filter range string into an array of "from" and "to" values.
Parameters
string $range: Typically of the format "from--to", "from--" or "--to", but a single value is also allowed. A single colon is accepted instead of --.
Return value
array Array of length 2, the 2nd value equals FALSE when no separator was found.
1 call to ContextualRangeFilter::split()
- ContextualRangeFilter::buildRangeQuery in src/
ContextualRangeFilter.php - Build a range query based on the ranges passed in.
File
- src/
ContextualRangeFilter.php, line 25
Class
- ContextualRangeFilter
- Functions for the contextual_range_filter module.
Namespace
Drupal\contextual_range_filterCode
private static function split($range) {
// A little defensive programming to make sure we have a string.
if (is_array($range)) {
$range = reset($range);
}
$range = trim($range);
$from_to = explode(self::CONTEXTUAL_RANGE_FILTER_SEPARATOR1, $range);
if (count($from_to) < 2) {
$from_to = explode(self::CONTEXTUAL_RANGE_FILTER_SEPARATOR2, $range);
}
return count($from_to) == 1 ? [
reset($from_to),
FALSE,
] : $from_to;
}