View\Manager & View\Provider
The role of the (eZ\Publish\Core\MVC\Symfony\)View\Manager is to select the right template for displaying a given content or location. It aggregates objects called content and location view providers which respectively implement eZ\Publish\Core\MVC\Symfony\View\Provider\Content and eZ\Publish\Core\MVC\Symfony\View\Provider\Location interfaces.
Each time a content is to be displayed through the Content\ViewController, the View\Manager iterates over the registered content or location View\Provider objects and calls getView().
Provided View\Provider implementations
| Name | Usage |
|---|---|
View provider configuration | Based on application configuration. |
| Forwards view selection to the legacy kernel by running the old content/view module. |
Custom View\Provider
Difference between View\Provider\Location and View\Provider\Content
- A
View\Provider\Locationonly deals withLocationobjects and implementseZ\Publish\Core\MVC\Symfony\View\Provider\Locationinterface. - A
View\Provider\Contentonly deals withContentInfoobjects and implementseZ\Publish\Core\MVC\Symfony\View\Provider\Contentinterface.
When to develop a custom View\Provider\(Location|Content)
- You want a custom template selection based on a very specific state of your application
- You depend on external resources for view selection
- You want to override the default one (based on configuration) for some reason
View\Provider objects need to be properly registered in the service container with the exponential.location_view_provider or exponential.content_view_provider service tag.
| Tag attribute name | Usage |
|---|---|
| priority | An integer giving the priority to the The priority range is from -255 to 255 |
Example