Zend\Mvc\Controller\Plugin\AcceptableViewModelSelector
Controller Plugin to assist in selecting an appropriate View Model type based on the User Agent's accept header.
Synopsis
class AcceptableViewModelSelector
extends AbstractPlugin
{
- // constants
- const INJECT_VIEWMODEL_NAME = '_internalViewModel';
- // members
- protected MvcEvent $event;
- protected Request $request;
- protected Array $defaultMatchAgainst;
- protected string $defaultViewModelName;
- // Inherited members from AbstractPlugin
- protected null|Dispatchable $controller;
- // methods
- public ModelInterface|null __invoke()
- public ModelInterface|null getViewModel()
- public ModelInterface|null getViewModelName()
- public AbstractFieldValuePart|null match()
- public AcceptableViewModelSelector setDefaultViewModelName()
- public string getDefaultViewModelName()
- public AcceptableViewModelSelector setDefaultMatchAgainst()
- public array|null getDefaultMatchAgainst()
- protected string injectViewModelName()
- protected string extractViewModelName()
- protected Request getRequest()
- protected MvcEvent getEvent()
- // Inherited methods from AbstractPlugin
- public void setController()
- public null|Dispatchable getController()
Hierarchy
Constants
Name | Value |
---|---|
INJECT_VIEWMODEL_NAME | '_internalViewModel' |
Members
protected
- $controller — Zend\Mvc\Controller\Plugin\null|Dispatchable
- $defaultMatchAgainst
—
Zend\Mvc\Controller\Plugin\Array
Default array to match against. - $defaultViewModelName — string
- $event — \Zend\Mvc\MvcEvent
- $request — \Zend\Http\Request
Methods
protected
- extractViewModelName() — Extract the viewmodel name from a match
- getEvent() — Get the event
- getRequest() — Get the request
- injectViewModelName() — Inject the viewmodel name into the accept header string
public
- __invoke() — Detects an appropriate viewmodel for request.
- getDefaultMatchAgainst() — Get the default Accept Types and View Model combinations to match against if none are specified.
- getDefaultViewModelName() — Set the default View Model (name) to return if no match could be made
- getViewModel() — Detects an appropriate viewmodel for request.
- getViewModelName() — Detects an appropriate viewmodel name for request.
- match() — Detects an appropriate viewmodel name for request.
- setDefaultMatchAgainst() — Set the default Accept Types and View Model combinations to match against if none are specified.
- setDefaultViewModelName() — Set the default View Model (name) to return if no match could be made
Inherited from Zend\Mvc\Controller\Plugin\AbstractPlugin
public
- getController() — Get the current controller instance
- setController() — Set the current controller instance