![]() 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/Block/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ declare(strict_types=1); namespace Magento\PageBuilder\Block; use Magento\Framework\App\ObjectManager; use Magento\Framework\Cache\FrontendInterface; use Magento\Framework\DataObject; use Magento\Framework\View\Element\Template; use Magento\Framework\View\Element\Template\Context; use Magento\PageBuilder\Model\Session\RandomKey; use Magento\Ui\Component\Wysiwyg\ConfigInterface; /** * @api */ class WysiwygSetup extends Template { private const WYSIWYG_CONFIG_CACHE_ID = 'WYSIWYG_CONFIG'; /** * @var ConfigInterface */ private $config; /** * @var FrontendInterface */ private $cache; /** * @var RandomKey */ private $sessionRandomKey; /** * @param Context $context * @param ConfigInterface $config * @param array $data * @param FrontendInterface|null $cache * @param RandomKey|null $sessionRandomKey */ public function __construct( Context $context, ConfigInterface $config, array $data = [], FrontendInterface $cache = null, ?RandomKey $sessionRandomKey = null ) { $this->config = $config; $this->cache = $cache ?: ObjectManager::getInstance()->get(FrontendInterface::class); $this->sessionRandomKey = $sessionRandomKey ?: ObjectManager::getInstance()->get(RandomKey::class); parent::__construct($context, $data); } /** * Get config for wysiwyg initialization * * @return string */ public function getConfigJson() : string { $cacheKey = self::WYSIWYG_CONFIG_CACHE_ID; if ($this->_urlBuilder->useSecretKey()) { $cacheKey .= '_' . $this->sessionRandomKey->getValue(); } $configJson = $this->cache->load($cacheKey); if (!$configJson) { $config = $this->config->getConfig(); if (is_array($config)) { $config = new DataObject($config); } $configJson = $config->toJson(); $this->cache->save($configJson, $cacheKey); } return $configJson; } }