Query
MMO\core\entities · 1 symbole · générée le 27 Oct 2026
Query
Query.php:22Generic way to query a collection of entities.
- Espace de noms
MMO\core\entities- Implémente
- IteratorAggregate, Stringable, iSignal
- Utilise les traits
- tEvent, tWithOptions
Index
| collection | ||
| customExecute | Custom function for execution function(Query $query, array $options) | |
| entities | ||
| fields | ||
| filters | Filter options A list of operators and/or array of json path/values. | |
| isList | ||
| limit | ||
| Listeners static | ||
| offset | Pagination | |
| opts | ||
| sorts | ||
| total | ||
| AddListener($handler, $order) static | Register a listener directly (as opposed to ConnectListeners's attribute-based discovery). | |
| addOptions($opts, $appendList) | Merge $opts into the existing options (through merge), rather than replacing them wholesale like setOptions. | |
| and($args) | Add one or more AND-combined filter conditions. | |
| applySort() | Re-sort the already-run results in memory by $sorts (defaulting to id descending if none set) -- useful when the entities' order needs to reflect a change made after the query ran (e.g. | |
| clear($clearSorts) | Reset the query to a blank slate: no results, filters, fields, offset, or limit. | |
| clearEntities() | Discard any already-run results (and the cached $total), so the next execute/getReturn re-runs the query. | |
| clearOptions() | Empty the options bag. | |
| ConnectListeners($obj) static | Scan $obj's methods for #[Listen(EventClass::class)] attributes and register each one as a listener on the matching event class. | |
| debugName() | ||
| DisconnectListeners($obj) static | Undo a previous ConnectListeners: removes every listener that connect had registered for $obj on this event class. | |
| dispatch() | Invoke every GetListeners listener with $this. | |
| execute($opts) | Execute a query | |
| field($path, $visible) | ||
| filter($filter) | Add a filter condition to this query's root filter group ($filters, an AND group by default). | |
| getEntities() | ||
| getFields() | ||
| getIterator() | \IteratorAggregate::getIterator -- the query's results (running it first if needed -- see getReturn), as a \Traversable either way. | |
| GetListeners() static | Collect every listener for this class, including those registered on its parent classes (so a subclass event is also caught by listeners of its parent event), sorted by ascending $order (ties keep … | |
| getOption($key, $default) | ||
| getOptions() | ||
| getOrigin() | ||
| getReturn() | ||
| getSorts() | ||
| getVisibleFields() | Resolve getFields into the actual list of field names that should be shown: with no explicit selection, every schema-declared visible property; with an explicit selection that only HIDES field… | |
| hasFilters() | ||
| HasListener($handler) static | ||
| isListOnly() | ||
| isRaw() | Tells if query's entities will be returned as an array (raw) instead of Entity | |
| listOnly() | Only list entities (return entity's id and properties needed in title and label) | |
| listRequiredCollections($filter) | List all the other required collections needed for the query | |
| loopRequiredCollection($repository, $schema, $path, $_recusivePath) | Recursion helper for listRequiredCollections: walks a single filter path's schema, yielding the collection behind each instance-typed segment it crosses -- including, for a computed 'label'/'t… | |
| nor($args) | Add one or more NOR-combined filter conditions. | |
| or($args) | Add one or more OR-combined filter conditions. | |
| pagination($limit, $offset) | ||
| RemoveListener($handler) static | Remove the last added handler from the listeners. | |
| resolveAliases() | Filter and sort on what an alias reads (Schema::storedPath): adresse/ville is adresses/default/ville, the path the repository stores. | |
| Send($args) static | Construct a new instance of this class with $args, then dispatch it to every listener. | |
| setFields($value) | NOTE: same bug (and fix) as setSorts -- used to check $value[0] instead of $field[0], so a --prefixed field (meant to hide it) was only ever recognized when it was the very first field i… | |
| SetListenerOrder($handler, $order) static | Change the order of an already-registered listener, whether added directly via AddListener or indirectly via ConnectListeners (which also stores its [$obj, $methodName] callables here). | |
| setListOnly($value) | ||
| setOption($key, $value) | Set (or, with a null $value, remove) a single option. | |
| setOptions($opts) | Replace the whole options bag. | |
| setRaw($raw) | ||
| setReturn($entities) | ||
| setRootOperator($operator) | Change the root filter group's combining operator, wrapping the existing filters in a new group under $operator if it differs from the current one. | |
| setSorts($value) | NOTE: this used to check $value[0] === '-' (the LIST's own first element) inside the foreach ($value as $field) loop, instead of $field[0] (the CURRENT field being examined) -- so, except for… | |
| sort($path, $asc) | NOTE: $asc used to be typed bool (non-nullable), so the $asc === null check below could never be true -- PHP rejects passing null for a non-nullable parameter with a TypeError before the me… | |
| __clone() | Deep-clones $filters (so mutating the clone's filters doesn't affect the original) and discards any already-run results (clearEntities). | |
| __construct($collection, $filter, $fields, $sort, $limit, $offset, $options) | ||
| __toString() |
Propriétés12
collection
- Type
- iCollection
customExecute
Custom function for execution function(Query $query, array $options)
entities
fields
- Type
- array
filters
Filter options A list of operators and/or array of json path/values.
- Type
- FilterGroup
isList
- Type
- bool
limit
Listeners
static- Type
- array
offset
Pagination
opts
- Type
- array
sorts
- Type
- array
total
Méthodes50
AddListener($handler, $order)
statictEvent.php:62Register a listener directly (as opposed to ConnectListeners's attribute-based discovery).
| $handler | callable | called as $handler($eventInstance) when this event class is Send / dispatch-ed |
| $order = 0 | int | listeners run in ascending order (lower first); listeners with an equal order run in the order they were added |
| retourne | void |
addOptions($opts, $appendList)
tWithOptions.php:65Merge $opts into the existing options (through merge), rather than replacing them wholesale like setOptions.
| $opts | array | the options to merge in |
| $appendList = false | bool | if true, a list-valued option is appended to (rather than replaced by) the corresponding list in $opts -- see \MMO\core\arrays\merge for the exact semantics |
| retourne | void |
and($args)
Query.php:464Add one or more AND-combined filter conditions. FilterGroup::and
applySort()
Query.php:315Re-sort the already-run results in memory by $sorts (defaulting to id descending if none set) -- useful when the entities' order needs to reflect a change made after the query ran (e.g. a listener mutated some values), since the repository-side sort can't see that.
| retourne | void |
clear($clearSorts)
Query.php:182Reset the query to a blank slate: no results, filters, fields, offset, or limit. @param bool $clearSorts if true, also clear the sort order (kept by default).
clearEntities()
Query.php:176Discard any already-run results (and the cached $total), so the next execute/getReturn re-runs the query.
| retourne | void |
clearOptions()
tWithOptions.php:39Empty the options bag.
| retourne | void |
ConnectListeners($obj)
statictEvent.php:37Scan $obj's methods for #[Listen(EventClass::class)] attributes and register each one as a listener on the matching event class. connect does the actual reflection/registration.
debugName()
Query.php:136| retourne | string |
DisconnectListeners($obj)
statictEvent.php:49Undo a previous ConnectListeners: removes every listener that connect had registered for $obj on this event class.
dispatch()
tEvent.php:153Invoke every GetListeners listener with $this. If the class also implements PSR-14's StoppableEventInterface, dispatch stops early as soon as isPropagationStopped() becomes true.
| retourne | static | $this, for chaining |
execute($opts)
Query.php:99Execute a query
field($path, $visible)
Query.php:389filter($filter)
Query.php:457Add a filter condition to this query's root filter group ($filters, an AND group by default). @return iFilter $filter itself, normalized.
getEntities()
Query.php:169| retourne | array | the query's results (running it first if needed), materialized as a plain array (consuming/caching a lazy iterable's items). |
getFields()
Query.php:334getIterator()
Query.php:161\IteratorAggregate::getIterator -- the query's results (running it first if needed -- see getReturn), as a \Traversable either way.
| retourne | Traversable | T> |
GetListeners()
statictEvent.php:123Collect every listener for this class, including those registered on its parent classes (so a subclass event is also caught by listeners of its parent event), sorted by ascending $order (ties keep insertion order).
| retourne | array | [[callable $handler, int $order], ...] |
getOption($key, $default)
tWithOptions.php:49getOptions()
tWithOptions.php:20| retourne | array | every option currently set |
getOrigin()
Query.php:90| retourne | object | string | this query's $collection (an iSignal/tEvent origin). |
getReturn()
Query.php:127- Voir
iSignal::getReturn-- the query's results, running it first (execute) if it hasn't been already.
| retourne | iterable |
getSorts()
Query.php:266| retourne | array | the sort order, field => ascending. |
getVisibleFields()
Query.php:347Resolve getFields into the actual list of field names that should be shown: with no explicit selection, every schema-declared visible property; with an explicit selection that only HIDES fields (no explicit true entries), every visible property minus those; otherwise, just the explicitly true fields.
| retourne | array |
hasFilters()
Query.php:152| retourne | bool | whether any filter condition has been added. |
HasListener($handler)
statictEvent.php:109| $handler | callable | object | either the exact callable passed to AddListener, or (for a [$obj, $methodName] listener registered via ConnectListeners) just the object, to check whether any of its methods are currently listening |
| retourne | bool |
isListOnly()
Query.php:441isRaw()
Query.php:430Tells if query's entities will be returned as an array (raw) instead of Entity
| retourne | bool |
listOnly()
Query.php:399Only list entities (return entity's id and properties needed in title and label)
| retourne | self |
listRequiredCollections($filter)
Query.php:239List all the other required collections needed for the query
loopRequiredCollection($repository, $schema, $path, $_recusivePath)
Query.php:202Recursion helper for listRequiredCollections: walks a single filter path's schema, yielding the collection behind each instance-typed segment it crosses -- including, for a computed 'label'/'title' segment (or when already recursing through one), the collections behind whatever properties that label/title template itself references.
nor($args)
Query.php:472Add one or more NOR-combined filter conditions. FilterGroup::nor
or($args)
Query.php:468Add one or more OR-combined filter conditions. FilterGroup::or
pagination($limit, $offset)
Query.php:450RemoveListener($handler)
statictEvent.php:91Remove the last added handler from the listeners.
resolveAliases()
Query.php:117Filter and sort on what an alias reads (Schema::storedPath): adresse/ville is adresses/default/ville, the path the repository stores. Run before the query is.
| retourne | void |
Send($args)
statictEvent.php:143Construct a new instance of this class with $args, then dispatch it to every listener.
setFields($value)
Query.php:372NOTE: same bug (and fix) as setSorts -- used to check $value[0] instead of $field[0], so a --prefixed field (meant to hide it) was only ever recognized when it was the very first field in the list; every other -field kept its literal - as part of the (wrong) key and was always marked visible.
SetListenerOrder($handler, $order)
statictEvent.php:75Change the order of an already-registered listener, whether added directly via AddListener or indirectly via ConnectListeners (which also stores its [$obj, $methodName] callables here).
setListOnly($value)
Query.php:421| $value | bool | |
| retourne | self | set isListOnly directly, without listOnly's other side effects (field/filter/sort setup). |
setOption($key, $value)
tWithOptions.php:77Set (or, with a null $value, remove) a single option.
| $key | string | |
| $value | mixed | if null, the option is unset entirely rather than being set to null |
| retourne | void |
setOptions($opts)
tWithOptions.php:30Replace the whole options bag.
setRaw($raw)
Query.php:435setReturn($entities)
Query.php:132- Voir
iSignal::setReturn-- e.g. for a listener to override the query's results.
setRootOperator($operator)
Query.php:477Change the root filter group's combining operator, wrapping the existing filters in a new group under $operator if it differs from the current one.
| $operator | GroupOperator | string | |
| retourne | self |
setSorts($value)
Query.php:281NOTE: this used to check $value[0] === '-' (the LIST's own first element) inside the foreach ($value as $field) loop, instead of $field[0] (the CURRENT field being examined) -- so, except for the first field in the list, a --prefixed field (meant to sort that field descending) was never recognized as such: the leading - stayed part of the (wrong) sort key, and every field got true (ascending) regardless.
sort($path, $asc)
Query.php:303NOTE: $asc used to be typed bool (non-nullable), so the $asc === null check below could never be true -- PHP rejects passing null for a non-nullable parameter with a TypeError before the method body ever runs -- making "remove this sort" (the clear intent, matching the identical, correctly ?bool-typed pattern in the sibling field method) completely unreachable. Fixed to ?bool.
__clone()
Query.php:141Deep-clones $filters (so mutating the clone's filters doesn't affect the original) and discards any already-run results (clearEntities).
| retourne | void |