Skip to content

Commit

Permalink
Merge pull request #38 from punktDeForks/bugfix/do-not-fail-when-cook…
Browse files Browse the repository at this point in the history
…iesettingspage-is-missing

BUGFIX: Do not fail if cookie settings CE is missing
  • Loading branch information
Nikdro authored Oct 22, 2021
2 parents 5619d1e + 9bddfdd commit 08dfe10
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Classes/Controller/JavaScriptController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use KaufmannDigital\GDPR\CookieConsent\Mvc\View\CustomTemplateView;
use Neos\Cache\Frontend\StringFrontend;
use Neos\ContentRepository\Domain\Model\NodeInterface;
use Neos\ContentRepository\Domain\Service\ContextFactoryInterface;
use Neos\Eel\FlowQuery\FlowQuery;
use Neos\Flow\Http\Component\SetHeaderComponent;
Expand Down Expand Up @@ -85,6 +86,11 @@ function ($key) {

$consentDate = new \DateTime(isset($cookie['consentDates'][$dimensionIdentifier]) ? $cookie['consentDates'][$dimensionIdentifier] : $cookie['consentDate']);
$cookieSettings = $q->find('[instanceof KaufmannDigital.GDPR.CookieConsent:Content.CookieSettings]')->get(0);

if (!$cookieSettings instanceof NodeInterface) {
throw new \Exception('No cookie settings could be found', 1634843525);
}

$decisionTtl = $cookieSettings->getProperty('decisionTtl') ?? 0;
$expireDate = clone $consentDate;
$expireDate->add(\DateInterval::createFromDateString($decisionTtl . ' seconds'));
Expand Down

0 comments on commit 08dfe10

Please sign in to comment.