canManageCookie = $canManageCookie; $this->config = $config; $this->isUserOptIn = $isUserOptIn; $this->getCategoryKey = $getCategoryKey; $this->isAllowedCategory = $isAllowedCategory; $this->isKnownCookie = $isKnownCookie; $this->systemCookies = $systemCookies; $this->getTrueName = $getTrueName; } /** * This logic has js alternative in CookieRestriction.isAllowed * * @inheritDoc */ public function execute(string $name): bool { if (in_array($name, $this->systemCookies, true)) { return true; } if (! $this->canManageCookie->execute()) { return true; } $name = $this->getTrueName->execute($name); if (! $this->isUserOptIn->execute()) { if ($this->config->canUseCookieBeforeOptIn()) { return true; } if ($this->isKnownCookie->execute($name)) { return $this->isAllowedCategory->execute($this->getCategoryKey->execute($name)); } return false; } if (! $this->isKnownCookie->execute($name)) { return ! $this->config->canBlockUnknownCookie(); } return $this->isAllowedCategory->execute($this->getCategoryKey->execute($name)); } }