init
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
<?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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user