/**
  * {@inheritDoc}
  */
 public function prepareEntityBeforeCommit($type)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'prepareEntityBeforeCommit', array($type));
     return parent::prepareEntityBeforeCommit($type);
 }
示例#2
0
 /**
  * Update review ids saved in session
  * used for connection between anonymous user and his reviews
  *
  * @param \XLite\Module\XC\Reviews\Model\Review $entity Entity
  *
  * @return bool
  */
 protected function updateReviewIds(\XLite\Module\XC\Reviews\Model\Review $entity)
 {
     if (!$this->getProfile()) {
         $reviewIds = \XLite\Core\Session::getInstance()->reviewIds;
         if (!is_array($reviewIds)) {
             $reviewIds = array();
         }
         if ($entity->getId()) {
             array_push($reviewIds, $entity->getId());
         }
         \XLite\Core\Session::getInstance()->reviewIds = array_unique($reviewIds);
     }
     return true;
 }
示例#3
0
 /**
  * Return shortened review content
  *
  * @param \XLite\Module\XC\Reviews\Model\Review $entity Review
  *
  * @return string
  */
 protected function getReviewShortContent(\XLite\Module\XC\Reviews\Model\Review $entity)
 {
     $review = $entity->getReview();
     $review = trim($review);
     if (function_exists('mb_substr')) {
         $value = mb_substr($review, 0, 30, 'utf-8');
         $result = $value . (mb_strlen($value, 'utf-8') != mb_strlen($review, 'utf-8') ? '...' : '');
     } else {
         $value = substr($review, 0, 30);
         $result = $value . (strlen($value) != strlen($review) ? '...' : '');
     }
     return func_htmlspecialchars($result);
 }
示例#4
0
 /**
  * Define if review is added by current user
  *
  * @return boolean
  */
 public function isOwnReview(\XLite\Module\XC\Reviews\Model\Review $entity)
 {
     $profile = \XLite\Core\Auth::getInstance()->getProfile();
     $result = false;
     if ($profile) {
         $result = $entity->getProfile() == $profile;
     } else {
         $reviewIds = \XLite\Core\Session::getInstance()->reviewIds;
         if (is_array($reviewIds)) {
             $result = in_array($entity->getId(), $reviewIds);
         }
     }
     return $result;
 }
示例#5
0
 /**
  * Return true if review is approved
  *
  * @return boolean
  */
 protected function isApproved(\XLite\Module\XC\Reviews\Model\Review $entity)
 {
     return $entity->getStatus() == \XLite\Module\XC\Reviews\Model\Review::STATUS_APPROVED;
 }
示例#6
0
 /**
  * Update the reviewer name, email and profile
  *
  * @param \XLite\Module\XC\Reviews\Model\Review $review    Review model object
  * @param integer                               $profileId Profile identificator
  *
  * @return void
  */
 protected function updateProfile(\XLite\Module\XC\Reviews\Model\Review $review, $profileId)
 {
     $profile = \XLite\Core\Database::getRepo('XLite\\Model\\Profile')->find($profileId);
     if ($profile) {
         $review->setProfile($profile);
         $review->setReviewerName($profile->getName());
         $review->setEmail($profile->getLogin());
     }
 }
示例#7
0
 /**
  * Import 'email' value
  *
  * @param \XLite\Module\XC\Reviews\Model\Review $model  Review
  * @param string                                $value  Value
  * @param array                                 $column Column info
  *
  * @return void
  */
 protected function importEmailColumn(\XLite\Module\XC\Reviews\Model\Review $model, $value, array $column)
 {
     $model->setEmail($value);
     if ($value) {
         $result = \XLite\Core\Database::getRepo('XLite\\Model\\Profile')->findByLogin($value);
         if ($result) {
             $model->setProfile($result);
         }
     }
 }