Controller Plugin to assist in selecting an appropriate View Model type based on the User Agent's accept header.

category Zend
package Zend_Mvc
subpackage Controller

 Methods

Detects an appropriate viewmodel for request.

__invoke(array $matchAgainst, bool $returnDefault, \Zend\Http\Header\Accept\FieldValuePart\AbstractFieldValuePart | null $resultReference) : \Zend\View\Model\ModelInterface | null

Parameters

$matchAgainst

array

(optional) The Array to match against

$returnDefault

bool

(optional) If no match is available. Return default instead

$resultReference

\Zend\Http\Header\Accept\FieldValuePart\AbstractFieldValuePartnull

(optional) The object that was matched

Exceptions

\Zend\Mvc\Exception\InvalidArgumentException If the supplied and matched View Model could not be found

Returns

Get the current controller instance

getController() : null | \Zend\Stdlib\DispatchableInterface
Inherited

inherited_from \Zend\Mvc\Controller\Plugin\AbstractPlugin::getController()

Returns

Get the default Accept Types and View Model combinations to match against if none are specified.

getDefaultMatchAgainst() : array | null

Returns

arraynull

Set the default View Model (name) to return if no match could be made

getDefaultViewModelName() : string

Returns

string

Detects an appropriate viewmodel for request.

getViewModel(array $matchAgainst, bool $returnDefault, \Zend\Http\Header\Accept\FieldValuePart\AbstractFieldValuePart | null $resultReference) : \Zend\View\Model\ModelInterface | null

Parameters

$matchAgainst

array

(optional) The Array to match against

$returnDefault

bool

(optional) If no match is available. Return default instead

$resultReference

\Zend\Http\Header\Accept\FieldValuePart\AbstractFieldValuePartnull

(optional) The object that was matched

Exceptions

\Zend\Mvc\Exception\InvalidArgumentException If the supplied and matched View Model could not be found

Returns

Detects an appropriate viewmodel name for request.

getViewModelName(array $matchAgainst, bool $returnDefault, \Zend\Http\Header\Accept\FieldValuePart\AbstractFieldValuePart | null $resultReference) : \Zend\View\Model\ModelInterface | null

Parameters

$matchAgainst

array

(optional) The Array to match against

$returnDefault

bool

(optional) If no match is available. Return default instead

$resultReference

\Zend\Http\Header\Accept\FieldValuePart\AbstractFieldValuePartnull

(optional) The object that was matched.

Returns

\Zend\View\Model\ModelInterfacenullReturns null if $returnDefault = false and no match could be made

Detects an appropriate viewmodel name for request.

match(array $matchAgainst) : \Zend\Http\Header\Accept\FieldValuePart\AbstractFieldValuePart | null

Parameters

$matchAgainst

array

(optional) The Array to match against

Returns

Set the current controller instance

setController(\Zend\Stdlib\DispatchableInterface $controller) : void
Inherited

inherited_from \Zend\Mvc\Controller\Plugin\AbstractPlugin::setController()

Parameters

Set the default Accept Types and View Model combinations to match against if none are specified.

setDefaultMatchAgainst(array $matchAgainst) : \Zend\Mvc\Controller\Plugin\AcceptableViewModelSelector

Parameters

$matchAgainst

array

(optional) The Array to match against

Returns

Set the default View Model (name) to return if no match could be made

setDefaultViewModelName(string $defaultViewModelName) : \Zend\Mvc\Controller\Plugin\AcceptableViewModelSelector

Parameters

$defaultViewModelName

string

The default View Model name

Returns

Extract the viewmodel name from a match

extractViewModelName(\Zend\Http\Header\Accept\FieldValuePart\AbstractFieldValuePart $res) : string

Get the event

getEvent() : \Zend\Mvc\MvcEvent

Exceptions

\Zend\Mvc\Exception\DomainException if unable to find event

Returns

Get the request

getRequest() : \Zend\Http\Request

Exceptions

\Zend\Mvc\Exception\DomainException if unable to find request

Returns

Inject the viewmodel name into the accept header string

injectViewModelName(string $modelAcceptString, string $modelName) : string

Parameters

$modelAcceptString

string

$modelName

string

Returns

string

 Properties

 

$controller

$controller : null | \Zend\Stdlib\DispatchableInterface
Inherited

inherited_from \Zend\Mvc\Controller\Plugin\AbstractPlugin::$$controller
 

Default array to match against.

$defaultMatchAgainst : Array

 

<p>Default ViewModel</p>

$defaultViewModelName : string

 

$event

$event : \Zend\Mvc\MvcEvent

 

$request

$request : \Zend\Http\Request

 Constants

 

<p>the Key to inject the name of a viewmodel with in an Accept Header</p>

INJECT_VIEWMODEL_NAME : string