Files
2025-08-02 16:30:27 +02:00

39 lines
1.0 KiB
PHP

<?php
declare(strict_types=1);
namespace KupShop\GraphQLBundle\ApiPublic\Controller;
use KupShop\ComponentsBundle\GTM\PageViews\CommonPageData;
use KupShop\GraphQLBundle\ApiAdmin\Annotation\Module;
use KupShop\GraphQLBundle\ApiPublic\Types\GTM\GTMData;
use KupShop\GTMBundle\PageType\CommonPageType;
use TheCodingMachine\GraphQLite\Annotations\Query;
class GTMController
{
/** @var CommonPageType */
private $commonPageType;
/**
* @required
*/
public function setCommonPageType(CommonPageType $commonPageType, ?CommonPageData $commonPageData): void
{
// Komponenty pouzivaji classu CommonPageData
$this->commonPageType = $commonPageData ?? $commonPageType;
}
#[Query]
#[Module(\Modules::JS_SHOP)]
public function gtmData(): ?GTMData
{
// Can be called together with cartUpdate. Wrapped in try catch, so it cannot cause 500 for cartUpdate
try {
return new GTMData($this->commonPageType);
} catch (\Exception $e) {
return null;
}
}
}