PHP Class Zend\Mvc\View\Http\RouteNotFoundStrategy

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

Protected Properties

Property Type Description
$displayExceptions boolean Whether or not to display exceptions related to the 404 condition
$displayNotFoundReason boolean Whether or not to display the reason for a 404
$notFoundTemplate string Template to use to report page not found conditions
$reason false | string The reason for a not-found condition

Public Methods

Method Description
attach ( Zend\EventManager\EventManagerInterface $events, $priority = 1 ) {@inheritDoc}
detectNotFoundError ( MvcEvent $e ) : void Detect if an error is a 404 condition
displayExceptions ( ) : boolean Should we display exceptions related to a not-found condition?
displayNotFoundReason ( ) : boolean Should we display the reason for a not-found condition?
getNotFoundTemplate ( ) : string Get template for not found conditions
prepareNotFoundViewModel ( MvcEvent $e ) : void Create and return a 404 view model
setDisplayExceptions ( boolean $displayExceptions ) : RouteNotFoundStrategy Set value indicating whether or not to display exceptions related to a not-found condition
setDisplayNotFoundReason ( boolean $displayNotFoundReason ) : RouteNotFoundStrategy Set value indicating whether or not to display the reason for a not-found condition
setNotFoundTemplate ( string $notFoundTemplate ) : RouteNotFoundStrategy Get template for not found conditions

Protected Methods

Method Description
injectController ( Zend\View\Model\ViewModel $model, MvcEvent $e ) : void Inject the controller and controller class into the model
injectException ( Zend\View\Model\ViewModel $model, MvcEvent $e ) : void Inject the exception message into the model
injectNotFoundReason ( Zend\View\Model\ViewModel $model ) : void Inject the not-found reason into the model

Method Details

attach() public method

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

detectNotFoundError() public method

If a "controller not found" or "invalid controller" error type is encountered, sets the response status code to 404.
public detectNotFoundError ( MvcEvent $e ) : void
$e Zend\Mvc\MvcEvent
return void

displayExceptions() public method

Should we display exceptions related to a not-found condition?
public displayExceptions ( ) : boolean
return boolean

displayNotFoundReason() public method

Should we display the reason for a not-found condition?
public displayNotFoundReason ( ) : boolean
return boolean

getNotFoundTemplate() public method

Get template for not found conditions
public getNotFoundTemplate ( ) : string
return string

injectController() protected method

If either $displayExceptions or $displayNotFoundReason are enabled, injects the controllerClass from the MvcEvent. It checks to see if a controller is present in the MvcEvent, and, if not, grabs it from the route match if present; if a controller is found, it injects it into the model.
protected injectController ( Zend\View\Model\ViewModel $model, MvcEvent $e ) : void
$model Zend\View\Model\ViewModel
$e Zend\Mvc\MvcEvent
return void

injectException() protected method

If $displayExceptions is enabled, and an exception is found in the event, inject it into the model.
protected injectException ( Zend\View\Model\ViewModel $model, MvcEvent $e ) : void
$model Zend\View\Model\ViewModel
$e Zend\Mvc\MvcEvent
return void

injectNotFoundReason() protected method

If $displayNotFoundReason is enabled, checks to see if $reason is set, and, if so, injects it into the model. If not, it injects Application::ERROR_CONTROLLER_CANNOT_DISPATCH.
protected injectNotFoundReason ( Zend\View\Model\ViewModel $model ) : void
$model Zend\View\Model\ViewModel
return void

prepareNotFoundViewModel() public method

Create and return a 404 view model
public prepareNotFoundViewModel ( MvcEvent $e ) : void
$e Zend\Mvc\MvcEvent
return void

setDisplayExceptions() public method

Set value indicating whether or not to display exceptions related to a not-found condition
public setDisplayExceptions ( boolean $displayExceptions ) : RouteNotFoundStrategy
$displayExceptions boolean
return RouteNotFoundStrategy

setDisplayNotFoundReason() public method

Set value indicating whether or not to display the reason for a not-found condition
public setDisplayNotFoundReason ( boolean $displayNotFoundReason ) : RouteNotFoundStrategy
$displayNotFoundReason boolean
return RouteNotFoundStrategy

setNotFoundTemplate() public method

Get template for not found conditions
public setNotFoundTemplate ( string $notFoundTemplate ) : RouteNotFoundStrategy
$notFoundTemplate string
return RouteNotFoundStrategy

Property Details

$displayExceptions protected property

Whether or not to display exceptions related to the 404 condition
protected bool $displayExceptions
return boolean

$displayNotFoundReason protected property

Whether or not to display the reason for a 404
protected bool $displayNotFoundReason
return boolean

$notFoundTemplate protected property

Template to use to report page not found conditions
protected string $notFoundTemplate
return string

$reason protected property

The reason for a not-found condition
protected false|string $reason
return false | string