vendor/ibexa/admin-ui/src/lib/Form/Processor/Content/AutosaveProcessor.php line 36

Open in your IDE?
  1. <?php
  2. /**
  3.  * @copyright Copyright (C) Ibexa AS. All rights reserved.
  4.  * @license For full copyright and license information view LICENSE file distributed with this source code.
  5.  */
  6. declare(strict_types=1);
  7. namespace Ibexa\AdminUi\Form\Processor\Content;
  8. use Ibexa\ContentForms\Event\FormActionEvent;
  9. use Ibexa\ContentForms\Form\Processor\ContentFormProcessor;
  10. use Ibexa\Contracts\AdminUi\Event\AutosaveEvents;
  11. use Ibexa\Contracts\Core\Repository\Exceptions\Exception as APIException;
  12. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  13. use Symfony\Component\HttpFoundation\Response;
  14. class AutosaveProcessor implements EventSubscriberInterface
  15. {
  16.     /** @var \Ibexa\ContentForms\Form\Processor\ContentFormProcessor */
  17.     private $innerContentFormProcessor;
  18.     public function __construct(
  19.         ContentFormProcessor $innerContentFormProcessor
  20.     ) {
  21.         $this->innerContentFormProcessor $innerContentFormProcessor;
  22.     }
  23.     public static function getSubscribedEvents(): array
  24.     {
  25.         return [
  26.             AutosaveEvents::CONTENT_AUTOSAVE => ['processAutosave'10],
  27.         ];
  28.     }
  29.     public function processAutosave(FormActionEvent $event): void
  30.     {
  31.         try {
  32.             $this->innerContentFormProcessor->processSaveDraft($event);
  33.             $statusCode Response::HTTP_OK;
  34.         } catch (APIException $exception) {
  35.             $statusCode Response::HTTP_BAD_REQUEST;
  36.         }
  37.         $event->setResponse(
  38.             // Response content is irrelevant as it will be overwritten by ViewRenderer anyway
  39.             new Response(null$statusCode)
  40.         );
  41.     }
  42. }
  43. class_alias(AutosaveProcessor::class, 'EzSystems\EzPlatformAdminUi\Form\Processor\Content\AutosaveProcessor');