\Charcoal\AppCallableResolverAwareTrait

Resolve Callable

This trait enables the resolution of 'class:method' strings into a closure. This class is based on \Slim\CallableResolverAwareTrait.

The resolver will attempt checks on the current class, an optional alternate object, the DI container.

Can resolve the following string formats:

  • 'class:method'
  • 'parent:method'
  • 'static:method'
  • 'self:method' or ':method'

Summary

Methods
Properties
Constants
No public methods found
No public properties found
No constants found
setCallableResolver()
resolveCallable()
$resolvedCallableCache
$callablePattern
$callableResolver
N/A
No private methods found
No private properties found
N/A

Properties

$resolvedCallableCache

$resolvedCallableCache : array

The cache of string-based callables.

Type

array

$callablePattern

$callablePattern : string

A regular expression for matching 'class:method' callable strings.

Type

string

$callableResolver

$callableResolver : \Slim\Interfaces\CallableResolverInterface

Store the callable resolver.

Type

\Slim\Interfaces\CallableResolverInterface

Methods

setCallableResolver()

setCallableResolver(\Slim\Interfaces\CallableResolverInterface  $resolver) : self

Set a callable resolver.

Parameters

\Slim\Interfaces\CallableResolverInterface $resolver

A callable resolver.

Returns

self

resolveCallable()

resolveCallable(callable|string  $callable, object|null  $context = null) : \Closure

Resolve a string of the format 'class:method' into a closure that the router can dispatch.

Parameters

callable|string $callable

A callable function or method, either as a reference or string.

object|null $context

Optional. An additional context under to test $callable as a method.

Throws

\RuntimeException

If the string cannot be resolved as a callable or the resolver was not previously set.

Returns

\Closure