fsi-open /
admin-bundle
| 1 | <?php |
||
| 2 | |||
| 3 | /** |
||
| 4 | * (c) FSi sp. z o.o. <[email protected]> |
||
| 5 | * |
||
| 6 | * For the full copyright and license information, please view the LICENSE |
||
| 7 | * file that was distributed with this source code. |
||
| 8 | */ |
||
| 9 | |||
| 10 | declare(strict_types=1); |
||
| 11 | |||
| 12 | namespace FSi\Bundle\AdminBundle\Admin\CRUD\Context\Request; |
||
| 13 | |||
| 14 | use FSi\Bundle\AdminBundle\Admin\Context\Request\AbstractFormValidRequestHandler; |
||
| 15 | use FSi\Bundle\AdminBundle\Event\AdminEvent; |
||
| 16 | use FSi\Bundle\AdminBundle\Event\FormEvent; |
||
| 17 | use FSi\Bundle\AdminBundle\Event\FormEvents; |
||
| 18 | use Symfony\Component\HttpFoundation\Request; |
||
| 19 | use Symfony\Component\HttpFoundation\Response; |
||
| 20 | |||
| 21 | class FormValidRequestHandler extends AbstractFormValidRequestHandler |
||
| 22 | { |
||
| 23 | protected function action(FormEvent $event, Request $request): void |
||
| 24 | { |
||
| 25 | $event->getElement()->save($event->getForm()->getData()); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 26 | } |
||
| 27 | |||
| 28 | protected function getPreSaveEventName(): string |
||
| 29 | { |
||
| 30 | return FormEvents::FORM_DATA_PRE_SAVE; |
||
| 31 | } |
||
| 32 | |||
| 33 | protected function getPostSaveEventName(): string |
||
| 34 | { |
||
| 35 | return FormEvents::FORM_DATA_POST_SAVE; |
||
| 36 | } |
||
| 37 | |||
| 38 | public function handleRequest(AdminEvent $event, Request $request): ?Response |
||
| 39 | { |
||
| 40 | $response = parent::handleRequest($event, $request); |
||
| 41 | if ($response) { |
||
|
0 ignored issues
–
show
|
|||
| 42 | return $response; |
||
| 43 | } |
||
| 44 | |||
| 45 | $this->eventDispatcher->dispatch(FormEvents::FORM_RESPONSE_PRE_RENDER, $event); |
||
| 46 | if ($event->hasResponse()) { |
||
| 47 | return $event->getResponse(); |
||
| 48 | } |
||
| 49 | |||
| 50 | return null; |
||
| 51 | } |
||
| 52 | } |
||
| 53 |