Uploaded image for project: 'eZ Platform Enterprise Edition'
  1. eZ Platform Enterprise Edition
  2. EZEE-2783

On frontend PreRenderEvent is dispatched twice for every block

    XMLWordPrintable

Details

    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.

      Attachments

        Activity

          People

            Unassigned Unassigned
            mateusz.bieniek@ibexa.co Mateusz Bieniek
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: