![]() 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-review/Block/Adminhtml/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ declare(strict_types=1); /** * Adminhtml review main block */ namespace Magento\Review\Block\Adminhtml; use Magento\Framework\App\ObjectManager; use Magento\Catalog\Model\ResourceModel\Product\CollectionFactory as ProductCollectionFactory; /** * Class \Magento\Review\Block\Adminhtml\Main */ class Main extends \Magento\Backend\Block\Widget\Grid\Container { /** * Core registry * * @var \Magento\Framework\Registry */ protected $_coreRegistry = null; /** * @var \Magento\Customer\Api\CustomerRepositoryInterface */ protected $customerRepository; /** * Catalog product model factory * * @var \Magento\Catalog\Model\ProductFactory */ protected $_productFactory; /** * Customer View Helper * * @var \Magento\Customer\Helper\View */ protected $_customerViewHelper; /** * Product Collection * * @var ProductCollectionFactory */ private $productCollectionFactory; /** * @param \Magento\Backend\Block\Widget\Context $context * @param \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository * @param \Magento\Catalog\Model\ProductFactory $productFactory * @param \Magento\Framework\Registry $registry * @param \Magento\Customer\Helper\View $customerViewHelper * @param array $data * @param ProductCollectionFactory $productCollectionFactory */ public function __construct( \Magento\Backend\Block\Widget\Context $context, \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository, \Magento\Catalog\Model\ProductFactory $productFactory, \Magento\Framework\Registry $registry, \Magento\Customer\Helper\View $customerViewHelper, array $data = [], ProductCollectionFactory $productCollectionFactory = null ) { $this->_coreRegistry = $registry; $this->customerRepository = $customerRepository; $this->_productFactory = $productFactory; $this->_customerViewHelper = $customerViewHelper; $this->productCollectionFactory = $productCollectionFactory ?: ObjectManager::getInstance() ->get(ProductCollectionFactory::class); parent::__construct($context, $data); } /** * Initialize add new review * * @return void */ protected function _construct() { $this->_addButtonLabel = __('New Review'); parent::_construct(); $this->_blockGroup = 'Magento_Review'; $this->_controller = 'adminhtml'; if (!$this->productCollectionFactory->create()->getSize()) { $this->removeButton('add'); } // lookup customer, if id is specified $customerId = $this->getRequest()->getParam('customerId', false); $customerName = ''; if ($customerId) { $customer = $this->customerRepository->getById($customerId); $customerName = $this->escapeHtml($this->_customerViewHelper->getCustomerName($customer)); } $productId = $this->getRequest()->getParam('productId', false); $productName = null; if ($productId) { $product = $this->_productFactory->create()->load($productId); $productName = $this->escapeHtml($product->getName()); } if ($this->_coreRegistry->registry('usePendingFilter') === true) { if ($customerName) { $this->_headerText = __('Pending Reviews of Customer `%1`', $customerName); } else { $this->_headerText = __('Pending Reviews'); } $this->buttonList->remove('add'); } else { if ($customerName) { $this->_headerText = __('All Reviews of Customer `%1`', $customerName); } elseif ($productName) { $this->_headerText = __('All Reviews of Product `%1`', $productName); } else { $this->_headerText = __('All Reviews'); } } } }