add admin page event doc
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Simon Vieille 2022-02-21 16:24:26 +01:00
parent 8c45315bfd
commit 2e4c1c3c6b

View file

@ -116,3 +116,35 @@ public function getMyBlock(): Block
return $this->getBlock('myBlock', CollectionBlock::class);
}
```
## Event
When a page is getting edited, options can be set this way:
```
// src/EventSuscriber/PageEventSubscriber.php
namespace App\EventSuscriber;
use App\Core\Event\Page\PageEditEvent;
use App\Entity\Page\YourPage;
class PageEventSubscriber implements EventSubscriberInterface
{
public static function getSubscribedEvents()
{
return [
PageEditEvent::FORM_INIT_EVENT => ['onFormInit'],
];
}
public function onFormInit(PageEditEvent $event)
{
if ($event->getPage() instanceof YourPage) {
$event->addPageBuilderOptions([
// options
]);
}
}
}
```