src/WebBundle/Controller/SliderController.php line 518

Open in your IDE?
  1. <?php
  2. namespace WebBundle\Controller;
  3. use Exception;
  4. use FlexApp\DTO\RequestCatalogDTO;
  5. use FlexApp\Service\LastUrlService;
  6. use FlexApp\Service\Meta\MetaManager;
  7. use Import1CBundle\Helper\v3\ArticleHelper;
  8. use Import1CBundle\Helper\v3\BiConst;
  9. use Import1CBundle\Helper\v3\InteriorHelper;
  10. use Import1CBundle\Helper\v3\TranslitNameHelper;
  11. use Symfony\Component\HttpFoundation\JsonResponse;
  12. use Symfony\Component\HttpFoundation\RedirectResponse;
  13. use Symfony\Component\HttpFoundation\Request;
  14. use Symfony\Component\HttpFoundation\Response;
  15. use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
  16. use Symfony\Component\Security\Core\Authorization\AuthorizationChecker;
  17. use Symfony\Contracts\Translation\TranslatorInterface;
  18. use WebBundle\Constant\CookieKeysConstant;
  19. use WebBundle\Helper\App;
  20. use WebBundle\Helper\ConversionHelper;
  21. use WebBundle\Helper\CookieHelper;
  22. use WebBundle\Helper\ItemHelper;
  23. use WebBundle\Helper\LocaleHelper;
  24. use WebBundle\Helper\PathHelper;
  25. use WebBundle\Helper\RedirectHelper;
  26. use WebBundle\Helper\SearchLogHelper;
  27. use WebBundle\Helper\StrHelper;
  28. use WebBundle\Helper\UrlHelper;
  29. use WebBundle\Helper\UserHelper;
  30. use WebBundle\Repository\ArticleRepository;
  31. use WebBundle\Repository\BuyOrderRepository;
  32. use WebBundle\Repository\CollectionRepository;
  33. use WebBundle\Repository\FilterRepository;
  34. use WebBundle\Repository\IdeaRepository;
  35. use WebBundle\Repository\InteriorRepository;
  36. use WebBundle\Repository\ListCountryRepository;
  37. use WebBundle\Repository\PublicationRepository;
  38. use WebBundle\Repository\SampleRepository;
  39. use WebBundle\Service\CollectionService;
  40. use WebBundle\Service\ReviewsService;
  41. use WebBundle\Service\SampleService;
  42. use WebBundle\Service\SearchService;
  43. use WebBundle\Service\SliderService;
  44. /**
  45.  * Работа слайдера
  46.  * коллекция опубликована,
  47.  * вызов из коллекции, вызывается 5 слайдов - 0, -2, +2, для крайних уменьшается до 0, игнорируются снятые слайды
  48.  * вызов из би - вызывается 5 слайдов аналогично, снятые игнорируются
  49.  * прямой вызов - вызвается 5 слайдов, снятые игнорируются
  50.  * прямой вызов снятого - вызвается 1 слайд
  51.  * при перелистываении подгружается крайний +-1 слайд
  52.  *
  53.  * коллекция неопубликована - слайдер заблокирован для всех случаев
  54.  *
  55.  * коллекция снята -
  56.  * только прямой вызов по одному слайду
  57.  *
  58.  * коллекция импортирована
  59.  * вызвается 5 слайдов аналогично
  60.  * прямой вызов - 5 слайдов
  61.  *
  62.  * Коллекция на проверке
  63.  * вызывается 5 слайдов аналогично
  64.  * collection controller.
  65.  */
  66. class SliderController extends ExtendedController
  67. {
  68.     /** @required */
  69.     public FilterRepository $filterRepository;
  70.     /** @required */
  71.     public SampleRepository $sampleRepository;
  72.     /** @required */
  73.     public BuyOrderRepository $buyOrderRepository;
  74.     /** @required */
  75.     public ListCountryRepository $listCountryRepository;
  76.     /** @required */
  77.     public PublicationRepository $publicationRepository;
  78.     /** @required */
  79.     public IdeaRepository $ideaRepository;
  80.     /** @required */
  81.     public ArticleRepository $articleRepository;
  82.     /** @required */
  83.     public CollectionRepository $collectionRepository;
  84.     /** @required */
  85.     public InteriorRepository $interiorRepository;
  86.     /** @required */
  87.     public CollectionService $collectionService;
  88.     /** @required */
  89.     public ReviewsService $reviewsService;
  90.     /** @required */
  91.     public SampleService $sampleService;
  92.     /** @required */
  93.     public SliderService $sliderService;
  94.     /** @required */
  95.     /** @required */
  96.     public SearchService $searchService;
  97.     /** @required */
  98.     public LastUrlService $lastUrlService;
  99.     private AuthorizationChecker $authorizationChecker;
  100.     private TranslatorInterface $translator;
  101.     public function __construct(
  102.         AuthorizationChecker $authorizationChecker,
  103.         TranslatorInterface $translator
  104.     ) {
  105.         parent::__construct();
  106.         $this->authorizationChecker $authorizationChecker;
  107.         $this->translator $translator;
  108.     }
  109.     /**
  110.      * @param Request $request
  111.      * @param $factoryUrl
  112.      * @param $collectionUrl
  113.      * @param $type
  114.      * @param $elementId
  115.      * @return Response
  116.      * @throws Exception
  117.      */
  118.     public function indexAction(Request $request$factoryUrl$collectionUrl$type$elementId)
  119.     {
  120.         // проверка переноса фабрики
  121.         if ($iNeedRedirect RedirectHelper::checkRedirect($factoryUrl$collectionUrl$type$elementId)) {
  122.             return $this->redirect(
  123.                 $this->generateUrl(
  124.                     'app_collection',
  125.                     $iNeedRedirect->getArrayForRedirect()
  126.                 )
  127.             );
  128.         }
  129.         $token UserHelper::getInstance()->getToken();
  130.         $translator $this->translator;
  131.         $collection $this->collectionRepository->getSlideCollection($factoryUrl$collectionUrl);
  132.         // проверка на сменный URL коллекции
  133.         if (!$collection) {
  134.             $redirect $this->lastUrlService->getSliderRedirectUrl($collectionUrl$factoryUrl$type$elementId);
  135.             if ($redirect) {
  136.                 return new RedirectResponse($redirect);
  137.             }
  138.         }
  139.         if (!$collection) {
  140.             throw $this->createNotFoundException('Element not found');
  141.         }
  142.         $isCollectionStatus in_array(
  143.             $collection['status'],
  144.             [BiConst::STATE_DISCONTINUEDBiConst::STATE_WORK_CONTINUED]
  145.         );
  146.         // Закрываем доступ для еще не опубликованных коллекций
  147.         if (
  148.             !in_array(
  149.                 $collection['status'],
  150.                 [BiConst::STATE_PUBLISHEDBiConst::STATE_DISCONTINUEDBiConst::STATE_WORK_CONTINUED]
  151.             )
  152.             && !$this->authorizationChecker->isGranted('ROLE_ADMIN')
  153.         ) {
  154.             throw $this->createNotFoundException('Slide not found');
  155.         }
  156.         $msg $this->collectionService->getAlertMessageIfCollectionInDiscontinuedState($collection);
  157.         $isBiFreezed $request->get('is_freezed');
  158.         $isFactoryStatus in_array(
  159.             $collection['factory']['status'],
  160.             [BiConst::STATE_DISCONTINUEDBiConst::STATE_WORK_CONTINUED]
  161.         );
  162.         $isFreezed = ($isBiFreezed !== null) ? (bool)$isBiFreezed $isCollectionStatus || $isFactoryStatus;
  163.         $suspended $isCollectionStatus || $isFactoryStatus;
  164.         $pathData = [
  165.             'factoryUrl' => $collection['factory']['url'],
  166.             'collectionUrl' => $collection['url'],
  167.             'file' => '%img%',
  168.         ];
  169.         $data $this->getData($request$token$type$collection$elementId);
  170.         if (!empty($data['redirect'])) {
  171.             return new RedirectResponse($data['redirect'], 301);
  172.         } elseif (
  173.             count($data['elements']) === 0
  174.             || $data['elementId'] === null
  175.         ) {
  176.             throw new NotFoundHttpException('The element is not found or it has the column "file" is null');
  177.         }
  178.         if (empty(App::getCountryList()[StrHelper::toLower($collection['factory']['country']['code'])])) {
  179.             $countryEntity $this->listCountryRepository->getCountry($collection['factory']['country']['code']);
  180.             $countryKey '';
  181.             if ($countryEntity) {
  182.                 $countryKey $countryEntity->getAlias();
  183.             }
  184.         } else {
  185.             $countryKey App::getCountryList()[StrHelper::toLower($collection['factory']['country']['code'])]['alias'];
  186.         }
  187.         $countryUrl '';
  188.         if ($countryKey) {
  189.             $countryKey $this->filterRepository->getKeyByLeftMenu($countryKey);
  190.             $countryUrl App::generateUrl('app_catalog', ['key' => $countryKey]);
  191.         }
  192.         // Специальная ссылка на блог
  193.         $blog $this->publicationRepository->find(2232);
  194.         $qr null;
  195.         if (($request->get('QR') || $request->get('qr')) && $type == 'a') {
  196.             $sampleId $data['elements'][$data['elementId']]['id'];
  197.             $sample $this->sampleRepository->sample((int)$sampleId);
  198.             if (!$sample) {
  199.                 throw $this->createNotFoundException('Sample not found');
  200.             }
  201.             $params = [$sample['itemOneId']];
  202.             if ($sample['itemTwoId']) {
  203.                 $params[] = $sample['itemTwoId'];
  204.             }
  205.             $ides $this->sampleRepository->getArticlesIdes($params);
  206.             $itemList $this->articleRepository->getArticleNativeOpt(
  207.                 [
  208.                     'collection' => $collection['id'],
  209.                     'status' => $collection['status'],
  210.                     'interior' => true,
  211.                     'items' => array_column($ides'id'),
  212.                     'isFreezed' => $isFreezed,
  213.                 ],
  214.                 true
  215.             );
  216.             foreach ($itemList as $k => $r) {
  217.                 if (!empty($r['surface']['name']) && !empty($r['surface']['alias'])) {
  218.                     $itemList[$k]['surface']['name'] = App::trans($r['surface']['alias']);
  219.                 }
  220.                 if (!empty($r['colors'])) {
  221.                     foreach ($r['colors'] as $n => $c) {
  222.                         if (!empty($c['name']) && !empty($c['alias'])) {
  223.                             $itemList[$k]['colors'][$n]['name'] = App::trans($c['alias']);
  224.                         }
  225.                     }
  226.                 }
  227.             }
  228.             $mea CookieHelper::get(in_array(App::getCurCountry(), ['us''ca']) ? 'measureFt' 'measure');
  229.             $sampleData $this->sampleService
  230.                 ->getSampleData(
  231.                     $data['elements'][$data['elementId']]['code'],
  232.                     App::getCurCountryId(),
  233.                     false,
  234.                     CookieHelper::get(CookieKeysConstant::CURRENCY),
  235.                     $mea
  236.                 );
  237.             if ($mea == 'ft') {
  238.                 $sample['sizeXOne'] = ConversionHelper::convertInch((float)$sample['sizeXOne'], ConversionHelper::CM);
  239.                 $sample['sizeYOne'] = ConversionHelper::convertInch((float)$sample['sizeYOne'], ConversionHelper::CM);
  240.                 $sample['sizeXTwo'] = ConversionHelper::convertInch((float)$sample['sizeXTwo'], ConversionHelper::CM);
  241.                 $sample['sizeYTwo'] = ConversionHelper::convertInch((float)$sample['sizeYTwo'], ConversionHelper::CM);
  242.             }
  243.             $qr = [
  244.                 'main' => array_merge($sampleData$sample),
  245.                 'mss' => ArticleHelper::getTileArticleAddOptions($data['elements'][$data['elementId']])['mss'],
  246.                 'listItem' => $itemList,
  247.             ];
  248.         }
  249.         $reviews $this->reviewsService->getReviewByCollection($collection['code']);
  250.         $output = [
  251.             'windowSizes' => json_decode($request->cookies->get('windowSizes''{}'), true),
  252.             'filters' => $this->getGoogleRefererInfo(),
  253.             'qr' => $qr,
  254.             'msg' => $msg ?? null,
  255.             'elements' => $data['elements'],
  256.             'elementsCount' => $data['elementsCount'],
  257.             'elementId' => $data['elementId'],
  258.             'number' => $data['numberElement'],
  259.             'type' => $type,
  260.             'suspended' => $suspended,
  261.             'dataNoRegular' => $collection['factory']['suspended'],
  262.             'buyOrderArticles' => $this->buyOrderRepository->getInfoBuyOrderArticle($token),
  263.             'userCountry' => App::getCurCountry(),
  264.             'userLocale' => App::getCurLocale(),
  265.             'currency' => LocaleHelper::getCurrency(LocaleHelper::getCur()),
  266.             'measureGb' => LocaleHelper::measureGb(),
  267.             'vatPercent' => LocaleHelper::includeVATAlways(),
  268.             'urls' => [
  269.                 'settings' => App::generateUrl('app_article_settings', ['id' => 0]),
  270.                 'collection' => App::generateUrl(
  271.                     'app_collection',
  272.                     ['factoryUrl' => '%factory%''collectionUrl' => '%collection%']
  273.                 ),
  274.                 'factory' => App::generateUrl('app_catalog', ['key' => '%factory%']),
  275.                 'country' => $countryUrl,
  276.                 'ideas' => App::generateUrl('app_ideas_list', ['id' => '%id%']),
  277.                 'pathImg' => [
  278.                     'item' => PathHelper::pathGenerate('article'$pathData),
  279.                     'interior' => PathHelper::pathGenerate('interior'$pathData),
  280.                 ],
  281.                 'fastDeliverySamplesUrl' => UrlHelper::genUrlBlogSingle($blog),
  282.                 'mainPic' => PathHelper::pathGenerate('main'$collection),
  283.             ],
  284.             'stateNotTime' => BiConst::STATE_NOT_TIME,
  285.             'statePublished' => BiConst::STATE_PUBLISHED,
  286.             'stateDiscontinued' => BiConst::STATE_DISCONTINUED,
  287.             'stateProcessing' => BiConst::STATE_PROCESSING,
  288.             'isWithoutVATPrice' => LocaleHelper::isWithoutVATPrice(10) !== false,
  289.             'isFreezed' => $isFreezed,
  290.             'closed' => ($collection['status'] == BiConst::STATE_DISCONTINUED
  291.                 $translator->trans('collection_unavailable_freezed_desc')
  292.                 : ($collection['status'] == BiConst::STATE_PROCESSING
  293.                     $translator->trans('collection_unavailable')
  294.                     : ''
  295.                 )),
  296.             'closedHelp' => $collection['status'] == BiConst::STATE_PROCESSING
  297.                 $translator->trans('collection_unavailable_manufacture_desc')
  298.                 : '',
  299.             'trans' => [
  300.                 'orderHelp' => $translator->trans('buyOrder.help'),
  301.                 'collectionCeilToPallet' => $translator->trans('collection_ceil_to_pallet'),
  302.                 'popupAutoChangeCountArts' => $translator->trans('popup_auto_change_count_arts'),
  303.                 'collectionAtentionPallet' => $translator->trans('collection_atention_pallet'),
  304.                 'articleTypeSample' => $translator->trans('article.type.sample'),
  305.                 'collection_Article' => $translator->trans('collection_article'),
  306.                 'collection_Interior' => $translator->trans('collection_interior'),
  307.                 'collectionName' => $translator->trans('collection_name'),
  308.                 'catalogFactory' => $translator->trans('catalog_factory'),
  309.                 'articleCharacteristics' => $translator->trans('article_characteristics'),
  310.                 'articleItemFormats' => $translator->trans('article_item_formats'),
  311.                 'itemDifferentPatterns' => $translator->trans('item_different_patterns'),
  312.                 'itemVariationsOfGraphics' => $translator->trans('item_variations_of_graphics'),
  313.                 'vatLabel' => $translator->trans('vat.label'),
  314.                 'vatIncluded' => $translator->trans('vat.included'),
  315.                 'catalogPrice' => $translator->trans('catalog_price'),
  316.                 'articleDiscountinued' => $translator->trans('article.discountinued'),
  317.                 'collectionBack' => $translator->trans('collection_back'),
  318.                 'commentAddQuestion' => $translator->trans('comment_add_question'),
  319.                 'articleInStock' => $translator->trans('article_in_stock'),
  320.                 'item' => [
  321.                     'collection' => $translator->trans('collection_name'),
  322.                     'factory' => $translator->trans('catalog_factory'),
  323.                     'characteristics' => $translator->trans('article_characteristics'),
  324.                     'header' => $translator->trans('collection_articles_d'),
  325.                     'formats' => $translator->trans('article_item_formats'),
  326.                     'cm' => $translator->trans('left_menu_cm'),
  327.                     'translated_by_google' => $translator->trans('translated_by_google'),
  328.                     'show_translate' => $translator->trans('show_translate'),
  329.                     'show_original' => $translator->trans('show_original'),
  330.                     'inch' => '″',
  331.                     'diameter' => $translator->trans('article_item_diameter'),
  332.                     'pcs' => $translator->trans('measure_unit'),
  333.                     'pcsPlural' => $translator->trans('measure_units'),
  334.                     'set' => $translator->trans('measure_set'),
  335.                     'sets' => $translator->trans('measure_sets'),
  336.                     'settings' => $translator->trans('collection_marks'),
  337.                     'someSettings' => $translator->trans('article_characteristics'),
  338.                     'allSettings' => $translator->trans('all'),
  339.                     'price' => $translator->trans('catalog_price'),
  340.                     'vat' => [
  341.                         'label' => $translator->trans('vat.label'),
  342.                         'included' => $translator->trans('vat.included'),
  343.                         'excluded' => $translator->trans('vat.excluded'),
  344.                     ],
  345.                     'info' => $translator->trans('article_item_more_info'),
  346.                     'infoLess' => $translator->trans('article_item_less_info'),
  347.                     'order' => [
  348.                         'help' => $translator->trans('buyOrder.help'),
  349.                         'ceilToPallet' => $translator->trans('collection_ceil_to_pallet'),
  350.                         'atentionPallet' => $translator->trans('collection_atention_pallet'),
  351.                         'popupAutoChangeCountArts' => $translator->trans('popup_auto_change_count_arts'),
  352.                     ],
  353.                     'up' => $translator->trans('article.price.up'),
  354.                     'down' => $translator->trans('article.price.down'),
  355.                     'readMore' => $translator->trans('read_more'),
  356.                     'titleAddedArticle' => $translator->trans('buyOrder.titleAddedArticle'),
  357.                     'addIntoOrder' => $translator->trans('buy_order.add_into_order'),
  358.                     'headerOrderAdd' => $translator->trans('header_order_add'),
  359.                     'draft' => $translator->trans('order.status.draft'),
  360.                     'typeMain' => $translator->trans('article.type.main'),
  361.                     'typeSample' => $translator->trans('article.type.sample'),
  362.                     'sampleText' => $translator->trans('article.type.sampleText'),
  363.                     'typeCompare' => $translator->trans('article.type.compare'),
  364.                     'compareText' => $translator->trans('article.type.compareText'),
  365.                     'type3d' => $translator->trans('article.type.3d'),
  366.                     'text3d' => $translator->trans('article.type.3dText'),
  367.                     'articleOrderOver' => $translator->trans('article.order.over'),
  368.                     'articlePricePerPallet' => $translator->trans('article.price.perPallet'),
  369.                     'articlePriceNoLessPallet' => $translator->trans('article.price.noLessPallet'),
  370.                     'articlePricePalleteFrom' => $translator->trans('article.pricePallete.from'),
  371.                     'articlePriceFrom' => $translator->trans('article.price.from'),
  372.                     'articlePricePalleteUnder' => $translator->trans('article.pricePallete.under'),
  373.                     'articlePriceFromTo' => $translator->trans('article.price.from_to'),
  374.                     'articleOrderMultiplies' => $translator->trans('article.order.multiplies'),
  375.                     'highResolutionImageDownload' => $translator->trans('image_download_high_resolution'),
  376.                     'boxArticleSingle' => $translator->trans('box_article_single'),
  377.                     'boxArticlePlural' => $translator->trans('box_article_plural'),
  378.                     'articleNoImgTitle' => $translator->trans('article.no_img'),
  379.                     'collectionAddOrder' => $translator->trans('collection_add_order'),
  380.                     'tempNoUKShippingMsg' => $translator->trans('msg.uk'),
  381.                     'discountinued' => $translator->trans('article.discountinued'),
  382.                     'tempUnavailable' => $translator->trans('article.temp_unavailable'),
  383.                 ],
  384.                 'sample' => [
  385.                     'folder' => $translator->trans('sample.folder.text'),
  386.                     'original' => $translator->trans('sample.original.text'),
  387.                     'piece' => $translator->trans('sample.piece.text'),
  388.                     'title' => $translator->trans('samplePopup.title'),
  389.                     'noMoreShow' => $translator->trans('samplePopup.noMoreShow'),
  390.                     'withDecl' => $translator->trans('article.type.sampleWithDecl'),
  391.                     'alreadyAdded' => $translator->trans('sample_already_added.header'),
  392.                     'fitsForItems' => $translator->trans('fits_for_items'),
  393.                 ],
  394.                 'reviews' => [
  395.                     'heading' => $translator->trans('collection_customer_reviews'),
  396.                     'validUser' => $translator->trans('product_validUser'),
  397.                     'reply' => $translator->trans('reply_comment'),
  398.                     'edit' => $translator->trans('edit'),
  399.                     'save' => $translator->trans('save'),
  400.                     'cancel' => $translator->trans('cancel'),
  401.                     'stars' => $translator->trans('reviews.stars.many'),
  402.                 ],
  403.                 'box' => $translator->trans('measure_box'),
  404.                 'boxes' => $translator->trans('boxes'),
  405.                 'collectionNotRegular' => $translator->trans('collection.notRegular'),
  406.                 'collectionBy' => $translator->trans('collection_by'),
  407.                 'ideaDelInteriorMsg' => $translator->trans('idea_del_interior_msg'),
  408.                 'ideaYes' => $translator->trans('idea_yes'),
  409.                 'ideaNo' => $translator->trans('idea_no'),
  410.                 'ideaMsgAdded' => $translator->trans('idea_msg_added'),
  411.                 'ideaMsgNormal' => $translator->trans('idea_msg_normal'),
  412.                 'ideaMsgNormalMany' => $translator->trans('idea_msg_normal_many'),
  413.                 'ideaMsgNormalZero' => $translator->trans('idea_msg_normal_zero'),
  414.                 'articleItemDiameter' => $translator->trans('article_item_diameter'),
  415.                 'leftMenuCm' => $translator->trans('left_menu_cm'),
  416.                 'leftMenuInch' => '″',
  417.                 'sampleFolderText' => $translator->trans('sample.folder.text'),
  418.                 'sampleOriginalText' => $translator->trans('sample.original.text'),
  419.                 'samplePieceText' => $translator->trans('sample.piece.text'),
  420.                 'unavailableFreezedDescArticle' => $translator->trans('collection_unavailable_freezed_desc_article'),
  421.                 'discountinued' => $translator->trans('article.discountinued'),
  422.                 'articleInInterior' => $translator->trans('article_in_interior'),
  423.                 'factoryCountry' => $translator->trans($collection['factory']['country']['alias']),
  424.                 'collectionIdeasShort' => $translator->trans('collection_ideas_short'),
  425.             ],
  426.             'reviews' => [
  427.                 'data' => $reviews,
  428.                 'urls' => [
  429.                     'preDataCollectionReviewsUrl' => App::generateUrl(
  430.                         'pre_data_collection_reviews',
  431.                         ['id' => $collection['id']]
  432.                     ),
  433.                     'collectionReviewsUrl' => App::generateUrl('collection_reviews', ['id' => $collection['id']]),
  434.                 ],
  435.             ],
  436.         ];
  437.         $imagePreload null;
  438.         if (!empty($output['elements'][$output['elementId']]['pathImg'])) {
  439.             $imagePreload $output['elements'][$output['elementId']]['pathImg'];
  440.         }
  441.         SearchLogHelper::save([
  442.             'url' => $request->getUri(),
  443.             'title' => $data['elements'][$data['elementId']]['title'],
  444.         ]);
  445.         if ($request->get('only-slider')) {
  446.             return new JsonResponse(['slider' => $output]);
  447.         } else {
  448.             $art $data['elements'][$data['elementId']];
  449.             if ($type == 'i') {
  450.                 $art = !empty($art['articles'][0]) ? $art['articles'][0] : null;
  451.             }
  452.             return $this->renderReact('@Web/Slider/index.html.twig', [
  453.                 'imagePreload' => $imagePreload,
  454.                 'metaData' => [
  455.                     'title' => $data['elements'][$data['elementId']]['title'],
  456.                     'description' => $data['elements'][$data['elementId']]['description'],
  457.                     'keyword' => '',
  458.                 ],
  459.                 //для динамического ремаркетинга
  460.                 'ecommProdid' => $data['elementId'],
  461.                 'ecommTotalvalue' => $art LocaleHelper::getPrice($art) : 0,
  462.                 'initialState' => ['slider' => $output],
  463.             ]);
  464.         }
  465.     }
  466.     /**
  467.      * @param Request $request
  468.      * @param string $token
  469.      * @param string $type
  470.      * @param array $collection
  471.      * @param string|null $elementId
  472.      * @param string|null $load
  473.      * @return array|null
  474.      * @throws Exception|\Doctrine\DBAL\Driver\Exception
  475.      */
  476.     private function getData(
  477.         Request $request,
  478.         string $token,
  479.         string $type,
  480.         array $collection,
  481.         ?string $elementId null,
  482.         ?string $load 'all'
  483.     ): ?array {
  484.         if ($type == 'a') {
  485.             $elementsCount $this->articleRepository->countArticlesColl(
  486.                 $collection['id'],
  487.                 $request->get('all'false)
  488.             );
  489. //            $elements = $this->articleRepository->idesArticlesColl(
  490. //                $collection['id'],
  491. //                !empty($_GET['all'])
  492. //            );
  493. //            $elementIdes = array_keys($elements);
  494. //            $elementUrls = array_values($elements);
  495.             //подсчитываем по тому почему и выводим
  496.             $params = [
  497.                 'collection' => $collection['id'],
  498.                 'offset' => 0,
  499.                 'limit' => 200000,
  500.             ];
  501.             $elements $this->articleRepository->getArticleNativeOpt(
  502.                 $params,
  503.                 true
  504.             );
  505.             $elementIdes array_column($elements'id');
  506.             $elementUrls array_column($elements'url');
  507.             if (in_array($elementId$elementUrls)) {
  508.                 if (
  509.                     $redirectArticle $this->articleRepository->findOneBy([
  510.                     'url' => $elementId,
  511.                     'collection' => $collection['id'],
  512.                     ])
  513.                 ) {
  514.                     $elementId $redirectArticle->getId();
  515.                 }
  516.             } else {
  517.                 // если ключ элемента цифровой - запросим редирект
  518.                 // https://tile.expert/ru-it/tile/del-conca/hcl-climb/a/288881155
  519.                 if (array_key_exists($elementId$elements)) {
  520.                     return [
  521.                         'redirect' => $this->generateUrl(
  522.                             'app_collection_slideshow',
  523.                             [
  524.                                 'factoryUrl' => $collection['factory']['url'],
  525.                                 'collectionUrl' => $collection['url'],
  526.                                 'type' => $type,
  527.                                 'elementId' => $elements[$elementId],
  528.                             ]
  529.                         ),
  530.                     ];
  531.                 }
  532.                 $elementId null;
  533.             }
  534.             $isFreezed false;
  535.             $res $this->getIdes($elementIdes$elementId$load);
  536.             $elements $this->articleRepository->getArticleNativeOpt(
  537.                 [
  538.                     'collection' => $collection['id'],
  539.                     'status' => $collection['status'],
  540.                     'interior' => true,
  541.                     'items' => $res['ides'],
  542.                     'isFreezed' => $isFreezed
  543.                 ],
  544.                 true
  545.             );
  546.         } else {
  547.             $elementsCount $this->interiorRepository->countInteriorsColl($collection['id']);
  548.             $res $this->interiorRepository->interiorId($elementId$collection['id']);
  549.             if (!$res) {
  550.                 $url $this->interiorRepository->interiorUrlByName($elementId$collection['id']);
  551.                 if ($url) {
  552.                     return [
  553.                         'redirect' => $this->generateUrl(
  554.                             'app_collection_slideshow',
  555.                             [
  556.                                 'factoryUrl' => $collection['factory']['url'],
  557.                                 'collectionUrl' => $collection['url'],
  558.                                 'type' => 'i',
  559.                                 'elementId' => $url
  560.                             ]
  561.                         )
  562.                     ];
  563.                 }
  564.             }
  565.             $elementId $res;
  566.             $filter $request->get('filter');
  567.             if ($filter) {
  568.                 $searchFilter = [
  569.                     'c_id' => [$collection['id']],
  570.                     'inside' => true
  571.                 ];
  572.                 $reqCatDTO = new RequestCatalogDTO($request$filternull);
  573.                 $oSearchService $this->searchService;
  574.                 $oSearchService->setFilter($reqCatDTO$searchFilter);
  575.                 $data $oSearchService->getSearchData();
  576.                 $keyString serialize($data);
  577.                 $key 'sphinx' md5($keyString);
  578.                 $searchTrue_cache App::getMemcache()->get($key);
  579.                 if ($searchTrue_cache !== false) {
  580.                     $searchTrue $searchTrue_cache;
  581.                 } else {
  582.                     $searchTrue App::searchSphinx($data0true);
  583.                     App::getMemcache()->set($key$searchTrue);
  584.                 }
  585.                 $elementIdesAll_ $this->interiorRepository->getInteriorsForSlider(
  586.                     $collection['id'],
  587.                     ['onlyId' => true]
  588.                 );
  589.                 if (!empty($searchTrue[0]['interiors'])) {
  590.                     $elementIdesFind array_column($searchTrue[0]['interiors'], 'i_id');
  591.                     if (in_array($elementId$elementIdesFind)) {
  592.                         $elementIdes array_values($elementIdesFind);
  593.                         $elementsCount count($elementIdes);
  594.                     } else {
  595.                         $elementIdes array_column($elementIdesAll_'id');
  596.                         $elementIdes array_values(array_diff($elementIdes$elementIdesFind));
  597.                         $elementsCount count($elementIdes);
  598.                     }
  599.                 } else {
  600.                     $elementIdes array_column($elementIdesAll_'id');
  601.                 }
  602.                 $res $this->getIdes($elementIdes$elementId$load);
  603.                 $elements $this->interiorRepository->getInteriorsForSlider(
  604.                     $collection['id'],
  605.                     ['ids' => $res['ides']]
  606.                 );
  607.                 foreach ($elements as &$element) {
  608.                     $element InteriorHelper::getInteriorDetails($element$element['collection'], null$filter);
  609.                 }
  610.             } else {
  611.                 $elementIdes $this->interiorRepository->getInteriorsForSlider($collection['id'], ['onlyId' => true]);
  612.                 $res $this->getIdes(array_column($elementIdes'id'), $elementId$load);
  613.                 $elements $this->interiorRepository->getInteriorsForSlider($collection['id'], ['ids' => $res['ides']]);
  614.                 foreach ($elements as &$element) {
  615.                     $element InteriorHelper::getInteriorDetails($element$element['collection']);
  616.                 }
  617.             }
  618.         }
  619.         $favorites $this->ideaRepository->getInteriorsIdeasByToken($token);
  620.         $nameF $collection['factory']['name'];
  621.         $pos = isset($collection['factory']['name']) ? strpos($collection['factory']['name'], '&prime;') : false;
  622.         if ($pos !== false) {
  623.             $name TranslitNameHelper::replacePrime($collection['factory']['name'], false);
  624.             $nameF $name;
  625.         }
  626.         $titleData = [
  627.             'c_id' => $collection['id'],
  628.             'c_name' => $collection['name'],
  629.             'c_satus' => $collection['status'],
  630.             'f_id' => $collection['factory']['id'],
  631.             'f_name' => $nameF,
  632.             'f_satus2' => $collection['factory']['status'],
  633.             'code' => $collection['factory']['country']['code'],
  634.             'type' => $type,
  635.             'elsCount' => $elementsCount,
  636.         ];
  637.         $buyOrderArticle $this->buyOrderRepository->getInfoBuyOrderArticle($token);
  638.         $samplesArray = [];
  639.         if ($request->get('sample')) {
  640.             $samplesArray $this->sampleService
  641.                 ->getSamplesData(
  642.                     array_column($elements'code'),
  643.                     App::getCurCountryId(),
  644.                     false,
  645.                     LocaleHelper::getCur(),
  646.                     LocaleHelper::getUserMeasure()
  647.                 );
  648.         }
  649.         $newElements = [];
  650.         $ordersItems $this->buyOrderRepository->getInfoBuyOrderArticle($token);
  651.         foreach ($elements as $row) {
  652.             $row $this->unsetInactiveArticleInInteriorOrCollection($row);
  653.             $newElements[$row['id']] = $newElements[$row['id']] ?? $row;
  654.             $newElements[$row['id']]['name'] = html_entity_decode($row['name']);
  655.             $newElements[$row['id']]['alternateName'] = empty($row['alternateName']) ? null html_entity_decode(
  656.                 $row['alternateName']
  657.             );
  658.             $newElements[$row['id']]['numberElement'] = $res['numberElement'][$row ['id']];
  659.             $titleData['id'] = $row['id'];
  660.             $titleData['elNum'] = $res['numberElement'][$row['id']];
  661.             $newElements[$row['id']]['collection']['priceSort'] = LocaleHelper::getPrMin($row['collection']);
  662.             $newElements[$row['id']]['collection']['priceSortCur'] = LocaleHelper::getCurrency();
  663.             $newElements[$row['id']]['collection']['priceSortMea'] = LocaleHelper::getUserMeasure();
  664.             $this->addInfoAboutAvailableInCountryOfFactory($row['collection'], $newElements[$row['id']]);
  665.             $furl $row['collection']['factory']['url'] ?? null;
  666.             $curl $row['collection']['url'] ?? null;
  667.             if ($type == 'i') {
  668.                 if (empty($row['file'])) {
  669.                     $row['file'] = StrHelper::toLower($row['name']) . '.jpg';
  670.                 } else {
  671.                     $row['file'] = StrHelper::toLower($row['file']);
  672.                 }
  673.                 //todo временно
  674.                 if (!empty($newElements[$row['id']]['collection']['process'])) {
  675.                     $row['file'] = preg_replace('#\.jpg#i''.webp'$row['file']);
  676.                     $isWebp $newElements[$row['id']]['collection']['a_version'] = true;
  677.                 } else {
  678.                     $isWebp $newElements[$row['id']]['collection']['a_version'] = false;
  679.                 }
  680.                 foreach ($row['articles'] as $n => $article) {
  681.                     if (empty($article['collection'])) {
  682.                         unset($newElements[$row['id']]['articles'][$n]);
  683.                         continue;
  684.                     }
  685.                     $afurl $article['collection']['factory']['url'] ?? null;
  686.                     $acurl $article['collection']['url'] ?? null;
  687.                     $article['name'] = html_entity_decode($article['name']);
  688.                     $article['alternateName'] = empty($article['alternateName']) ? null html_entity_decode(
  689.                         $article['alternateName']
  690.                     );
  691.                     $article['addUrl'] = App::generateUrl(
  692.                         'app_buy_orders_list',
  693.                         [
  694.                             'articleId' => $article['id'],
  695.                         ]
  696.                     );
  697.                     $article['sampleUrl'] = App::generateUrl('app_order_sample', ['code' => $article['code']]);
  698.                     $article['collectionUrl'] = App::generateUrl(
  699.                         'app_collection',
  700.                         [
  701.                             'factoryUrl' => $afurl,
  702.                             'collectionUrl' => $acurl,
  703.                         ]
  704.                     );
  705.                     $article['factoryUrl'] = App::generateUrl(
  706.                         'app_catalog',
  707.                         [
  708.                             'key' => $afurl,
  709.                         ]
  710.                     );
  711.                     $article['prc'] = LocaleHelper::getPrice($article);
  712.                     $article['mea'] = App::trans(LocaleHelper::getMeasure($article));
  713.                     // рассчитываем размер в inch-ах
  714.                     $article['sizeGbX'] = ConversionHelper::convertInch((float)$article['sizeX'], ConversionHelper::CM);
  715.                     $article['sizeGbY'] = ConversionHelper::convertInch((float)$article['sizeY'], ConversionHelper::CM);
  716.                     $article['sizeGbZ'] = ConversionHelper::convertInch((float)$article['sizeZ'], ConversionHelper::CM);
  717.                     $article['amount'] = LocaleHelper::getAmount($article);
  718.                     $article['orders'] = !empty($ordersItems[$article['id']]) ? $ordersItems[$article['id']] : false;
  719.                     $article['ssLink'] = App::generateUrl(
  720.                         'app_collection_slideshow',
  721.                         [
  722.                             'factoryUrl' => $afurl,
  723.                             'collectionUrl' => $acurl,
  724.                             'type' => 'a',
  725.                             'elementId' => $article['url'],
  726.                         ]
  727.                     );
  728.                     $article['imageSettingIcon'] = ArticleHelper::getPathArticleImageSettings($article);
  729.                     $article['shape'] = [
  730.                         'id' => $article['shape']['id'],
  731.                         'alias' => App::trans($article['shape']['alias']),
  732.                     ];
  733.                     if ($isWebp) {
  734.                         $articleFileNameWebp preg_replace('#\.jpg#i''.webp'$article['details']['file']);
  735.                     } else {
  736.                         $articleFileNameWebp $article['details']['file'];
  737.                     }
  738.                     $article['pathImg'] = PathHelper::pathGenerate(
  739.                         'article',
  740.                         [
  741.                             'factoryUrl' => $afurl,
  742.                             'collectionUrl' => $acurl,
  743.                             'file' => 'b_' $articleFileNameWebp,
  744.                         ]
  745.                     );
  746.                     if (!empty($article['commentSchemeImage'])) {
  747.                         $article['commentSchemeImage'] = PathHelper::pathGenerate(
  748.                             'article',
  749.                             [
  750.                                 'factoryUrl' => $afurl,
  751.                                 'collectionUrl' => $acurl,
  752.                                 'file' => 'b_' $article['details']['commentSchemeImage'],
  753.                             ]
  754.                         );
  755.                     }
  756.                     $alt[] = $article['name'];
  757.                     foreach ($article['textures'] as $k => $texture) {
  758.                         $article['textures'][$k]['alias'] = $alt[] = App::trans($texture['alias']);
  759.                     }
  760.                     if (!empty($article['details']['variantImage']['texture'])) {
  761.                         $article['details']['variantImage']['texture'] = ItemHelper::addMainPic(
  762.                             $article['details']['variantImage']['texture'],
  763.                             $articleFileNameWebp
  764.                         );
  765.                     }
  766.                     if (!empty($article['details']['variantImage']['picture'])) {
  767.                         $article['details']['variantImage']['picture'] = ItemHelper::addMainPic(
  768.                             $article['details']['variantImage']['picture'],
  769.                             $articleFileNameWebp
  770.                         );
  771.                     }
  772.                     // добавляем объект цены для js
  773.                     $price LocaleHelper::getPrice($article);
  774.                     $woVATPrice LocaleHelper::isWithoutVATPrice($price);
  775.                     if ($woVATPrice) {
  776.                         $article['discountsAmount'][] = [
  777.                             'price' => $price,
  778.                             'startAmount' => 0,
  779.                             'woVATPrice' => $woVATPrice,
  780.                             'fold' => 0,
  781.                         ];
  782.                     } else {
  783.                         $article['discountsAmount'][] = [
  784.                             'price' => $price,
  785.                             'startAmount' => 0,
  786.                             'woVATPrice' => $price,
  787.                             'fold' => 0,
  788.                         ];
  789.                     }
  790.                     if (!empty($article['priceDiscounts'])) {
  791.                         foreach ($article['priceDiscounts'] as $k => $r) {
  792.                             if ($r == null) {
  793.                                 continue;
  794.                             }
  795.                             $priceDiscount LocaleHelper::getPriceDiscount($r, [
  796.                                 'measureId' => $article['measure']['id'],
  797.                             ]);
  798.                             if (
  799.                                 $k == && $article['multiplePallet'] == &&
  800.                                 $article['packagingCount'] >= $priceDiscount['amount']
  801.                             ) {
  802.                                 $article['discountsAmount'] = [];
  803.                             } else {
  804.                                 $article['discountsAmount'][count(
  805.                                     $article['discountsAmount']
  806.                                 ) - 1]['endAmount'] = $priceDiscount['amount'];
  807.                             }
  808.                             $woVATPrice LocaleHelper::isWithoutVATPrice($priceDiscount['price']);
  809.                             if ($woVATPrice) {
  810.                                 $article['discountsAmount'][] = [
  811.                                     'price' => $priceDiscount['price'],
  812.                                     'startAmount' => $priceDiscount['amount'],
  813.                                     'woVATPrice' => $woVATPrice,
  814.                                     'fold' => $r['fold'],
  815.                                 ];
  816.                             } else {
  817.                                 $article['discountsAmount'][] = [
  818.                                     'price' => $priceDiscount['price'],
  819.                                     'startAmount' => $priceDiscount['amount'],
  820.                                     'woVATPrice' => $priceDiscount['price'],
  821.                                     'fold' => $r['fold'],
  822.                                 ];
  823.                             }
  824.                         }
  825.                     }
  826.                     $coords = [];
  827.                     if (!empty($article['coordItems'])) {
  828.                         foreach ($article['coordItems'] as $coord) {
  829.                             $interiorId $coord['interior']['id'] ?? null;
  830.                             if ($interiorId == $row['id']) {
  831.                                 $coords[] = [
  832.                                     'id' => $coord['id'],
  833.                                     'coordX' => $coord['coordX'],
  834.                                     'coordY' => $coord['coordY'],
  835.                                     'typePointer' => $coord['typePointer'],
  836.                                     'interiorId' => $coord['interior']['id'],
  837.                                     'articleId' => $coord['article']['id'],
  838.                                 ];
  839.                             }
  840.                         }
  841.                     }
  842.                     unset($article['coordItems']);
  843.                     $article['coordItems'] = $coords;
  844.                     $article['url'] = !empty($article['url']) ? $article['url'] : $article['name'];
  845.                     if (!empty($buyOrderArticle[$article['id']])) {
  846.                         $article['orders'] = $buyOrderArticle[$article['id']];
  847.                     } else {
  848.                         $article['orders'] = [];
  849.                     }
  850.                     $pos = isset($article['collection']['factory']['name'])
  851.                         ? strpos($article['collection']['factory']['name'], '&prime;')
  852.                         : false;
  853.                     if ($pos !== false) {
  854.                         $name TranslitNameHelper::replacePrime($article['collection']['factory']['name'], false);
  855.                         $alternateName TranslitNameHelper::replacePrime(
  856.                             $article['collection']['factory']['alternateName'],
  857.                             false
  858.                         );
  859.                         $article['collection']['factory']['name'] = $name;
  860.                         $article['collection']['factory']['alternateName'] = $alternateName;
  861.                     }
  862.                     $newElements[$row['id']]['articles'][$n] = ArticleHelper::getTileArticleAddOptions($article);
  863.                 }
  864.                 if (!empty($newElements[$row['id']]['articles'])) {
  865.                     $newElements[$row['id']]['articles'] = array_values($newElements[$row['id']]['articles']);
  866.                 }
  867.                 $pos = isset($row['collection']['factory']['name'])
  868.                     ? strpos($row['collection']['factory']['name'], '&prime;')
  869.                     : false;
  870.                 if ($pos !== false) {
  871.                     $name TranslitNameHelper::replacePrime($row['collection']['factory']['name'], false);
  872.                     $alternateName TranslitNameHelper::replacePrime(
  873.                         $row['collection']['factory']['alternateName'],
  874.                         false
  875.                     );
  876.                     $newElements[$row['id']]['collection']['factory']['name'] = $name;
  877.                     $newElements[$row['id']]['collection']['factory']['alternateName'] = $alternateName;
  878.                 }
  879.                 $newElements[$row['id']]['inIdeaBook'] = in_array($row['id'], $favorites);
  880.                 $newElements[$row['id']]['url'] = $row['url'];
  881.                 $newElements[$row['id']]['paths'] = [
  882.                     'hd' => !empty($row['fileSizeHDY']) ?
  883.                         PathHelper::pathGenerate(
  884.                             'interior',
  885.                             [
  886.                                 'factoryUrl' => $furl,
  887.                                 'collectionUrl' => $curl,
  888.                                 'file' => 'hd_' $row['file']
  889.                             ]
  890.                         )
  891.                         : null,
  892.                     'shd_1080' => !empty($row['fileSizeSHDY'])
  893.                         ? PathHelper::pathGenerate(
  894.                             'interior',
  895.                             [
  896.                                 'factoryUrl' => $furl,
  897.                                 'collectionUrl' => $curl,
  898.                                 'file' => 'shd_' $row['file']
  899.                             ]
  900.                         )
  901.                         : null,
  902.                     's_900' => PathHelper::pathGenerate(
  903.                         'interior',
  904.                         [
  905.                             'factoryUrl' => $furl,
  906.                             'collectionUrl' => $curl,
  907.                             'file' => $row['file']
  908.                         ]
  909.                     )
  910.                 ];
  911.                 $newElements[$row['id']]['pathImg'] = PathHelper::pathGenerate(
  912.                     'interior',
  913.                     [
  914.                         'factoryUrl' => $furl,
  915.                         'collectionUrl' => $curl,
  916.                         'file' => $row['file']
  917.                     ]
  918.                 );
  919.                 $alt[] = $row['name'];
  920.                 foreach ($row['textures'] as $k => $texture) {
  921.                     $newElements[$row['id']]['textures'][$k]['alias'] = $alt[] = App::trans($texture['alias']);
  922.                 }
  923.                 $titleData['i_name'] = $res['numberElement'][$row['id']];
  924.                 $titleData['numberPhoto'] = $res['numberElement'][$row['id']];
  925.                 $titleData['minPrice'] = $this->interiorRepository->getArticleMinPriceByInteriorId($row['id']);
  926.             } else {
  927.                 $titleData['a_name'] = $row['name'];
  928.                 if ($request->get('sample')) {
  929.                     $newElements[$row['id']]['sampleData'] = $samplesArray[$row['code']] ?? [];
  930.                 } else {
  931.                     $newElements[$row['id']]['sampleData'] = null;
  932.                 }
  933.                 // todo удалить при первой возможности - вынести из цикла!
  934.                 $titleData['minPrice'] = $this->articleRepository->getArticleMinPriceById($row['id']);
  935.                 $newElements[$row['id']]['addUrl'] = App::generateUrl(
  936.                     'app_buy_orders_list',
  937.                     [
  938.                         'articleId' => $row['id']
  939.                     ]
  940.                 );
  941.                 $newElements[$row['id']]['sampleUrl'] = App::generateUrl(
  942.                     'app_order_sample',
  943.                     [
  944.                         'code' => $row['code']
  945.                     ]
  946.                 );
  947.                 $newElements[$row['id']]['collectionUrl'] = App::generateUrl(
  948.                     'app_collection',
  949.                     [
  950.                         'factoryUrl' => $furl,
  951.                         'collectionUrl' => $curl,
  952.                     ]
  953.                 );
  954.                 $newElements[$row['id']]['factoryUrl'] = App::generateUrl(
  955.                     'app_catalog',
  956.                     [
  957.                         'key' => $furl
  958.                     ]
  959.                 );
  960.                 $newElements[$row['id']]['prc'] = LocaleHelper::getPrice($row);
  961.                 $newElements[$row['id']]['mea'] = App::trans(LocaleHelper::getMeasure($row));
  962.                 $newElements[$row['id']]['amount'] = LocaleHelper::getAmount($row);
  963.                 $newElements[$row['id']]['orders'] = !empty($ordersItems[$row['id']]) ? $ordersItems[$row['id']] : false;
  964.                 $newElements[$row['id']]['ssLink'] = App::generateUrl(
  965.                     'app_collection_slideshow',
  966.                     [
  967.                         'factoryUrl' => $furl,
  968.                         'collectionUrl' => $curl,
  969.                         'type' => 'a',
  970.                         'elementId' => $row['url']
  971.                     ]
  972.                 );
  973.                 $newElements[$row['id']]['file'] = $row['details']['file'] ?? null;
  974.                 $newElements[$row['id']]['pathImg'] = PathHelper::pathGenerate(
  975.                     'article',
  976.                     [
  977.                         'factoryUrl' => $furl,
  978.                         'collectionUrl' => $curl,
  979.                         'file' => 'b_' $row['details']['file'] ?? null
  980.                     ]
  981.                 );
  982.                 if ($row['details']['commentSchemeImage']) {
  983.                     $newElements[$row['id']]['commentSchemeImage'] = PathHelper::pathGenerate(
  984.                         'article',
  985.                         [
  986.                             'factoryUrl' => $furl,
  987.                             'collectionUrl' => $curl,
  988.                             'file' => $row['details']['commentSchemeImage']
  989.                         ]
  990.                     );
  991.                 }
  992.                 if ($row['shape']) {
  993.                     $newElements[$row['id']]['shape'] = [
  994.                         'id' => $row['shape']['id'],
  995.                         'alias' => App::trans($row['shape']['alias'])
  996.                     ];
  997.                 }
  998.                 $variantImage $row['details']['variantImage'] ?? null;
  999.                 if ($variantImage) {
  1000.                     if ($variantImage['texture'] ?? null) {
  1001.                         $newElements[$row['id']]['variantImage']['texture'] = ItemHelper::addMainPic(
  1002.                             $variantImage['texture'],
  1003.                             $row['details']['file']
  1004.                         );
  1005.                     }
  1006.                     if ($variantImage['picture'] ?? null) {
  1007.                         $newElements[$row['id']]['variantImage']['picture'] = ItemHelper::addMainPic(
  1008.                             $variantImage['picture'],
  1009.                             $row['details']['file']
  1010.                         );
  1011.                     }
  1012.                 }
  1013.                 $filesEdit $row['details']['fileEdit'] ?? null;
  1014.                 if ($filesEdit) {
  1015.                     foreach ($filesEdit as $fileEdit) {
  1016.                         // генерируем список загружаемых картинок
  1017.                         $newElements[$row['id']]['fileEdit'] = PathHelper::pathGenerate(
  1018.                             'article',
  1019.                             [
  1020.                                 'factoryUrl' => $furl,
  1021.                                 'collectionUrl' => $curl,
  1022.                                 'file' => $fileEdit
  1023.                             ]
  1024.                         );
  1025.                     }
  1026.                 }
  1027.                 $newElements[$row['id']]['imageZipLink'] = null;
  1028.                 $alt[] = $row['name'];
  1029.                 $textures $row['textures'];
  1030.                 foreach ($textures as $k => $texture) {
  1031.                     $newElements[$row['id']]['textures'][$k]['alias'] = $alt[] = App::trans($texture['alias']);
  1032.                 }
  1033.                 if (!empty($row['interiors'])) {
  1034.                     foreach ($row['interiors'] as $i => $r) {
  1035.                         if (
  1036.                             $r['status'] == 2
  1037.                             || $r['collection']['status'] != 1
  1038.                             || $r['collection']['factory']['status'] != 1
  1039.                         ) {
  1040.                             if (!empty($newElements[$row['id']]['interiors'][$i])) {
  1041.                                 unset($newElements[$row['id']]['interiors'][$i]);
  1042.                             }
  1043.                             continue;
  1044.                         }
  1045.                         $newElements[$row['id']]['interiors'][$i]['url'] = $r['url'];
  1046.                         $newElements[$row['id']]['interiors'][$i]['inIdeaBook'] = in_array($r['id'], $favorites);
  1047.                         if (empty($r['file'])) {
  1048.                             $r['file'] = $r['name'] . '.jpg';
  1049.                         }
  1050.                         if (preg_match('#/f/(.*)/a/#is'App::getRequest()->getUri(), $matches)) {
  1051.                             $url App::generateUrl('app_collection_slideshow_f', [
  1052.                                 'factoryUrl' => $r['collection']['factory']['url'],
  1053.                                 'collectionUrl' => $r['collection']['url'],
  1054.                                 'filter' => $matches[1],
  1055.                                 'type' => 'i',
  1056.                                 'elementId' => $r['url']
  1057.                             ]);
  1058.                         } else {
  1059.                             $url App::generateUrl('app_collection_slideshow', [
  1060.                                 'factoryUrl' => $r['collection']['factory']['url'],
  1061.                                 'collectionUrl' => $r['collection']['url'],
  1062.                                 'type' => 'i',
  1063.                                 'elementId' => $r['url']
  1064.                             ]);
  1065.                         }
  1066.                         $r['file'] = StrHelper::toLower($r['file']);
  1067. //                        $newElements[$row['id']]['interiors']['setting'] = $this->getSettingColl($r['collection']['id']);
  1068. //                        https://te.remote.team/#/discus/6C90A7A2-893A-62A1-117D-43B66115858D/
  1069.                         $newElements[$row['id']]['interiors']['setting'] = $r['collection']['settings'];
  1070.                         $newElements[$row['id']]['interiors'][$i]['url'] = $url;
  1071.                         $newElements[$row['id']]['interiors'][$i]['paths'] = [
  1072.                             'hd' => !empty($r['fileSizeHDY']) ?
  1073.                                 PathHelper::pathGenerate(
  1074.                                     'interior',
  1075.                                     [
  1076.                                         'factoryUrl' => $r['collection']['factory']['url'],
  1077.                                         'collectionUrl' => $r['collection']['url'],
  1078.                                         'file' => 'hd_' $r['file']
  1079.                                     ]
  1080.                                 )
  1081.                                 : null,
  1082.                             'shd_1080' => !empty($r['fileSizeSHDY'])
  1083.                                 ? PathHelper::pathGenerate(
  1084.                                     'interior',
  1085.                                     [
  1086.                                         'factoryUrl' => $r['collection']['factory']['url'],
  1087.                                         'collectionUrl' => $r['collection']['url'],
  1088.                                         'file' => 'shd_' $r['file']
  1089.                                     ]
  1090.                                 )
  1091.                                 : null,
  1092.                             's_900' => PathHelper::pathGenerate(
  1093.                                 'interior',
  1094.                                 [
  1095.                                     'factoryUrl' => $r['collection']['factory']['url'],
  1096.                                     'collectionUrl' => $r['collection']['url'],
  1097.                                     'file' => $r['file']
  1098.                                 ]
  1099.                             )
  1100.                         ];
  1101.                     }
  1102.                 } else {
  1103.                     $newElements[$row['id']]['interiors'] = [];
  1104.                 }
  1105.                 $newElements[$row['id']] = ArticleHelper::getTileArticleAddOptions($newElements[$row['id']]);
  1106.             }
  1107.             if (!empty($newElements[$row['id']]['interiors'])) {
  1108.                 unset($newElements[$row['id']]['interiors']['setting']);
  1109.                 // необходимо, чтобы выровнять ключи
  1110.                 $newElements[$row['id']]['interiors'] = array_values($newElements[$row['id']]['interiors']);
  1111.             }
  1112.             $metaManager = new MetaManager($titleData, [
  1113.                 '_route' => 'app_collection_slideshow',
  1114.                 'type' => $type
  1115.             ]);
  1116.             $newElements[$row['id']]['title'] = html_entity_decode($metaManager->getTitle());
  1117.             $newElements[$row['id']]['description'] = $metaManager->getDescription();
  1118.         }
  1119.         return [
  1120.             'elements' => $newElements,
  1121.             'elementsCount' => $elementsCount,
  1122.             'elementId' => $elementId,
  1123.             'numberElement' => $res['numberElement'],
  1124.         ];
  1125.     }
  1126.     /**
  1127.      * @param array $elementIdes
  1128.      * @param ?int $elementId
  1129.      * @param ?string $load
  1130.      * @return array
  1131.      */
  1132.     private function getIdes(array $elementIdes, ?int $elementId null, ?string $load 'all'): array
  1133.     {
  1134.         if (!in_array($load, ['left''right''all'])) {
  1135.             $load 'all';
  1136.         }
  1137.         if ($elementId == null) {
  1138.             $elementId = !empty($elementIdes[0]['id']) ? $elementIdes[0]['id'] : $elementIdes[0] ?? null;
  1139.         }
  1140.         $numberElement = [];
  1141.         $ides = [=> 0];
  1142.         foreach ($elementIdes as $k => $row) {
  1143.             if ($elementId == $row) {
  1144.                 $numberElement[$row] = $k 1;
  1145.                 if ($load == 'all') {
  1146.                     $ides[] = $row;
  1147.                 }
  1148.                 if ($load == 'left' || $load == 'all') {
  1149.                     if (!empty($elementIdes[$k 2])) {
  1150.                         $ides[] = $elementIdes[$k 2];
  1151.                         $numberElement[$elementIdes[$k 2]] = $k 1;
  1152.                     }
  1153.                     if (!empty($elementIdes[$k 1])) {
  1154.                         $ides[] = $elementIdes[$k 1];
  1155.                         $numberElement[$elementIdes[$k 1]] = $k;
  1156.                     }
  1157.                 }
  1158.                 if ($load == 'right' || $load == 'all') {
  1159.                     if (!empty($elementIdes[$k 1])) {
  1160.                         $ides[] = $elementIdes[$k 1];
  1161.                         $numberElement[$elementIdes[$k 1]] = $k 2;
  1162.                     }
  1163.                     if (!empty($elementIdes[$k 2])) {
  1164.                         $ides[] = $elementIdes[$k 2];
  1165.                         $numberElement[$elementIdes[$k 2]] = $k 3;
  1166.                     }
  1167.                 }
  1168.                 break;
  1169.             }
  1170.         }
  1171.         return [
  1172.             'ides' => $ides,
  1173.             'numberElement' => $numberElement
  1174.         ];
  1175.     }
  1176.     /**
  1177.      * @param Request $request
  1178.      * @param string $factoryUrl
  1179.      * @param string $collectionUrl
  1180.      * @param string $type
  1181.      * @param string|int $elementId
  1182.      * @param ?string $load
  1183.      * @return Response
  1184.      * @throws Exception|\Doctrine\DBAL\Driver\Exception
  1185.      */
  1186.     public function slideAction(
  1187.         Request $request,
  1188.         string $factoryUrl,
  1189.         string $collectionUrl,
  1190.         string $type,
  1191.         $elementId,
  1192.         ?string $load 'all'
  1193.     ) {
  1194.         $token UserHelper::getInstance()->getToken();
  1195.         $collection $this->collectionRepository->getSlideCollection($factoryUrl$collectionUrl);
  1196.         if (!$collection) {
  1197.             throw $this->createNotFoundException('The collection is not found');
  1198.         }
  1199. //App::debugExit($request, $factoryUrl, $collectionUrl ,$type, $elementId);
  1200.         $data $this->getData($request$token$type$collection$elementId$load);
  1201.         return new JsonResponse(['elements' => $data['elements']]);
  1202.     }
  1203.     private function unsetInactiveArticleInInteriorOrCollection(?array $element): ?array
  1204.     {
  1205.         foreach ($element['articles'] ?? [] as $key => $article) {
  1206.             if ($article['collection']['status'] == 2) {
  1207.                 unset($element['articles'][$key]);
  1208.             }
  1209.         }
  1210.         return $element;
  1211.     }
  1212.     private function getGoogleRefererInfo(): bool
  1213.     {
  1214.         if (
  1215.             stripos($_SERVER['HTTP_REFERER'] ?? '''google.') !== false
  1216.             && stripos($_SERVER['HTTP_REFERER'] ?? '''mail.google.') === false
  1217.         ) {
  1218.             return true;
  1219.         }
  1220.         // https://te2.remote.team/discus/DA0E211E-CD52-A435-805A-0039E39A2954
  1221.         if (stripos($_SERVER['HTTP_REFERER'] ?? '''googleadservices.') !== false) {
  1222.             return true;
  1223.         }
  1224.         // https://te2.remote.team/discus/D058F322-78AA-AEBE-9D88-B2B9B077677C
  1225.         if (empty($_SERVER['HTTP_REFERER'])) {
  1226.             return true;
  1227.         }
  1228.         return false;
  1229.     }
  1230.     private function addInfoAboutAvailableInCountryOfFactory(array $collection, array &$newElement): void
  1231.     {
  1232.         if (!($collection['factory']['country']['code'] ?? null)) {
  1233.             return;
  1234.         }
  1235.         switch (StrHelper::toLower($collection['factory']['country']['code'])) {
  1236.             case 'it':
  1237.                 $newElement['in_stock'] = $this->translator->trans('in_stock_italy');
  1238.                 return;
  1239.             case 'es':
  1240.                 $newElement['in_stock'] = $this->translator->trans('in_stock_spain');
  1241.                 return;
  1242.             case 'ge':
  1243.                 $newElement['in_stock'] = $this->translator->trans('in_stock_germany');
  1244.                 return;
  1245.             case 'ma':
  1246.                 $newElement['in_stock'] = $this->translator->trans('in_stock_morocco');
  1247.                 return;
  1248.             case 'pt':
  1249.                 $newElement['in_stock'] = $this->translator->trans('in_stock_portugal');
  1250.                 return;
  1251.         }
  1252.     }
  1253. }