Documentation

ContainerLocator
in package
implements HandlerLocator

Fetch handler instances from an in-memory collection.

This locator allows you to bind a handler FQCN to receive commands of a certain command name.

Interfaces, Classes and Traits

HandlerLocator
Service locator for handler objects

Table of Contents

$commandNameToHandlerMap  : array<string|int, mixed>
The collection of Command/CommandHandler
$container  : ContainerInterface
__construct()  : mixed
addHandler()  : mixed
Bind a handler instance to receive all commands with a certain class
addHandlers()  : mixed
Allows you to add multiple handlers at once.
getHandlerForCommand()  : object
Retrieves the handler for a specified command

Properties

$commandNameToHandlerMap

The collection of Command/CommandHandler

protected array<string|int, mixed> $commandNameToHandlerMap = []

Methods

__construct()

public __construct(ContainerInterface $container[, array<string|int, mixed> $commandNameToHandlerMap = [] ]) : mixed
Parameters
$container : ContainerInterface
$commandNameToHandlerMap : array<string|int, mixed> = []
Return values
mixed

addHandler()

Bind a handler instance to receive all commands with a certain class

public addHandler(string $handler, string $commandName) : mixed
Parameters
$handler : string

Handler to receive class

$commandName : string

Can be a class name or name of a NamedCommand

Return values
mixed

addHandlers()

Allows you to add multiple handlers at once.

public addHandlers(array<string|int, mixed> $commandNameToHandlerMap) : mixed

The map should be an array in the format of: [ 'AddTaskCommand' => 'AddTaskCommandHandler', 'CompleteTaskCommand' => 'CompleteTaskCommandHandler', ]

Parameters
$commandNameToHandlerMap : array<string|int, mixed>
Return values
mixed

getHandlerForCommand()

Retrieves the handler for a specified command

public getHandlerForCommand(string $commandName) : object
Parameters
$commandName : string
Tags
throws
MissingHandlerException
Return values
object

Search results