mirror of
https://github.com/processwire/processwire.git
synced 2025-08-09 16:26:59 +02:00
Add ability for PageFinder and PagesLoader to retain additional info about selectors and PageFinder instance for debugging purposes
This commit is contained in:
@@ -171,6 +171,7 @@ class PageFinder extends Wire {
|
|||||||
protected $reverseAfter = false; // reverse order after load?
|
protected $reverseAfter = false; // reverse order after load?
|
||||||
protected $pageArrayData = array(); // any additional data that should be populated back to any resulting PageArray objects
|
protected $pageArrayData = array(); // any additional data that should be populated back to any resulting PageArray objects
|
||||||
protected $partialMatchOperators = array('%=', '^=', '$=', '%^=', '%$=', '*=');
|
protected $partialMatchOperators = array('%=', '^=', '$=', '%^=', '%$=', '*=');
|
||||||
|
protected $finalSelectors = null; // Fully parsed final selectors
|
||||||
protected $singlesFields = array( // fields that can only be used by themselves (not OR'd with other fields)
|
protected $singlesFields = array( // fields that can only be used by themselves (not OR'd with other fields)
|
||||||
'has_parent',
|
'has_parent',
|
||||||
'hasParent',
|
'hasParent',
|
||||||
@@ -1426,6 +1427,7 @@ class PageFinder extends Wire {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->postProcessQuery($query);
|
$this->postProcessQuery($query);
|
||||||
|
$this->finalSelectors = $selectors;
|
||||||
|
|
||||||
return $query;
|
return $query;
|
||||||
}
|
}
|
||||||
@@ -2889,5 +2891,20 @@ class PageFinder extends Wire {
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the fully parsed/final selectors used in the last find() operation
|
||||||
|
*
|
||||||
|
* Should only be called after a find() or findIDs() operation, otherwise returns null.
|
||||||
|
*
|
||||||
|
* #pw-internal
|
||||||
|
*
|
||||||
|
* @return Selectors|null
|
||||||
|
* @since 3.0.146
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function getSelectors() {
|
||||||
|
return $this->finalSelectors;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -48,6 +48,14 @@ class PagesLoader extends Wire {
|
|||||||
*/
|
*/
|
||||||
protected $totalPagesLoaded = 0;
|
protected $totalPagesLoaded = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Last used instance of PageFinder
|
||||||
|
*
|
||||||
|
* @var PageFinder|null
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
protected $lastPageFinder = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Debug mode for pages class
|
* Debug mode for pages class
|
||||||
*
|
*
|
||||||
@@ -359,6 +367,7 @@ class PagesLoader extends Wire {
|
|||||||
$pages->setStart($start);
|
$pages->setStart($start);
|
||||||
$pages->setSelectors($selectorString);
|
$pages->setSelectors($selectorString);
|
||||||
$pages->setTrackChanges(true);
|
$pages->setTrackChanges(true);
|
||||||
|
$this->lastPageFinder = $pageFinder;
|
||||||
|
|
||||||
if($loadPages && $cachePages) {
|
if($loadPages && $cachePages) {
|
||||||
if(strpos($selectorString, 'sort=random') !== false) {
|
if(strpos($selectorString, 'sort=random') !== false) {
|
||||||
@@ -1230,4 +1239,15 @@ class PagesLoader extends Wire {
|
|||||||
return $this->totalPagesLoaded;
|
return $this->totalPagesLoaded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get last used instance of PageFinder (for debugging purposes)
|
||||||
|
*
|
||||||
|
* @return PageFinder|null
|
||||||
|
* @since 3.0.146
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public function getLastPageFinder() {
|
||||||
|
return $this->lastPageFinder;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Reference in New Issue
Block a user