Documentation

CallableLocator
in package
implements HandlerLocator

This locator loads Handlers from a provided callable.

At first glance, this might seem fairly useless but it's actually very useful to encapsulate DI containers without having to write a custom adapter for each one.

Let's say you have a Symfony container or similar that works via a 'get' method. You can pass in an array style callable such as:

$locator = new CallableLocator([$container, 'get'])

This is easy to set up and will now automatically pipe the command name straight through to the $container->get() method without having to write the custom locator.

Naturally, you can also pass in closures for further behavior tweaks.

Table of Contents

Interfaces

HandlerLocator
Service locator for handler objects

Properties

$callable  : callable

Methods

__construct()  : mixed
getHandlerForCommand()  : object
Retrieves the handler for a specified command

Properties

Methods

__construct()

public __construct(callable $callable) : mixed
Parameters
$callable : callable

getHandlerForCommand()

Retrieves the handler for a specified command

public getHandlerForCommand(mixed $commandName) : object
Parameters
$commandName : mixed
Return values
object

        
On this page

Search results