![]() 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/Rating/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Review\Block\Adminhtml\Rating; use Magento\Review\Model\ResourceModel\Rating\Collection as RatingCollection; /** * Adminhtml summary rating stars */ class Summary extends \Magento\Backend\Block\Template { /** * Rating summary template name * * @var string */ protected $_template = 'Magento_Review::rating/stars/summary.phtml'; /** * Core registry * * @var \Magento\Framework\Registry */ protected $_coreRegistry = null; /** * Rating resource option model * * @var \Magento\Review\Model\ResourceModel\Rating\Option\Vote\CollectionFactory */ protected $_votesFactory; /** * Rating model * * @var \Magento\Review\Model\RatingFactory */ protected $_ratingFactory; /** * @param \Magento\Backend\Block\Template\Context $context * @param \Magento\Review\Model\ResourceModel\Rating\Option\Vote\CollectionFactory $votesFactory * @param \Magento\Review\Model\RatingFactory $ratingFactory * @param \Magento\Framework\Registry $registry * @param array $data */ public function __construct( \Magento\Backend\Block\Template\Context $context, \Magento\Review\Model\ResourceModel\Rating\Option\Vote\CollectionFactory $votesFactory, \Magento\Review\Model\RatingFactory $ratingFactory, \Magento\Framework\Registry $registry, array $data = [] ) { $this->_votesFactory = $votesFactory; $this->_ratingFactory = $ratingFactory; $this->_coreRegistry = $registry; parent::__construct($context, $data); } /** * Initialize review data * * @return void */ protected function _construct() { if ($this->_coreRegistry->registry('review_data')) { $this->setReviewId($this->_coreRegistry->registry('review_data')->getId()); } } /** * Get collection of ratings * * @return RatingCollection */ public function getRating() { if (!$this->getRatingCollection()) { $ratingCollection = $this->_votesFactory->create()->setReviewFilter( $this->getReviewId() )->addRatingInfo()->load(); $this->setRatingCollection($ratingCollection->getSize() ? $ratingCollection : false); } return $this->getRatingCollection(); } /** * Get rating summary * * @return string */ public function getRatingSummary() { if (!$this->getRatingSummaryCache()) { $this->setRatingSummaryCache($this->_ratingFactory->create()->getReviewSummary($this->getReviewId())); } return $this->getRatingSummaryCache(); } }