Skip to content

Controllers

By configuring a controller you can modify and enhance the way in which the built-in content view controller renders content.

You indicate which controller to use in the content view configuration, under the controller key:

1
2
3
4
5
                    article:
                        controller: App\Controller\RelationController::showContentAction
                        template: '@ezdesign/full/article.html.twig'
                        match:
                            Identifier\ContentType: article
1
2
3
4
5
6
7
namespace App\Controller;

use eZ\Publish\API\Repository\ContentService;
use eZ\Publish\API\Repository\LocationService;
use eZ\Publish\Core\MVC\Symfony\View\View;

class RelationController

For a full example of using a custom controller, see Embed content.

If you do not want to use the default view controller and only use a custom one, use the same configuration, but do not provide the template key. You have to indicate the template to use from the controller itself.

Permissions for custom controllers

See permission documentation for information about access control for custom controllers.