1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-08 07:47:00 +02:00

Update PagesLoader::count() method to fully support selectors argument that is instanceof Selectors object

This commit is contained in:
Ryan Cramer
2023-08-02 10:14:46 -04:00
parent 223c0e79be
commit 09300ebb96

View File

@@ -1988,7 +1988,7 @@ class PagesLoader extends Wire {
/**
* Count and return how many pages will match the given selector string
*
* @param string|array $selector Specify selector, or omit to retrieve a site-wide count.
* @param string|array|Selectors $selector Specify selector, or omit to retrieve a site-wide count.
* @param array|string $options See $options in Pages::find
* @return int
*
@@ -2016,6 +2016,8 @@ class PagesLoader extends Wire {
$selector .= ", limit=1";
} else if(is_array($selector)) {
$selector['limit'] = 1;
} else if($selector instanceof Selectors) {
$selector->add(new SelectorEqual('limit', 1));
}
return $this->pages->find($selector, $options)->getTotal();
}