Comment fonctionne le rendu de la homepage ?
This post is available in englishQuand on se rend sur le controller vendor/sylius/sylius/src/Sylius/Bundle/ShopBundle/Controller/HomepageController.php
on a ce résultat :
<?php
namespace Sylius\Bundle\ShopBundle\Controller;
use Symfony\Bundle\FrameworkBundle\Templating\EngineInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
final class HomepageController
{
/** @var EngineInterface */
private $templatingEngine;
public function __construct(EngineInterface $templatingEngine)
{
$this->templatingEngine = $templatingEngine;
}
public function indexAction(Request $request): Response
{
return $this->templatingEngine->renderResponse('@SyliusShop/Homepage/index.html.twig');
}
}
et voici ce que contient le contenu de index.html.twig qui est retourné par l'action :
{% extends '@SyliusShop/layout.html.twig' %}
{% block content %}
<div class="homepage">
<div class="ui hidden divider"></div>
{{ sylius_template_event('sylius.shop.homepage') }}
</div>
{% endblock %}
Pour trouver tout ce que rend la homepage il faut chercher l'event sylius.shop.homepage
. Il est dans le fichier le fichier vendor/sylius/sylius/src/Sylius/Bundle/ShopBundle/Resources/config/app/config.yml
qui va nous indiquer tous les templates qui sont appelés :
sylius.shop.homepage:
blocks:
banner:
template: "@SyliusShop/Homepage/_banner.html.twig"
priority: 60
latest_products:
template: "@SyliusShop/Homepage/_latestProducts.html.twig"
priority: 50
latest_products_carousel:
template: "@SyliusShop/Homepage/_latestProductsCarousel.html.twig"
priority: 40
newsletter:
template: "@SyliusShop/Homepage/_newsletter.html.twig"
priority: 30
products_grid:
template: "@SyliusShop/Homepage/_productsGrid.html.twig"
priority: 20
about_us:
template: "@SyliusShop/Homepage/_aboutUs.html.twig"
priority: 10
Voici donc la liste des templates qui sont sur la homepage