Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Main.php
Go to the documentation of this file.
1 <?php
11 
12 class Main extends \Magento\Backend\Block\Widget\Grid\Container
13 {
19  protected $_coreRegistry = null;
20 
25 
31  protected $_productFactory;
32 
39 
48  public function __construct(
49  \Magento\Backend\Block\Widget\Context $context,
50  \Magento\Customer\Api\CustomerRepositoryInterface $customerRepository,
51  \Magento\Catalog\Model\ProductFactory $productFactory,
52  \Magento\Framework\Registry $registry,
53  \Magento\Customer\Helper\View $customerViewHelper,
54  array $data = []
55  ) {
56  $this->_coreRegistry = $registry;
57  $this->customerRepository = $customerRepository;
58  $this->_productFactory = $productFactory;
59  $this->_customerViewHelper = $customerViewHelper;
60  parent::__construct($context, $data);
61  }
62 
68  protected function _construct()
69  {
70  $this->_addButtonLabel = __('New Review');
71  parent::_construct();
72 
73  $this->_blockGroup = 'Magento_Review';
74  $this->_controller = 'adminhtml';
75 
76  // lookup customer, if id is specified
77  $customerId = $this->getRequest()->getParam('customerId', false);
78  $customerName = '';
79  if ($customerId) {
80  $customer = $this->customerRepository->getById($customerId);
81  $customerName = $this->escapeHtml($this->_customerViewHelper->getCustomerName($customer));
82  }
83  $productId = $this->getRequest()->getParam('productId', false);
84  $productName = null;
85  if ($productId) {
86  $product = $this->_productFactory->create()->load($productId);
87  $productName = $this->escapeHtml($product->getName());
88  }
89 
90  if ($this->_coreRegistry->registry('usePendingFilter') === true) {
91  if ($customerName) {
92  $this->_headerText = __('Pending Reviews of Customer `%1`', $customerName);
93  } else {
94  $this->_headerText = __('Pending Reviews');
95  }
96  $this->buttonList->remove('add');
97  } else {
98  if ($customerName) {
99  $this->_headerText = __('All Reviews of Customer `%1`', $customerName);
100  } elseif ($productName) {
101  $this->_headerText = __('All Reviews of Product `%1`', $productName);
102  } else {
103  $this->_headerText = __('All Reviews');
104  }
105  }
106  }
107 }
elseif(isset( $params[ 'redirect_parent']))
Definition: iframe.phtml:17
$customer
Definition: customers.php:11
__()
Definition: __.php:13
__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=[])
Definition: Main.php:48