Rendering process ================= |Rendering process|\ {: style=“width: 100%” } Trigger ------- The rendering process is normally **triggered through TypoScript** (using the ``ContentObjectRenderer``) by calling the ``DataProcessor``: \```typo3_typoscript linenums=“1” # Configuration/TypoScript/setup.typoscript tt_content.textmedia = USER tt_content.textmedia.userFunc = Fr:raw-latex:`\Sitepackage`:raw-latex:`\DataProcessing`:raw-latex:`\TextMediaProcessor` \``\` Fetch data ---------- In the next step the ``DataProcessor`` **gets the relevant data** from the ``DataProvider``: .. code:: php $data = $this->provider->get($this->cObj->data); Each ``DataProvider`` returns an object which implements the ```ProviderResponseInterface`` <%7B%7B%20repository.blob%20%7D%7D/Classes/Data/Response/ProviderResponseInterface.php>`__: \```php linenums=“1” # Classes/Data/Response/TextMediaProviderResponse.php namespace Fr:raw-latex:`\Sitepackage`:raw-latex:`\Data`:raw-latex:`\Response`; use Fr:raw-latex:`\Typo`3Handlebars:raw-latex:`\Data`:raw-latex:`\Response`:raw-latex:`\ProviderResponseInterface`; class TextMediaProviderResponse implements ProviderResponseInterface { /*\* \* @var string \*/ protected $layout = ’’; :: public function getLayout(): string { return $this->layout; } public function setLayout(string $layout): self { $this->layout = $layout; return $this; } // ... pubflic function toArray(): array { return [ 'layout' => $this->layout, // ... ]; } } \``\` Process data ------------ The provided data is now transferred to the ``Presenter``, which **prepares the data** for rendering and then **triggers the actual rendering**: .. code:: php $renderedTemplate = $this->presenter->present($data); return $renderedTemplate; It is up to the ``Presenter`` to trigger the rendering differently based on the given data: \```php linenums=“1” # Classes/Presenter/TextMediaPresenter.php namespace Fr:raw-latex:`\Sitepackage`:raw-latex:`\Presenter`; use Fr:raw-latex:`\Sitepackage`:raw-latex:`\Data`:raw-latex:`\Response`:raw-latex:`\TextMediaProviderResponse`; use Fr:raw-latex:`\Typo`3Handlebars:raw-latex:`\Data`:raw-latex:`\Response`:raw-latex:`\ProviderResponseInterface`; use Fr:raw-latex:`\Typo`3Handlebars:raw-latex:`\Presenter`:raw-latex:`\PresenterInterface`; class TextMediaPresenter implements PresenterInterface { public function present(ProviderResponseInterface :math:`data): string { if (!(`\ data instanceof TextMediaProviderResponse)) { throw new UnableToPresentException( ‘Received unexpected response from DataProvider.’, 1613552420 ); } if ($data->getLayout() === ‘wide’) { return :math:`this->presentWide(`\ data); } return :math:`this->presentNormal(`\ data); } :: protected function presentWide(TextMediaProviderResponse $data): string { return $this->renderer->render( 'Extensions/FluidStyledContent/TextMedia/Wide', $data->toArray() ); } protected function presentNormal(TextMediaProviderResponse $data): string { return $this->renderer->render( 'Extensions/FluidStyledContent/TextMedia/Normal', $data->toArray() ); } } \``\` Render template --------------- In the ``Renderer`` the **template path is now resolved** and the rendering is triggered. If the template is already in the cache, it will be treated preferentially. In any case, the **compiled template is cached** to speed up subsequent renderings. Finally, the rendered template is returned to the ``ContentObjectRenderer`` which triggered the ``DataProcessor`` from TypoScript. .. |Rendering process| image:: ../assets/img/rendering-chart.svg