52 lines
1.3 KiB
PHP
52 lines
1.3 KiB
PHP
<?php
|
|
/**
|
|
* @package Plumrocket_CookieConsent
|
|
* @copyright Copyright (c) 2022 Plumrocket Inc. (https://plumrocket.com)
|
|
* @license https://plumrocket.com/license End-user License Agreement
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Plumrocket\CookieConsent\Plugin;
|
|
|
|
use Magento\Framework\App\ResponseInterface;
|
|
use Magento\Framework\View\Result\Page;
|
|
use Plumrocket\CookieConsent\Model\Integration\NoCookieYoutube;
|
|
|
|
/**
|
|
* @since 1.9.0
|
|
*/
|
|
class YouTubeNoCookiePlugin
|
|
{
|
|
|
|
/**
|
|
* @var \Plumrocket\CookieConsent\Model\Integration\NoCookieYoutube
|
|
*/
|
|
private $noCookieYoutube;
|
|
|
|
/**
|
|
* @param \Plumrocket\CookieConsent\Model\Integration\NoCookieYoutube $noCookieYoutube
|
|
*/
|
|
public function __construct(
|
|
NoCookieYoutube $noCookieYoutube
|
|
) {
|
|
$this->noCookieYoutube = $noCookieYoutube;
|
|
}
|
|
|
|
/**
|
|
* @param \Magento\Framework\View\Result\Page $subject
|
|
* @param $result
|
|
* @param \Magento\Framework\App\ResponseInterface $response
|
|
* @return mixed
|
|
*/
|
|
public function afterRenderResult(Page $subject, $result, ResponseInterface $response)
|
|
{
|
|
if (! $response->getBody() || ! $this->noCookieYoutube->isEnabled()) {
|
|
return $result;
|
|
}
|
|
|
|
$response->setBody($this->noCookieYoutube->convertHtml((string) $response->getBody()));
|
|
return $result;
|
|
}
|
|
}
|