Spork Code Libraries

AccessDeniedStrategy

Displays an access denied error page if the response status is 403.

If the MvcEvent::Response status has been set to 403 it creates a View Model to render the access denied template, inserts it into the MvcEvent and ends propagation of the dispatch event.

If self::renderLayout is true it will also inject the access denied View Model into the layout View Model. IMPORTANT make sure your layout never contains any sensitive information before you enable this.

Configuration Example array(

'access_denied_strategy' => array(
    'renderLayout' => BOOLEAN,
    'template' => template/alias/or/path,
)

);

Extends
\Zend\EventManager\AbstractListenerAggregate

Constants

CONFIG_KEY

CONFIG_KEY

Properties

$renderLayout

$renderLayout : boolean

Should access denied template be rendered inside layout.

Type

boolean

$template

$template : string

Alias or path to access denied template

Type

string

Methods

attach()

attach(\Zend\EventManager\EventManagerInterface  $events) 

Attach event

Parameters

\Zend\EventManager\EventManagerInterface $events
See also

getRenderLayout()

getRenderLayout() : boolean

Get render layout flag

Returns

boolean

getTemplate()

getTemplate() : string

Get access denied template

Returns

string

setTemplate()

setTemplate(\Spork\Mvc\Listener\unknown  $template) : \Spork\Mvc\Listener\AccessDeniedStrategy

Set access denied template

Parameters

\Spork\Mvc\Listener\unknown $template

Returns

\Spork\Mvc\Listener\AccessDeniedStrategy

detectAccessDenied()

detectAccessDenied(\Zend\Mvc\MvcEvent  $event) 

If response status code is 403 set error state and stop event propagation

Parameters

\Zend\Mvc\MvcEvent $event

injectAccessDeniedViewModel()

injectAccessDeniedViewModel(\Zend\Mvc\MvcEvent  $event) 

Inject access denied View Model is response status is 403

Parameters

\Zend\Mvc\MvcEvent $event

config()

config(\Zend\Mvc\MvcEvent  $event) 

Set configuration options from application configuration

Parameters

\Zend\Mvc\MvcEvent $event