vendor/sonata-project/admin-bundle/src/Event/AdminEventExtension.php line 30

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4.  * This file is part of the Sonata Project package.
  5.  *
  6.  * (c) Thomas Rabaix <[email protected]>
  7.  *
  8.  * For the full copyright and license information, please view the LICENSE
  9.  * file that was distributed with this source code.
  10.  */
  11. namespace Sonata\AdminBundle\Event;
  12. use Sonata\AdminBundle\Admin\AbstractAdminExtension;
  13. use Sonata\AdminBundle\Admin\AdminInterface;
  14. use Sonata\AdminBundle\Datagrid\DatagridMapper;
  15. use Sonata\AdminBundle\Datagrid\ListMapper;
  16. use Sonata\AdminBundle\Datagrid\ProxyQueryInterface;
  17. use Sonata\AdminBundle\Form\FormMapper;
  18. use Sonata\AdminBundle\Show\ShowMapper;
  19. use Symfony\Component\EventDispatcher\EventDispatcherInterface;
  20. /**
  21.  * @final since sonata-project/admin-bundle 3.52
  22.  *
  23.  * @author Thomas Rabaix <[email protected]>
  24.  */
  25. class AdminEventExtension extends AbstractAdminExtension
  26. {
  27.     protected $eventDispatcher;
  28.     public function __construct(EventDispatcherInterface $eventDispatcher)
  29.     {
  30.         $this->eventDispatcher $eventDispatcher;
  31.     }
  32.     public function configureFormFields(FormMapper $form)
  33.     {
  34.         $this->eventDispatcher->dispatch(
  35.             'sonata.admin.event.configure.form',
  36.             new ConfigureEvent($form->getAdmin(), $formConfigureEvent::TYPE_FORM)
  37.         );
  38.     }
  39.     public function configureListFields(ListMapper $list)
  40.     {
  41.         $this->eventDispatcher->dispatch(
  42.             'sonata.admin.event.configure.list',
  43.             new ConfigureEvent($list->getAdmin(), $listConfigureEvent::TYPE_LIST)
  44.         );
  45.     }
  46.     public function configureDatagridFilters(DatagridMapper $filter)
  47.     {
  48.         $this->eventDispatcher->dispatch(
  49.             'sonata.admin.event.configure.datagrid',
  50.             new ConfigureEvent($filter->getAdmin(), $filterConfigureEvent::TYPE_DATAGRID)
  51.         );
  52.     }
  53.     public function configureShowFields(ShowMapper $show)
  54.     {
  55.         $this->eventDispatcher->dispatch(
  56.             'sonata.admin.event.configure.show',
  57.             new ConfigureEvent($show->getAdmin(), $showConfigureEvent::TYPE_SHOW)
  58.         );
  59.     }
  60.     public function configureQuery(AdminInterface $adminProxyQueryInterface $query$context 'list')
  61.     {
  62.         $this->eventDispatcher->dispatch(
  63.             'sonata.admin.event.configure.query',
  64.             new ConfigureQueryEvent($admin$query$context)
  65.         );
  66.     }
  67.     public function preUpdate(AdminInterface $admin$object)
  68.     {
  69.         $this->eventDispatcher->dispatch(
  70.             'sonata.admin.event.persistence.pre_update',
  71.             new PersistenceEvent($admin$objectPersistenceEvent::TYPE_PRE_UPDATE)
  72.         );
  73.     }
  74.     public function postUpdate(AdminInterface $admin$object)
  75.     {
  76.         $this->eventDispatcher->dispatch(
  77.             'sonata.admin.event.persistence.post_update',
  78.             new PersistenceEvent($admin$objectPersistenceEvent::TYPE_POST_UPDATE)
  79.         );
  80.     }
  81.     public function prePersist(AdminInterface $admin$object)
  82.     {
  83.         $this->eventDispatcher->dispatch(
  84.             'sonata.admin.event.persistence.pre_persist',
  85.             new PersistenceEvent($admin$objectPersistenceEvent::TYPE_PRE_PERSIST)
  86.         );
  87.     }
  88.     public function postPersist(AdminInterface $admin$object)
  89.     {
  90.         $this->eventDispatcher->dispatch(
  91.             'sonata.admin.event.persistence.post_persist',
  92.             new PersistenceEvent($admin$objectPersistenceEvent::TYPE_POST_PERSIST)
  93.         );
  94.     }
  95.     public function preRemove(AdminInterface $admin$object)
  96.     {
  97.         $this->eventDispatcher->dispatch(
  98.             'sonata.admin.event.persistence.pre_remove',
  99.             new PersistenceEvent($admin$objectPersistenceEvent::TYPE_PRE_REMOVE)
  100.         );
  101.     }
  102.     public function postRemove(AdminInterface $admin$object)
  103.     {
  104.         $this->eventDispatcher->dispatch(
  105.             'sonata.admin.event.persistence.post_remove',
  106.             new PersistenceEvent($admin$objectPersistenceEvent::TYPE_POST_REMOVE)
  107.         );
  108.     }
  109. }