src/EventListener/DocumentListener.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\EventListener;
  3. use Pimcore\Event\DocumentEvents;
  4. use Pimcore\Event\Model\DocumentEvent;
  5. use Pimcore\Model\Document;
  6. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  7. class DocumentListener implements EventSubscriberInterface
  8. {
  9.     public static function getSubscribedEvents(): array
  10.     {
  11.         return [
  12.             DocumentEvents::PRE_ADD => 'onPreAdd'
  13.         ];
  14.     }
  15.     public function onPreAdd(DocumentEvent $documentEvent)
  16.     {
  17.         $currentDocument $documentEvent->getDocument();
  18.         if ($currentDocument instanceof Document\Page) {
  19.             $currentDocument->setProperty('navigation_title''text'$currentDocument->getProperty('navigation_name'));
  20.         }
  21.     }
  22. }