_escaper = $escaper; $this->filter = $filter; parent::__construct($context); } /** * Get review detail * * @param string $origDetail * @return string */ public function getDetail($origDetail) { return nl2br($this->filter->truncate($origDetail, ['length' => 50])); } /** * Return short detail info in HTML * * @param string $origDetail Full detail info * @return string */ public function getDetailHtml($origDetail) { return nl2br($this->filter->truncate($this->_escaper->escapeHtml($origDetail), ['length' => 50])); } /** * Return an indicator of whether or not guest is allowed to write * * @return bool * @SuppressWarnings(PHPMD.BooleanGetMethodName) */ public function getIsGuestAllowToWrite() { return $this->scopeConfig->isSetFlag( self::XML_REVIEW_GUETS_ALLOW, \Magento\Store\Model\ScopeInterface::SCOPE_STORE ); } /** * Get review statuses with their codes * * @return array */ public function getReviewStatuses() { return [ \Magento\Review\Model\Review::STATUS_APPROVED => __('Approved'), \Magento\Review\Model\Review::STATUS_PENDING => __('Pending'), \Magento\Review\Model\Review::STATUS_NOT_APPROVED => __('Not Approved') ]; } /** * Get review statuses as option array * * @return array */ public function getReviewStatusesOptionArray() { $result = []; foreach ($this->getReviewStatuses() as $value => $label) { $result[] = ['value' => $value, 'label' => $label]; } return $result; } }