add admin page event doc
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
8c45315bfd
commit
2e4c1c3c6b
|
@ -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
|
||||
]);
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
|
Loading…
Reference in a new issue