<?php
namespace App\EventListener;
use Pimcore\Event\DocumentEvents;
use Pimcore\Event\Model\DocumentEvent;
use Pimcore\Model\Document;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
class DocumentListener implements EventSubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [
DocumentEvents::PRE_ADD => 'onPreAdd'
];
}
public function onPreAdd(DocumentEvent $documentEvent)
{
$currentDocument = $documentEvent->getDocument();
if ($currentDocument instanceof Document\Page) {
$currentDocument->setProperty('navigation_title', 'text', $currentDocument->getProperty('navigation_name'));
}
}
}