<?php
/**
 * Mageplaza
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Mageplaza.com license that is
 * available through the world-wide-web at this URL:
 * https://www.mageplaza.com/LICENSE.txt
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade this extension to newer
 * version in the future.
 *
 * @category    Mageplaza
 * @package     Mageplaza_ProductAttachments
 * @copyright   Copyright (c) Mageplaza (http://www.mageplaza.com/)
 * @license     https://www.mageplaza.com/LICENSE.txt
 */

namespace Mageplaza\ProductAttachments\Plugin\Model\Product;

use Magento\Backend\Block\Template;
use Magento\Framework\Exception\LocalizedException;
use Magento\PricePermissions\Observer\AdminhtmlBlockHtmlBeforeObserver;
use Magento\Framework\Event\Observer as EventObserver;

/**
 * Class NewEditProduct
 * @package Mageplaza\ProductAttachments\Plugin\Model\Product
 */
class NewEditProduct
{
    /**
     * @param AdminhtmlBlockHtmlBeforeObserver $subject
     * @param callable $proceed
     * @param EventObserver $observer
     *
     * @return void
     * @throws LocalizedException
     */
    public function aroundExecute(AdminhtmlBlockHtmlBeforeObserver $subject, callable $proceed, $observer)
    {
        /** @var $block Template */
        $block = $observer->getBlock();

        if ($block->getNameInLayout() !== null) {
            return $proceed($observer);
        }
    }
}
