1424. Class

1424.1. Zend\Mvc\Controller\Plugin\AcceptableViewModelSelector

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

1424.1.1. Methods

1424.1.1.1. __invoke

__invoke()

Detects an appropriate viewmodel for request.

Parameters:
  • array – (optional) The Array to match against
  • bool – (optional) If no match is available. Return default instead
  • AbstractFieldValuePart|null – (optional) The object that was matched
Throws InvalidArgumentException:
 

If the supplied and matched View Model could not be found

Return type:

ModelInterface|null

1424.1.1.2. getViewModel

getViewModel()

Detects an appropriate viewmodel for request.

Parameters:
  • array – (optional) The Array to match against
  • bool – (optional) If no match is available. Return default instead
  • AbstractFieldValuePart|null – (optional) The object that was matched
Throws InvalidArgumentException:
 

If the supplied and matched View Model could not be found

Return type:

ModelInterface|null

1424.1.1.3. getViewModelName

getViewModelName()

Detects an appropriate viewmodel name for request.

Parameters:
  • array – (optional) The Array to match against
  • bool – (optional) If no match is available. Return default instead
  • AbstractFieldValuePart|null – (optional) The object that was matched.
Return type:

ModelInterface|null Returns null if $returnDefault = false and no match could be made

1424.1.1.4. match

match()

Detects an appropriate viewmodel name for request.

Parameters:array – (optional) The Array to match against
Return type:AbstractFieldValuePart|null The object that was matched

1424.1.1.5. setDefaultViewModelName

setDefaultViewModelName()

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

Parameters:string – The default View Model name
Return type:AcceptableViewModelSelector provides fluent interface

1424.1.1.6. getDefaultViewModelName

getDefaultViewModelName()

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

Return type:string

1424.1.1.7. setDefaultMatchAgainst

setDefaultMatchAgainst()

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

Parameters:array – (optional) The Array to match against
Return type:AcceptableViewModelSelector provides fluent interface

1424.1.1.8. getDefaultMatchAgainst

getDefaultMatchAgainst()

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

Return type:array|null

1424.1.1.9. injectViewModelName

injectViewModelName()

Inject the viewmodel name into the accept header string

Parameters:
  • string
  • string
Return type:

string

1424.1.1.10. extractViewModelName

extractViewModelName()

Extract the viewmodel name from a match

Parameters:AbstractFieldValuePart
Return type:string

1424.1.1.11. getRequest

getRequest()

Get the request

Return type:Request
Throws :DomainException if unable to find request

1424.1.1.12. getEvent

getEvent()

Get the event

Return type:MvcEvent
Throws :DomainException if unable to find event

1424.1.2. Constants

1424.1.2.1. INJECT_VIEWMODEL_NAME

@var string the Key to inject the name of a viewmodel with in an Accept Header