1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-08 07:47:00 +02:00
This commit is contained in:
Ryan Cramer
2016-12-19 13:00:20 -05:00
parent 2570d6c86d
commit e34918c73a

View File

@@ -156,6 +156,31 @@ class PagesLoaderCache extends Wire {
return true;
}
/**
* Convert an options array to a string
*
* @param array $options
* @return string
*
*/
protected function optionsArrayToString(array $options) {
$str = '';
ksort($options);
foreach($options as $key => $value) {
if(is_array($value)) {
$value = $this->optionsArrayToString($value);
} else if(is_object($value)) {
if(method_exists($value, '__toString')) {
$value = (string) $value;
} else {
$value = wireClassName($value);
}
}
$str .= "[$key:$value]";
}
return $str;
}
/**
* Retrieve any cached page IDs for the given selector and options OR false if none found.
*
@@ -170,12 +195,7 @@ class PagesLoaderCache extends Wire {
public function getSelectorCache($selector, $options, $returnSelector = false) {
if(count($options)) {
$optionsHash = '';
ksort($options);
foreach($options as $key => $value) {
if(is_array($value)) $value = print_r($value, true);
$optionsHash .= "[$key:$value]";
}
$optionsHash = $this->optionsArrayToString($options);
$selector .= "," . $optionsHash;
} else {
$selector .= ",";