Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/cartforge.co/vendor/magento/module-page-builder/Plugin/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/cartforge.co/vendor/magento/module-page-builder/Plugin/DesignLoader.php
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
declare(strict_types=1);

namespace Magento\PageBuilder\Plugin;

use Magento\Catalog\Model\Product;
use Magento\Framework\App\AreaList;
use Magento\Framework\App\State;
use Magento\Framework\Message\ManagerInterface;
use Magento\Framework\Message\MessageInterface;

/**
 * Load necessary design files for GraphQL
 */
class DesignLoader
{
    /**
     * @var ManagerInterface
     */
    private $messageManager;

    /**
     * Application arealist
     *
     * @var AreaList
     */
    private $areaList;

    /**
     * Application State
     *
     * @var State
     */
    private $appState;

    /**
     * @var \Magento\PageBuilder\Model\Stage\Preview
     */
    private $preview;

    /**
     * @param \Magento\Framework\Message\ManagerInterface $messageManager
     * @param \Magento\Framework\App\State $appState
     * @param \Magento\PageBuilder\Model\Stage\Preview $preview
     * @param AreaList $areaList
     */
    public function __construct(
        \Magento\Framework\Message\ManagerInterface $messageManager,
        \Magento\Framework\App\State $appState,
        \Magento\PageBuilder\Model\Stage\Preview $preview,
        AreaList $areaList
    ) {
        $this->messageManager = $messageManager;
        $this->appState = $appState;
        $this->preview = $preview;
        $this->areaList = $areaList;
    }

    /**
     * Before create load the design files
     *
     * @param \Magento\Catalog\Block\Product\ImageFactory $subject
     * @param Product $product
     * @param string $imageId
     * @param array|null $attributes
     * @throws \Exception
     *
     * @SuppressWarnings(PHPMD.UnusedFormalParameter)
     */
    public function beforeCreate(
        \Magento\Catalog\Block\Product\ImageFactory $subject,
        Product $product,
        string $imageId,
        array $attributes = null
    ) {
        if ($this->preview->isPreviewMode()) {
            $this->appState->emulateAreaCode(
                $this->preview->getPreviewArea(),
                [$this, 'loadDesignConfig']
            );
        }
    }

    /**
     * Load the design config
     */
    public function loadDesignConfig()
    {
        try {
            $area = $this->areaList->getArea($this->appState->getAreaCode());
            $area->load(\Magento\Framework\App\Area::PART_DESIGN);
        } catch (\Magento\Framework\Exception\LocalizedException $e) {
            if ($e->getPrevious() instanceof \Magento\Framework\Config\Dom\ValidationException) {
                /** @var MessageInterface $message */
                $message = $this->messageManager
                    ->createMessage(MessageInterface::TYPE_ERROR)
                    ->setText($e->getMessage());
                $this->messageManager->addUniqueMessages([$message]);
            }
        }
    }
}

Spamworldpro Mini