Changeset View
Changeset View
Standalone View
Standalone View
src/symbols/PhutilClassMapQuery.php
| Show All 39 Lines | |||||
| final class PhutilClassMapQuery extends Phobject { | final class PhutilClassMapQuery extends Phobject { | ||||
| private $ancestorClass; | private $ancestorClass; | ||||
| private $expandMethod; | private $expandMethod; | ||||
| private $filterMethod; | private $filterMethod; | ||||
| private $filterNull = false; | private $filterNull = false; | ||||
| private $uniqueMethod; | private $uniqueMethod; | ||||
| private $sortMethod; | private $sortMethod; | ||||
| private $continueOnFailure; | |||||
| // NOTE: If you add more configurable properties here, make sure that | // NOTE: If you add more configurable properties here, make sure that | ||||
| // cache key construction in getCacheKey() is updated properly. | // cache key construction in getCacheKey() is updated properly. | ||||
| private static $cache = array(); | private static $cache = array(); | ||||
| /* -( Configuring the Query )---------------------------------------------- */ | /* -( Configuring the Query )---------------------------------------------- */ | ||||
| ▲ Show 20 Lines • Show All 101 Lines • ▼ Show 20 Lines | /* -( Configuring the Query )---------------------------------------------- */ | ||||
| * @return this | * @return this | ||||
| * @task config | * @task config | ||||
| */ | */ | ||||
| public function setFilterMethod($filter_method) { | public function setFilterMethod($filter_method) { | ||||
| $this->filterMethod = $filter_method; | $this->filterMethod = $filter_method; | ||||
| return $this; | return $this; | ||||
| } | } | ||||
| public function setContinueOnFailure($continue) { | |||||
| $this->continueOnFailure = $continue; | |||||
| return $this; | |||||
| } | |||||
| /* -( Executing the Query )------------------------------------------------ */ | /* -( Executing the Query )------------------------------------------------ */ | ||||
| /** | /** | ||||
| * Execute the query as configured. | * Execute the query as configured. | ||||
| * | * | ||||
| * @return map<string, object> Realized class map. | * @return map<string, object> Realized class map. | ||||
| ▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | if (strlen($expand)) { | ||||
| 'must have unique keys.', | 'must have unique keys.', | ||||
| $ancestor, | $ancestor, | ||||
| $expand)); | $expand)); | ||||
| } | } | ||||
| } | } | ||||
| $objects = id(new PhutilSymbolLoader()) | $objects = id(new PhutilSymbolLoader()) | ||||
| ->setAncestorClass($ancestor) | ->setAncestorClass($ancestor) | ||||
| ->setContinueOnFailure($this->continueOnFailure) | |||||
| ->loadObjects(); | ->loadObjects(); | ||||
| // Apply the "expand" mechanism, if it is configured. | // Apply the "expand" mechanism, if it is configured. | ||||
| if (strlen($expand)) { | if (strlen($expand)) { | ||||
| $list = array(); | $list = array(); | ||||
| foreach ($objects as $object) { | foreach ($objects as $object) { | ||||
| foreach (call_user_func(array($object, $expand)) as $instance) { | foreach (call_user_func(array($object, $expand)) as $instance) { | ||||
| $list[] = $instance; | $list[] = $instance; | ||||
| ▲ Show 20 Lines • Show All 86 Lines • Show Last 20 Lines | |||||