-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reuse default cookie restriction mode
- Loading branch information
1 parent
c8ae934
commit f18ce7c
Showing
10 changed files
with
129 additions
and
197 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
/** | ||
* Copyright © OpenGento, All rights reserved. | ||
* See LICENSE bundled with this library for license details. | ||
*/ | ||
declare(strict_types=1); | ||
|
||
namespace Opengento\Gdpr\ViewModel\Cookie; | ||
|
||
use Magento\Framework\View\Element\Block\ArgumentInterface; | ||
use Opengento\Gdpr\Model\Config\PrivacyMessage; | ||
|
||
final class NoticeDataProvider implements ArgumentInterface | ||
{ | ||
private PrivacyMessage $privacyMessage; | ||
|
||
public function __construct(PrivacyMessage $privacyMessage) | ||
{ | ||
$this->privacyMessage = $privacyMessage; | ||
} | ||
|
||
public function getTemplate(string $defaultTemplate, string $customTemplate): string | ||
{ | ||
return $this->privacyMessage->isEnabled() ? $customTemplate : $defaultTemplate; | ||
} | ||
|
||
public function getLearnMoreUrl(): ?string | ||
{ | ||
return $this->privacyMessage->getLearnMoreUrl(); | ||
} | ||
|
||
public function getNoticeHtml(): string | ||
{ | ||
return $this->privacyMessage->getDisclosureInformationHtml(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
declare(strict_types=1); | ||
/** | ||
* Copyright © OpenGento, All rights reserved. | ||
* See LICENSE bundled with this library for license details. | ||
*/ | ||
|
||
use Magento\Cookie\Block\Html\Notices; | ||
use Magento\Cookie\Helper\Cookie; | ||
use Magento\Framework\Escaper; | ||
use Magento\Framework\View\Helper\SecureHtmlRenderer; | ||
use Opengento\Gdpr\ViewModel\Cookie\NoticeDataProvider; | ||
|
||
/** @var Notices $block */ | ||
/** @var Escaper $escaper */ | ||
/** @var SecureHtmlRenderer $secureRenderer */ | ||
/** @var Cookie $cookieHelper */ | ||
$cookieHelper = $block->getData('cookieHelper'); | ||
/** @var NoticeDataProvider $noticeDataProvider */ | ||
$noticeDataProvider = $block->getData('noticeDataProvider'); | ||
|
||
$learnMoreUrl = $noticeDataProvider->getLearnMoreUrl() ?: $block->getPrivacyPolicyLink() | ||
?> | ||
<?php | ||
if ($cookieHelper->isCookieRestrictionModeEnabled()): ?> | ||
<div role="alertdialog" | ||
tabindex="-1" | ||
class="message global cookie" | ||
id="notice-cookie-block"> | ||
<div role="document" class="content" tabindex="0"> | ||
<div class="details"> | ||
<?= /* @noEscape */ $noticeDataProvider->getNoticeHtml() ?> | ||
<p> | ||
<strong><?= $block->escapeHtml(__('We use cookies to make your experience better.')) ?></strong> | ||
<?= $block->escapeHtml(__('<a href="%1">Learn more</a>.', $learnMoreUrl), ['a']) ?> | ||
</p> | ||
</div> | ||
<div class="actions"> | ||
<button id="btn-cookie-allow" class="action allow primary"> | ||
<span><?= $block->escapeHtml(__('Allow Cookies')) ?></span> | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
<?= /* @noEscape */ $secureRenderer->renderStyleAsTag('display: none;', 'div#notice-cookie-block') ?> | ||
<script type="text/x-magento-init"> | ||
{ | ||
"#notice-cookie-block": { | ||
"cookieNotices": { | ||
"cookieAllowButtonSelector": "#btn-cookie-allow", | ||
"cookieName": "<?= /* @noEscape */ Cookie::IS_USER_ALLOWED_SAVE_COOKIE ?>", | ||
"cookieValue": <?= /* @noEscape */ $cookieHelper->getAcceptedSaveCookiesWebsiteIds() ?>, | ||
"cookieLifetime": <?= /* @noEscape */ $cookieHelper->getCookieRestrictionLifetime() ?>, | ||
"noCookiesUrl": "<?= $escaper->escapeJs($block->getUrl('cookie/index/noCookies')) ?>" | ||
} | ||
} | ||
} | ||
</script> | ||
<?php endif; ?> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.