![]() 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/old/vendor/magento/module-widget/Controller/Adminhtml/Widget/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ /** * Adminhtml Manage Widgets Instance Controller */ namespace Magento\Widget\Controller\Adminhtml\Widget; abstract class Instance extends \Magento\Backend\App\Action { /** * Authorization level of a basic admin session * * @see _isAllowed() */ const ADMIN_RESOURCE = 'Magento_Widget::widget_instance'; /** * Core registry * * @var \Magento\Framework\Registry */ protected $_coreRegistry; /** * @var \Magento\Widget\Model\Widget\InstanceFactory */ protected $_widgetFactory; /** * @var \Psr\Log\LoggerInterface */ protected $_logger; /** * @var \Magento\Framework\Math\Random */ protected $mathRandom; /** * @var \Magento\Framework\Translate\InlineInterface */ protected $_translateInline; /** * @param \Magento\Backend\App\Action\Context $context * @param \Magento\Framework\Registry $coreRegistry * @param \Magento\Widget\Model\Widget\InstanceFactory $widgetFactory * @param \Psr\Log\LoggerInterface $logger * @param \Magento\Framework\Math\Random $mathRandom * @param \Magento\Framework\Translate\InlineInterface $translateInline */ public function __construct( \Magento\Backend\App\Action\Context $context, \Magento\Framework\Registry $coreRegistry, \Magento\Widget\Model\Widget\InstanceFactory $widgetFactory, \Psr\Log\LoggerInterface $logger, \Magento\Framework\Math\Random $mathRandom, \Magento\Framework\Translate\InlineInterface $translateInline ) { $this->_translateInline = $translateInline; $this->_coreRegistry = $coreRegistry; $this->_widgetFactory = $widgetFactory; $this->_logger = $logger; $this->mathRandom = $mathRandom; parent::__construct($context); } /** * Load layout, set active menu and breadcrumbs * * @return $this */ protected function _initAction() { $this->_view->loadLayout(); $this->_setActiveMenu( 'Magento_Widget::cms_widget_instance' )->_addBreadcrumb( __('CMS'), __('CMS') )->_addBreadcrumb( __('Manage Widget Instances'), __('Manage Widget Instances') ); return $this; } /** * Init widget instance object and set it to registry * * @return \Magento\Widget\Model\Widget\Instance|boolean */ protected function _initWidgetInstance() { /** @var $widgetInstance \Magento\Widget\Model\Widget\Instance */ $widgetInstance = $this->_widgetFactory->create(); $code = $this->getRequest()->getParam('code', null); $instanceId = $this->getRequest()->getParam('instance_id', null); if ($instanceId) { $widgetInstance->load($instanceId)->setCode($code); if (!$widgetInstance->getId()) { $this->messageManager->addError(__('Please specify a correct widget.')); return false; } } else { // Widget id was not provided on the query-string. Locate the widget instance // type (namespace\classname) based upon the widget code (aka, widget id). $themeId = $this->getRequest()->getParam('theme_id', null); $type = $code != null ? $widgetInstance->getWidgetReference('code', $code, 'type') : null; $widgetInstance->setType($type)->setCode($code)->setThemeId($themeId); } $this->_coreRegistry->register('current_widget_instance', $widgetInstance); return $widgetInstance; } /** * Set body to response * * @param string $body * @return void */ protected function setBody($body) { $this->_translateInline->processResponseBody($body); $this->getResponse()->setBody($body); } }