Details
-
Bug
-
Resolution: Fixed
-
High
-
2.4.2, 2.5.1
-
None
Description
Every block rendered on the Landing Page dispatch PreRenderEvent twice.
Steps to reproduce
1. Clean installation of eZ Platform 2.5
2. Create a new custom block testblock
ezplatform_page_fieldtype: blocks: testblock: name: 'Test Block' thumbnail: '/bundles/ezplatformadminui/img/ez-icons.svg#contentlist' views: default: template: 'AppBundle:blocks:testblock.html.twig' name: 'Default block template'
3. Create AppBundle:blocks:testblock.html.twig with contents:
<h2>Testblock</h2>
4. Create src/AppBundle/EventListener/PreBlockRenderEvents/TestblockPreBlockRenderEvent.php:
<?php declare(strict_types=1); namespace AppBundle\EventListener\PreBlockRenderEvents; use EzSystems\EzPlatformPageFieldType\FieldType\Page\Block\Renderer\Event\PreRenderEvent; class TestblockPreBlockRenderEvent { /** * @param PreRenderEvent $event */ public function onPreRenderBlock(PreRenderEvent $event): void { dump($event); } }
5. In services.yml add:
AppBundle\EventListener\PreBlockRenderEvents\TestblockPreBlockRenderEvent: tags: - { name: kernel.event_listener, event: ezplatform.ezlandingpage.block.render.testblock.pre, method: onPreRenderBlock }
6. Create a LandingPage, place testblock once in it. Publish it.
7. On frontend open previously created Landing Page in dev enviroment.
Result
In the toolbar at the bottom, you can notice that dump() was called twice.