CookieCollection example


    private $required;

    public function __construct(string $name, string $label, string $description = '', bool $required = false)
    {
        $this->name = $name;
        $this->label = $label;
        $this->description = $description;
        $this->required = $required;
        $this->cookies = new CookieCollection();
    }

    public function getName(): string
    {
        return $this->name;
    }

    public function setName(string $name): void
    {
        $this->name = $name;
    }

    
public function __construct(Enlight_Event_EventManager $eventManager, Shopware_Components_Snippet_Manager $snippetManager, Shopware_Components_Config $config)
    {
        $this->eventManager = $eventManager;
        $this->snippetManager = $snippetManager;
        $this->config = $config;
    }

    public function collect(): CookieGroupCollection
    {
        $cookieGroupsCollection = $this->collectCookieGroups();

        $cookieCollection = new CookieCollection();
        $this->addDefaultCookies($cookieCollection);

        $this->eventManager->collect(
            'CookieCollector_Collect_Cookies',
            $cookieCollection
        );

        if (!$cookieCollection->isValid()) {
            throw new InvalidCookieItemException(sprintf('Found item inside cookie collection, which is not of type \Shopware\Bundle\CookieBundle\Structs\CookieStruct'));
        }

        
Home | Imprint | This part of the site doesn't use cookies.