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

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 <thomas.rabaix@sonata-project.org>
  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. use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy;
  21. /**
  22.  * @final since sonata-project/admin-bundle 3.52
  23.  *
  24.  * @author Thomas Rabaix <thomas.rabaix@sonata-project.org>
  25.  */
  26. class AdminEventExtension extends AbstractAdminExtension
  27. {
  28.     protected $eventDispatcher;
  29.     public function __construct(EventDispatcherInterface $eventDispatcher)
  30.     {
  31.         $this->eventDispatcher LegacyEventDispatcherProxy::decorate($eventDispatcher);
  32.     }
  33.     public function configureFormFields(FormMapper $form)
  34.     {
  35.         $this->eventDispatcher->dispatch(
  36.             new ConfigureEvent($form->getAdmin(), $formConfigureEvent::TYPE_FORM),
  37.             'sonata.admin.event.configure.form'
  38.         );
  39.     }
  40.     public function configureListFields(ListMapper $list)
  41.     {
  42.         $this->eventDispatcher->dispatch(
  43.             new ConfigureEvent($list->getAdmin(), $listConfigureEvent::TYPE_LIST),
  44.             'sonata.admin.event.configure.list'
  45.         );
  46.     }
  47.     public function configureDatagridFilters(DatagridMapper $filter)
  48.     {
  49.         $this->eventDispatcher->dispatch(
  50.             new ConfigureEvent($filter->getAdmin(), $filterConfigureEvent::TYPE_DATAGRID),
  51.             'sonata.admin.event.configure.datagrid'
  52.         );
  53.     }
  54.     public function configureShowFields(ShowMapper $show)
  55.     {
  56.         $this->eventDispatcher->dispatch(
  57.             new ConfigureEvent($show->getAdmin(), $showConfigureEvent::TYPE_SHOW),
  58.             'sonata.admin.event.configure.show'
  59.         );
  60.     }
  61.     public function configureQuery(AdminInterface $adminProxyQueryInterface $query$context 'list')
  62.     {
  63.         $this->eventDispatcher->dispatch(
  64.             new ConfigureQueryEvent($admin$query$context),
  65.             'sonata.admin.event.configure.query'
  66.         );
  67.     }
  68.     public function preUpdate(AdminInterface $admin$object)
  69.     {
  70.         $this->eventDispatcher->dispatch(
  71.             new PersistenceEvent($admin$objectPersistenceEvent::TYPE_PRE_UPDATE),
  72.             'sonata.admin.event.persistence.pre_update'
  73.         );
  74.     }
  75.     public function postUpdate(AdminInterface $admin$object)
  76.     {
  77.         $this->eventDispatcher->dispatch(
  78.             new PersistenceEvent($admin$objectPersistenceEvent::TYPE_POST_UPDATE),
  79.             'sonata.admin.event.persistence.post_update'
  80.         );
  81.     }
  82.     public function prePersist(AdminInterface $admin$object)
  83.     {
  84.         $this->eventDispatcher->dispatch(
  85.             new PersistenceEvent($admin$objectPersistenceEvent::TYPE_PRE_PERSIST),
  86.             'sonata.admin.event.persistence.pre_persist'
  87.         );
  88.     }
  89.     public function postPersist(AdminInterface $admin$object)
  90.     {
  91.         $this->eventDispatcher->dispatch(
  92.             new PersistenceEvent($admin$objectPersistenceEvent::TYPE_POST_PERSIST),
  93.             'sonata.admin.event.persistence.post_persist'
  94.         );
  95.     }
  96.     public function preRemove(AdminInterface $admin$object)
  97.     {
  98.         $this->eventDispatcher->dispatch(
  99.             new PersistenceEvent($admin$objectPersistenceEvent::TYPE_PRE_REMOVE),
  100.             'sonata.admin.event.persistence.pre_remove'
  101.         );
  102.     }
  103.     public function postRemove(AdminInterface $admin$object)
  104.     {
  105.         $this->eventDispatcher->dispatch(
  106.             new PersistenceEvent($admin$objectPersistenceEvent::TYPE_POST_REMOVE),
  107.             'sonata.admin.event.persistence.post_remove'
  108.         );
  109.     }
  110. }