Skip to content

Commit cb4c893

Browse files
committed
Improve code, DEV-1111
Signed-off-by: Iman Aboheydary <[email protected]>
1 parent e262dda commit cb4c893

File tree

2 files changed

+4
-53
lines changed

2 files changed

+4
-53
lines changed

Plugin/PageBuilder/Model/Filter/TemplatePlugin.php

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,14 @@
1010

1111
class TemplatePlugin
1212
{
13-
/**
14-
* @var Config
15-
*/
16-
private $config;
17-
18-
/**
19-
* @var ExternalVideoReplacer
20-
*/
21-
private $externalVideoReplacer;
22-
2313
/**
2414
* @param Config $config
2515
* @param ExternalVideoReplacer $externalVideoReplacer
2616
*/
27-
public function __construct(Config $config, ExternalVideoReplacer $externalVideoReplacer)
28-
{
29-
$this->config = $config;
30-
$this->externalVideoReplacer = $externalVideoReplacer;
17+
public function __construct(
18+
private readonly Config $config,
19+
private readonly ExternalVideoReplacer $externalVideoReplacer
20+
) {
3121
}
3222

3323
/**

view/frontend/templates/iframe-handler.phtml

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -9,45 +9,6 @@ $viewModel = $block->getData('view_model');
99

1010
// Only add scripts if video blocking is enabled
1111
if ($viewModel && $viewModel->isBlockVideosUntilConsentEnabled()) {
12-
$addRequiredAttributesScript = '
13-
document.addEventListener("DOMContentLoaded", function() {
14-
const videoIframes = document.querySelectorAll(".pagebuilder-video-container iframe");
15-
16-
videoIframes.forEach((iframe) => {
17-
if (!Cookiebot?.consent?.marketing) {
18-
iframe.setAttribute("data-cookieblock-src", iframe.src);
19-
iframe.setAttribute("data-cookieconsent", "marketing");
20-
iframe.removeAttribute("src");
21-
iframe.closest("[data-content-type=\"video\"]").setAttribute("data-content-type", "image");
22-
}
23-
});
24-
});
25-
26-
addEventListener("CookiebotOnAccept", () => {
27-
const videoIframes = document.querySelectorAll(".pagebuilder-video-container iframe");
28-
29-
videoIframes.forEach((iframe) => {
30-
if (Cookiebot?.consent?.marketing) {
31-
if (iframe.closest("[data-content-type=\"image\"]")) {
32-
iframe.closest("[data-content-type=\"image\"]").setAttribute("data-content-type", "video");
33-
}
34-
}
35-
});
36-
});
37-
38-
addEventListener("CookiebotOnDecline", () => {
39-
const videoIframes = document.querySelectorAll(".pagebuilder-video-container iframe");
40-
41-
videoIframes.forEach((iframe) => {
42-
if (!Cookiebot?.consent?.marketing) {
43-
if (iframe.closest("[data-content-type=\"video\"]")) {
44-
iframe.closest("[data-content-type=\"video\"]").setAttribute("data-content-type", "image");
45-
}
46-
}
47-
});
48-
});
49-
';
50-
5112
$placeholderScript = '
5213
document.addEventListener("DOMContentLoaded", function() {
5314
((document, selector, consentType) => {

0 commit comments

Comments
 (0)