32 lines
908 B
PHP
32 lines
908 B
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace Esun\CmsLayout\Observer;
|
|
|
|
use Magento\Framework\Event\Observer;
|
|
use Magento\Framework\Event\ObserverInterface;
|
|
use Magento\Framework\View\Page\Config as PageConfig;
|
|
|
|
class ApplyCustomFullWidthLayout implements ObserverInterface
|
|
{
|
|
private const PAGE_LAYOUT = 'cms-custom-full-width';
|
|
|
|
public function __construct(
|
|
private readonly PageConfig $pageConfig
|
|
) {
|
|
}
|
|
|
|
public function execute(Observer $observer): void
|
|
{
|
|
if ($observer->getEvent()->getFullActionName() !== 'cms_page_view'
|
|
|| $this->pageConfig->getPageLayout() !== self::PAGE_LAYOUT
|
|
) {
|
|
return;
|
|
}
|
|
|
|
$this->pageConfig->addBodyClass('cms-custom-full-width');
|
|
$this->pageConfig->addPageAsset('Magento_Theme::css/cms-custom-common.css');
|
|
$observer->getEvent()->getLayout()->unsetElement('breadcrumbs');
|
|
}
|
|
}
|