collectCookieGroups example

private $config;

    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.