PHP Class Zend\Mvc\View\Http\InjectTemplateListener

Inheritance: extends Zend\EventManager\AbstractListenerAggregate
Show file Open project: zendframework/zend-mvc Class Usage Examples

Protected Properties

Property Type Description
$controllerMap array Array of controller namespace -> template mappings
$preferRouteMatchController boolean Flag to force the use of the route match controller param

Public Methods

Method Description
attach ( Zend\EventManager\EventManagerInterface $events, $priority = 1 ) {@inheritDoc}
injectTemplate ( MvcEvent $e ) : void Inject a template into the view model, if none present
isPreferRouteMatchController ( ) : boolean
mapController ( string $controller ) : string | false Maps controller to template if controller namespace is whitelisted or mapped
setControllerMap ( array $map ) : self Set map of controller namespace -> template pairs
setPreferRouteMatchController ( boolean $preferRouteMatchController ) Sets the flag to instruct the listener to prefer the route match controller param over the class name

Protected Methods

Method Description
deriveControllerClass ( string $controller ) : string Determine the name of the controller
inflectName ( string $name ) : string Inflect a name to a normalized value

Method Details

attach() public method

{@inheritDoc}
public attach ( Zend\EventManager\EventManagerInterface $events, $priority = 1 )
$events Zend\EventManager\EventManagerInterface

deriveControllerClass() protected method

Strip the namespace, and the suffix "Controller" if present.
protected deriveControllerClass ( string $controller ) : string
$controller string
return string

inflectName() protected method

Inlines the logic from zend-filter's Word\CamelCaseToDash filter.
protected inflectName ( string $name ) : string
$name string
return string

injectTemplate() public method

Template is derived from the controller found in the route match, and, optionally, the action, if present.
public injectTemplate ( MvcEvent $e ) : void
$e Zend\Mvc\MvcEvent
return void

isPreferRouteMatchController() public method

mapController() public method

Maps controller to template if controller namespace is whitelisted or mapped
public mapController ( string $controller ) : string | false
$controller string controller FQCN
return string | false template name or false if controller was not matched

setControllerMap() public method

Set map of controller namespace -> template pairs
public setControllerMap ( array $map ) : self
$map array
return self

setPreferRouteMatchController() public method

Sets the flag to instruct the listener to prefer the route match controller param over the class name
public setPreferRouteMatchController ( boolean $preferRouteMatchController )
$preferRouteMatchController boolean

Property Details

$controllerMap protected property

Array of controller namespace -> template mappings
protected array $controllerMap
return array

$preferRouteMatchController protected property

Flag to force the use of the route match controller param
protected bool $preferRouteMatchController
return boolean