src/BricomanBundle/EventListener/ActiveWireframeListener.php line 29

Open in your IDE?
  1. <?php
  2. /**
  3.  * Active Publishing - Creative Common CC BY 4.0
  4.  *   Full copyright and license information is available in
  5.  *   LICENSE.md which is distributed with this source code.
  6.  *
  7.  * @copyright Copyright (c) Active Publishing (https://activepublishing.fr)
  8.  * @license Creative Common CC BY 4.0
  9.  * @author Active Publishing <contact@active-publishing.fr>
  10.  */
  11. namespace BricomanBundle\EventListener;
  12. use Pimcore\Event\Model\ElementEventInterface;
  13. use Pimcore\Event\Model\DocumentEvent;
  14. use Pimcore\Model\DataObject;
  15. use Pimcore\Model\Document;
  16. /**
  17.  * Class ActivePaginatorListener
  18.  * @package BricomanBundle\EventListener
  19.  */
  20. class ActiveWireframeListener
  21. {
  22.     /**
  23.      * @param ElementEventInterface $e
  24.      * @throws \Exception
  25.      */
  26.     public function onPreUpdate (ElementEventInterface $e)
  27.     {
  28.         if ($e instanceof DocumentEvent) {
  29.             $document $e->getDocument();
  30.             $namespaceCatalog = [
  31.                 "@AP\ActiveWireframeBundle\Controller\CatalogController",
  32.                 "@ActiveWireframeBundle\Controller\CatalogController",
  33.                 "catalog"
  34.             ];
  35.             if (($document instanceof Document\Printcontainer)
  36.                 && (in_array($document->getController(), $namespaceCatalog))
  37.             ) {
  38.                 if ($document->hasProperty('active_paginate_link')) {
  39.                     $activePaginator $document->getProperty('active_paginate_link');
  40.                     if ($activePaginator instanceof DataObject\ActivePaginator) {
  41.                         $dateRef $activePaginator->getProperty('bricoman_date_referent_obj');
  42.                         $datePub $activePaginator->getProperty('bricoman_date_pub_obj');
  43.                         $document->setProperty('bricoman_date_pub_doc''text'$datePub);
  44.                         $document->setProperty('bricoman_date_referent_doc''text'$dateRef);
  45.                     }
  46.                 }
  47.             }
  48.         }
  49.     }
  50. }