Use a collector when several callbacks should contribute independently. Register with addCollector() and call collect() with the arguments every callback needs.
For example, dashboard cards may come from several packages. Each package can return one card without knowing about the others.
public function collect(
string $hookPoint,
mixed ...$arguments,
): array
Use it when:
you want the raw contributions and will decide how to interpret them.
Applies to: Collectors
Returns: One raw callback result per listener, in priority and registration order.
With no listeners: An empty array is returned.
Exceptions: Exceptions from listeners bubble to the caller.
Configuration: No. It does not configure or change a processor or renderer.
The default priority is 10. collect() does not merge, flatten, process, or render the returned entries; choose those operations explicitly when you need them.
Every listener receives the same explicit arguments, and its return value becomes one entry in the result array:
The default priority is 10. Lower priorities run first, and equal priorities preserve registration order. With no listeners, a collector returns []:
<?php
declare(strict_types=1);
use Magdicom\Hooks;
$hooks=newHooks();
$results=$hooks->collect('navigation.items');
// []
Arguments are explicit. collect('navigation.items', $userId) passes $userId to every listener; Hooks does not keep a global parameter array or hidden invocation state.
removeCollector() removes the first matching callback at the requested priority. removeAllCollectors(?string $hookPoint = null) removes collector registrations in bulk.
collect() returns the raw result array. It does not need a processor or renderer.
process() collects results and passes them with a ProcessingContext to the configured processor. It throws MissingProcessorException when no processor is configured.
render() collects results and passes them to the configured renderer, which must return a string. Missing or invalid renderer configuration raises the documented renderer exceptions.
Processors and renderers apply to collectors only—not actions or filters. See processors and renderers for the released built-ins and their failure behavior.