Skip to content

Commit a4e1fd0

Browse files
committed
Add plugin, DEV-1111
Signed-off-by: Iman Aboheydary <iman@customgento.com>
1 parent 895652e commit a4e1fd0

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CustomGento\Cookiebot\Plugin\Cms\Model;
6+
7+
use CustomGento\Cookiebot\Model\Config;
8+
use CustomGento\Cookiebot\Model\ExternalVideoReplacer;
9+
use Magento\Cms\Model\Page;
10+
11+
class AddVideoBlockerToCmsContentPlugin
12+
{
13+
public function __construct(
14+
private readonly Config $config,
15+
private readonly ExternalVideoReplacer $externalVideoReplacer
16+
) {
17+
}
18+
19+
public function afterGetContent(Page $subject, string $result): string
20+
{
21+
// Only process if the block_videos_until_consent feature is enabled
22+
if (!$this->config->isBlockVideosUntilConsentEnabled()) {
23+
return $result;
24+
}
25+
26+
return $this->externalVideoReplacer->replaceIframeSources($result);
27+
}
28+
}

etc/di.xml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
<?xml version="1.0"?>
22
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
33
<type name="Magento\PageBuilder\Model\Filter\Template">
4-
<plugin name="customgento_cookiebot_pagebuilder_template_video_blocker_plugin" type="CustomGento\Cookiebot\Plugin\PageBuilder\Model\Filter\AddVideoBlockerFilterPlugin" sortOrder="10"/>
4+
<plugin name="customgento_cookiebot_pagebuilder_template_video_blocker_plugin" type="CustomGento\Cookiebot\Plugin\PageBuilder\Model\Filter\AddVideoBlockerToCmsContentPlugin" sortOrder="10"/>
5+
</type>
6+
<type name="Magento\Cms\Model\Page">
7+
<plugin name="customgento_cookiebot_cms_page_content_video_blocker_plugin" type="CustomGento\Cookiebot\Plugin\Cms\Model\AddVideoBlockerToCmsContentPlugin" sortOrder="10"/>
58
</type>
69
</config>

0 commit comments

Comments
 (0)