Returning a response
All controller classes contain an __invoke()
method that is called when a request terminates at that controller. The __invoke()
method must return a Response
object.
The Photon\Core\Controller\Page
class of the PhotonCoreBundle
project that all Photon Page controllers extend provides a method render()
that returns a formatted Response
object.
render()
generally takes two arguments:
- the path to the Twig template to be rendered
- an array of values to be supplied to the template
Further details on Response objects are provided by the Symfony documentation - Response.
<?php
return $this->render(
'article.html.twig',
[
'page' => $page,
'page_categoryId' => $categoryId,
'page_contentType' => 1,
'page_translationItem' => $document->getId(),
'page_translationType'=> 'document',
'page_structure' => $pageStructure,
]
);