Ejemplo n.º 1
0
 protected function showComment(BaseHookRenderEvent $event)
 {
     list($ref, $refId) = $this->getParams($event);
     $eventDefinition = new CommentDefinitionEvent();
     $eventDefinition->setRef($ref)->setRefId($refId)->setCustomer($this->getCustomer())->setConfig(Comment::getConfig());
     $message = '';
     try {
         $this->dispatcher->dispatch(CommentEvents::COMMENT_GET_DEFINITION, $eventDefinition);
         $eventDefinition->setValid(true);
     } catch (InvalidDefinitionException $ex) {
         if ($ex->isSilent()) {
             return null;
         }
         $eventDefinition->setValid(false);
         $message = $ex->getMessage();
     } catch (\Exception $ex) {
         Tlog::getInstance()->debug($ex->getMessage());
         return null;
     }
     return $this->render("comment.html", ['definition' => $eventDefinition, 'message' => $message]);
 }
Ejemplo n.º 2
0
 public function getContentDefinition(CommentDefinitionEvent $event)
 {
     $config = $event->getConfig();
     $event->setVerified(true);
     $event->setRating(false);
     // is comment is authorized on this product
     $commentProductActivated = MetaDataQuery::getVal(Comment::META_KEY_ACTIVATED, \Thelia\Model\MetaData::CONTENT_KEY, $event->getRefId());
     // not defined, get the global config
     if ("1" !== $commentProductActivated) {
         if ("0" === $commentProductActivated || false === $config['activated']) {
             throw new InvalidDefinitionException($this->translator->trans("Comment not activated on this element.", ['%ref' => $event->getRef()], CommentModule::MESSAGE_DOMAIN));
         }
     }
 }
Ejemplo n.º 3
0
 protected function getDefinition($ref, $refId)
 {
     $eventDefinition = new CommentDefinitionEvent();
     $eventDefinition->setRef($ref)->setRefId($refId)->setCustomer($this->getSecurityContext()->getCustomerUser())->setConfig(Comment::getConfig());
     $this->dispatch(CommentEvents::COMMENT_GET_DEFINITION, $eventDefinition);
     return $eventDefinition;
 }