Epic layout small components with Twig #33101
Labels
EPIC
Macro-level issue gathering improvements & bugs related to a specific topic
Symfony layout
Task
Type: neither a bug or a feature
The base smarty layout
admin-dev/themes/new-theme/template/layout.tpl
is composed of multiple small blocks. To migrate the whole layout progressively to Twig we're gonna handle those blocks piece by piece and split them into small components.We will rely on the Symfony UX Twg component to handle them, you can see an example of this implementation in this POC PR
To allow merging in advance the modifications and avoid too many conflicts resolving on a dedicated branch we'll use a feature flag to enable/disable the Symfony layout feature (all the components are bound to the same feature flag).
Step 1 - create Twig component and identify their dependencies
The initial PR will introduce a
render_template
smarty method, this method is able to either render the old smarty block or the new Twig component. The first step of this migration is to create the Twig components (rendered via a temporary twig file), the method will need these parameters:The
@PrestaShop/Admin/Layout/quick_access.html.twig
template is only used to render the component:In step 1 all the required variables are passed manually from Smarty.
Step 2 - Make the components independent
The second step is about making the component independent, all the data it needs to fetch should be handled internally via some repositories, some context services, ... We only keep some manually injected variables if the component is meant to be used often with different options from the template so that it can adapt to several use cases.
The variables passed to the template should be lazy loaded as much as possible, this way when the component is not displayed no need to fetch the data.
The purpose, as much as possible, is that the component will then be rendered without requiring some inputs:
{{ component('QuickAccess') }}
Twig components
<head></head>
) #33103php_errors
#33088Independent twig components
head></head>
) #33183Not required to finish the EPIC
The text was updated successfully, but these errors were encountered: