<?php
namespace App\Controller\Front;
use App\Application\Service\ElasticSearch\ElasticSearchService;
use App\Application\Service\Helper\ConfigurationService;
use App\Application\Service\Helper\LinkGenerator;
use App\Entity\System\Pack;
use App\ViewManager\Landing\LandingService;
use App\Entity\System\Cms;
use App\Entity\System\Language;
use App\Entity\System\Tag;
use App\Manager\System\BrandManager;
use App\Manager\System\CmsLanguageManager;
use App\Manager\System\TagManager;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Contracts\Translation\TranslatorInterface;
class CmsController extends AbstractController
{
public string $linkLoginAliExpress = 'https://login.aliexpress.com/join/seller/unifiedJoin.htm?_regbizsource=ES_Bigbuy ';
public string $linkLoginShopify = 'https://www.shopify.com/?ref=bigbuy';
public const DOMAIN = 'landings';
private CmsLanguageManager $cmsLanguageManager;
private BrandManager $brandManager;
private ElasticSearchService $elasticSearchService;
private TranslatorInterface $translator;
private LinkGenerator $linkGenerator;
private TagManager $tagManager;
private LandingService $landingService;
public function __construct(
CmsLanguageManager $cmsLanguageManager,
BrandManager $brandManager,
ElasticSearchService $elasticSearchService,
TranslatorInterface $translator,
LinkGenerator $linkGenerator,
TagManager $tagManager,
LandingService $landingService
) {
$this->cmsLanguageManager = $cmsLanguageManager;
$this->brandManager = $brandManager;
$this->elasticSearchService = $elasticSearchService;
$this->translator = $translator;
$this->linkGenerator = $linkGenerator;
$this->tagManager = $tagManager;
$this->landingService = $landingService;
}
/**
* @Route("en/demo-multi-channel-integration-platform.html")
* @Route("es/demo-multi-channel-integration-platform.html")
* @Route("fr/demo-multi-channel-integration-platform.html")
* @Route("de/demo-multi-channel-integration-platform.html")
* @Route("pt/demo-multi-channel-integration-platform.html")
* @Route("el/demo-multi-channel-integration-platform.html")
* @Route("hr/demo-multi-channel-integration-platform.html")
* @Route("it/demo-multi-channel-integration-platform.html")
* @Route("et/demo-multi-channel-integration-platform.html")
* @Route("da/demo-multi-channel-integration-platform.html")
* @Route("fi/demo-multi-channel-integration-platform.html")
* @Route("ro/demo-multi-channel-integration-platform.html")
* @Route("bg/demo-multi-channel-integration-platform.html")
* @Route("hu/demo-multi-channel-integration-platform.html")
* @Route("sk/demo-multi-channel-integration-platform.html")
* @Route("si/demo-multi-channel-integration-platform.html")
* @Route("lt/demo-multi-channel-integration-platform.html")
* @Route("lv/demo-multi-channel-integration-platform.html")
* @Route("pl/demo-multi-channel-integration-platform.html")
* @Route("nl/demo-multi-channel-integration-platform.html")
* @Route("ru/demo-multi-channel-integration-platform.html")
* @Route("no/demo-multi-channel-integration-platform.html")
* @Route("sv/demo-multi-channel-integration-platform.html")
* @Route("cs/demo-multi-channel-integration-platform.html")
*/
public function viewMIPDemo(Request $request): Response
{
$idLang = $request->getSession()->get('id_lang');
$metas = $this->cmsLanguageManager->getCmsMetasLanguage(Cms::CMS_MIP_DEMO, $idLang);
return $this->render(
'front/cms/cms_mip_demo.html.twig',
[
'metas' => $metas,
'languages' => $this->landingService->getCmsHrefLanguages(),
]
);
}
/**
* @Route("en/integrations-mip.html")
* @Route("es/integraciones-mip.html")
* @Route("fr/integrations-mip.html")
* @Route("de/integrationen-mip.html")
* @Route("pt/integracoes-mip.html")
* @Route("el/integrations-mip.html")
* @Route("hr/integracije-mip.html")
* @Route("it/integrazioni-mip.html")
* @Route("et/integratsiooni-mip.html")
* @Route("da/integreringer-mip.html")
* @Route("fi/integrointialustan-mip.html")
* @Route("ro/integrari-mip.html")
* @Route("bg/integrations-mip.html")
* @Route("hu/integracioi-mip.html")
* @Route("sk/integracie-mip.html")
* @Route("si/integracija-mip.html")
* @Route("lt/integracie-mip.html")
* @Route("lv/integracie-mip.html")
* @Route("pl/integracje-mip.html")
* @Route("nl/integraties-mip.html")
* @Route("ru/integrations-mip.html")
* @Route("no/integrasjoner-mip.html")
* @Route("sv/integrationer-mip.html")
* @Route("cs/integrations-mip.html")
*/
public function view(Request $request): Response
{
$idLang = $request->getSession()->get('id_lang');
$metas = $this->cmsLanguageManager->getCmsMetasLanguage(Cms::CMS_INTEGRATIONS, $idLang);
$cmsFrontLegacy = new \cmsController();
$viewArgs = $cmsFrontLegacy->view();
return $this->render(
'front/cms/cms_integraciones_mip.html.twig',
[
'viewargs' => $viewArgs,
'metas' => $metas,
'languages' => $this->landingService->getCmsHrefLanguages(),
]
);
}
/**
* @Route("en/wholesaler-packs.html")
* @Route("es/packs-mayoristas.html")
* @Route("fr/packs-grossistes.html")
* @Route("de/grosshandelspakete.html")
* @Route("pt/pacotes-grossistas.html")
* @Route("el/paketa-xondrikis.html")
* @Route("hr/veleprodajni-paketi.html")
* @Route("it/pacchetti-all-ingrosso.html")
* @Route("et/hulgimüügipaketid.html")
* @Route("da/engros-pakker.html")
* @Route("fi/tukkumyyjä-paketit.html")
* @Route("ro/pachete-engros.html")
* @Route("bg/opakovka-na-edro.html")
* @Route("hu/nagykereskedői-csomag.html")
* @Route("sk/velkoobchodnicke-baliky.html")
* @Route("si/veleprodajni-paketi.html")
* @Route("lt/didmeniniai-pasiulymai.html")
* @Route("lv/vairumtirgotaju-pakas.html")
* @Route("pl/pakiety-hurtowe.html")
* @Route("nl/groothandel-pakketten.html")
* @Route("ru/wholesaler-packs.html")
* @Route("no/engros-pakker.html")
* @Route("sv/grossistpaket.html")
* @Route("cs/velkoobchodni-balicky.html")
*
* */
public function view_pack_mayorista(Request $request): Response
{
$idLang = $request->getSession()->get('id_lang');
$customerId = $request->getSession()->get('id_customer');
$lang = $request->getSession()->get('lang');
/** @var CmsLanguageManager $metas */
$metas = $this->cmsLanguageManager->getCmsMetasLanguage(Cms::CMS_WHOLESALE_PACKS, $idLang);
$cmsFrontLegacy = new \cmsController();
$cmsPack = $cmsFrontLegacy->view_pack_mayorista();
if ($cmsPack['isMobile']) {
return $this->render(
'front/cms/mobile/cms_packs.html.twig',
[
'metas' => $metas,
'lang' => $lang,
'languages' => $this->landingService->getCmsHrefLanguages(),
'customerId' => $customerId,
'cmsPack' => $cmsPack,
'domain' => 'landings',
]
);
}
return $this->render(
'front/cms/cms_packs.html.twig',
[
'metas' => $metas,
'lang' => $lang,
'languages' => $this->landingService->getCmsHrefLanguages(),
'customerId' => $customerId,
'cmsPack' => $cmsPack,
'domain' => 'landings',
]
);
}
/**
* @Route("en/multi-channel-integration.html")
* @Route("es/multi-channel-integration.html")
* @Route("fr/multi-channel-integration.html")
* @Route("de/multi-channel-integration.html")
* @Route("pt/multi-channel-integration.html")
* @Route("el/multi-channel-integration.html")
* @Route("hr/multi-channel-integration.html")
* @Route("it/multi-channel-integration.html")
* @Route("et/multi-channel-integration.html")
* @Route("da/multi-channel-integration.html")
* @Route("fi/multi-channel-integration.html")
* @Route("ro/multi-channel-integration.html")
* @Route("bg/multi-channel-integration.html")
* @Route("hu/multi-channel-integration.html")
* @Route("sk/multi-channel-integration.html")
* @Route("si/multi-channel-integration.html")
* @Route("lt/multi-channel-integration.html")
* @Route("lv/multi-channel-integration.html")
* @Route("pl/multi-channel-integration.html")
* @Route("nl/multi-channel-integration.html")
* @Route("ru/multi-channel-integration.html")
* @Route("no/multi-channel-integration.html")
* @Route("sv/multi-channel-integration.html")
* @Route("cs/multi-channel-integration.html")
*/
public function mipCms(Request $request, ConfigurationService $configuration, LinkGenerator $linkGenerator): Response
{
$dropshipingConfig = \array_keys(Pack::DROPSHIPPING_PACK_INDEXED_BY_ID);
$lang = $request->getSession()->get('lang');
$idLang = $request->getSession()->get('id_lang');
$customerPack = $request->getSession()->get('customerPack');
$customerId = $request->getSession()->get('id_customer');
/** @var CmsLanguageManager $metas */
$metas = $this->cmsLanguageManager->getCmsMetasLanguage(Cms::CMS_MULTICHANNEL_ID, $idLang);
$criteria = [
'active' => true,
];
$numBrandsActive = $this->brandManager->countBy($criteria);
$numReferences = $this->elasticSearchService->getNumTotalProductsIndexedByElastic();
$hasShop = (bool)\syncronised_shop_configuration::getSyncronisedShops($customerId);
$cmsFrontLegacy = new \cmsController();
$vars = $cmsFrontLegacy->viewFull(Cms::CMS_MULTICHANNEL_ID);
$linkShop = $linkGenerator->getFrontUrl('tiendab2b.html');
if ($vars['is_mobile']) {
return $this->render(
'front/cms/mobile/cms_mip.html.twig',
[
'metas' => $metas,
'lang' => $lang,
'languages' => $this->landingService->getCmsHrefLanguages(),
'customerId' => $customerId,
'vars' => $vars,
'dropshiping' => $dropshipingConfig,
'customerPack' => $customerPack,
'numBrands' => $numBrandsActive,
'numReferences' => $numReferences['total_results'] ?? null,
'hasShop' => $hasShop,
'linkShop' => $linkShop,
'linkLoginAliExpress' => $this->linkLoginAliExpress,
'linkLoginShopify' => $this->linkLoginShopify,
'blackFridayEnabled' => $this->blackFridayIsEnabled(),
]
);
}
return $this->render(
'front/cms/cms_mip.html.twig',
[
'metas' => $metas,
'lang' => $lang,
'languages' => $this->landingService->getCmsHrefLanguages(),
'customerId' => $customerId,
'vars' => $vars,
'dropshiping' => $dropshipingConfig,
'customerPack' => $customerPack,
'numBrands' => $numBrandsActive,
'numReferences' => $numReferences['total_results'] ?? null,
'hasShop' => $hasShop,
'linkShop' => $linkShop,
'linkLoginAliExpress' => $this->linkLoginAliExpress,
'linkLoginShopify' => $this->linkLoginShopify,
'blackFridayEnabled' => $this->blackFridayIsEnabled(),
]
);
}
/**
* @Route("promotionBannerMip")
*
* @param Request $request
*
* @return JsonResponse
*/
public function getPromotionBannerMip(Request $request): JsonResponse
{
$lang = $request->getSession()->get('lang');
$idLang = $request->getSession()->get('id_lang');
$promotionBanner = [
'promotionBanner' => [
'title' => $this->translator->trans('landings.home.promotionBanner.title', ['%html_br%' => '<br />'], self::DOMAIN, $lang),
'subtitle' => $this->translator->trans('landings.home.promotionBanner.subtitle', [], self::DOMAIN, $lang),
'buttonText' => $this->translator->trans('landings.home.promotionBanner.buttonText', [], self::DOMAIN, $lang),
'buttonLink' => $this->linkGenerator->getCmsLink(Cms::CMS_INTEGRATIONS, $idLang),
],
];
return new JsonResponse(json_encode($promotionBanner), Response::HTTP_OK, ['Content-Type', 'application/json'], true);
}
/**
* @return bool
*/
protected function blackFridayIsEnabled(): bool
{
$tag = $this->tagManager->findOneBy(['id' => Tag::BLACK_FRIDAY_TAG_ID, 'language' => Language::SPANISH_LANGUAGE_ID]);
return $tag->isActive();
}
}