vendor/store.shopware.com/netinextmodal/src/Storefront/Controller/Traits/ResultTrait.php line 36

Open in your IDE?
  1. <?php
  2. /**
  3.  * @category NetiNextModal
  4.  * @author   bmueller
  5.  */
  6. namespace NetInventors\NetiNextModal\Storefront\Controller\Traits;
  7. use NetInventors\NetiNextModal\Core\Content\Modal\ModalEntity;
  8. use NetInventors\NetiNextModal\Services\ModalPosition;
  9. use Shopware\Core\System\SalesChannel\SalesChannelContext;
  10. use Symfony\Component\HttpFoundation\JsonResponse;
  11. use Symfony\Component\HttpFoundation\Request;
  12. /**
  13.  * Trait ResultTrait
  14.  *
  15.  * @package NetInventors\NetiNextModal\Storefront\Controller\Traits
  16.  */
  17. trait ResultTrait
  18. {
  19.     /**
  20.      * @param Request             $request
  21.      * @param SalesChannelContext $context
  22.      * @param ModalEntity         $modal
  23.      *
  24.      * @return JsonResponse
  25.      * @throws \Exception
  26.      */
  27.     protected function handleResult(
  28.         Request $request,
  29.         SalesChannelContext $context,
  30.         ?ModalEntity $modal
  31.     ): JsonResponse {
  32.         if (null === $modal) {
  33.             return $this->json([]);
  34.         }
  35.         return $this->json(
  36.             [
  37.                 'modal' => [
  38.                     'content'           => $this->buildContent(
  39.                         $request,
  40.                         $context,
  41.                         $modal
  42.                     ),
  43.                     'cssClass'          => $modal->getCssClass(),
  44.                     'delay'             => $modal->getDelay(),
  45.                     'duration'          => $modal->getDuration(),
  46.                     'reincarnation'     => $modal->getReincarnation(),
  47.                     'headline'          => $modal->getTranslation('headline'),
  48.                     'height'            => $modal->getHeight() ?? 0,
  49.                     'id'                => $modal->getId(),
  50.                     'inlineStyle'       => $modal->getInlineStyle(),
  51.                     'needsConfirmation' => $modal->getNeedsConfirmation(),
  52.                     'padding'           => $modal->getPadding(),
  53.                     'width'             => $modal->getWidth(),
  54.                     'position'          => ModalPosition::toCssClass($modal->getModalPosition()),
  55.                     'displayMode'       => $modal->getDisplayMode(),
  56.                     'backdropClose'     => $modal->isBackdropClose(),
  57.                     'animation'         => [
  58.                         'in'        => $modal->getAnimateIn(),
  59.                         'in_speed'  => $modal->getAnimateInSpeed(),
  60.                         'in_class'  => $modal->getAnimateInClass(),
  61.                         'out'       => $modal->getAnimateOut(),
  62.                         'out_speed' => $modal->getAnimateOutSpeed(),
  63.                         'out_class' => $modal->getAnimateOutClass(),
  64.                     ],
  65.                     'openOnExit'        => $modal->isOpenOnExit(),
  66.                 ],
  67.             ]
  68.         );
  69.     }
  70. }