<?php
/**
* Active Publishing - Creative Common CC BY 4.0
* Full copyright and license information is available in
* LICENSE.md which is distributed with this source code.
*
* @copyright Copyright (c) Active Publishing (https://activepublishing.fr)
* @license Creative Common CC BY 4.0
* @author Active Publishing <contact@active-publishing.fr>
*/
namespace BricomanBundle\EventListener;
use Pimcore\Event\Model\ElementEventInterface;
use Pimcore\Event\Model\DocumentEvent;
use Pimcore\Model\DataObject;
use Pimcore\Model\Document;
/**
* Class ActivePaginatorListener
* @package BricomanBundle\EventListener
*/
class ActiveWireframeListener
{
/**
* @param ElementEventInterface $e
* @throws \Exception
*/
public function onPreUpdate (ElementEventInterface $e)
{
if ($e instanceof DocumentEvent) {
$document = $e->getDocument();
$namespaceCatalog = [
"@AP\ActiveWireframeBundle\Controller\CatalogController",
"@ActiveWireframeBundle\Controller\CatalogController",
"catalog"
];
if (($document instanceof Document\Printcontainer)
&& (in_array($document->getController(), $namespaceCatalog))
) {
if ($document->hasProperty('active_paginate_link')) {
$activePaginator = $document->getProperty('active_paginate_link');
if ($activePaginator instanceof DataObject\ActivePaginator) {
$dateRef = $activePaginator->getProperty('bricoman_date_referent_obj');
$datePub = $activePaginator->getProperty('bricoman_date_pub_obj');
$document->setProperty('bricoman_date_pub_doc', 'text', $datePub);
$document->setProperty('bricoman_date_referent_doc', 'text', $dateRef);
}
}
}
}
}
}