コード例 #1
0
ファイル: TopicDataExtension.php プロジェクト: symbb/symbb
 public function getLabels(\Symbb\Core\ForumBundle\Entity\Topic $element)
 {
     $labels = array();
     $flags = $this->topicFlagHandler->findAll($element);
     foreach ($flags as $flag) {
         $label = array('title' => $flag->getFlag(), 'type' => 'default');
         if ($label["title"] == "new") {
             $label["type"] = 'success';
         } else {
             if ($label["title"] == "answered") {
                 $label["type"] = 'info';
             } else {
                 if ($label["title"] == "locked") {
                     $label["type"] = 'warning';
                 }
             }
         }
         $labels[$label["title"]] = $label;
     }
     $event = new \Symbb\Core\EventBundle\Event\TopicLabelsEvent($element, $labels);
     $this->dispatcher->dispatch('symbb.topic.labels', $event);
     $labels = $event->getLabels();
     foreach ($labels as $key => $label) {
         $labels[$key]['title'] = $this->translator->trans($label['title'], array(), 'symbb_frontend');
     }
     return $labels;
 }
コード例 #2
0
ファイル: TopicManager.php プロジェクト: symbb/symbb
 /**
  * @param Topic $topic
  * @param string $searchForFlag
  * @return bool
  */
 public function checkFlag(Topic $topic, $searchForFlag = '')
 {
     if (empty($searchForFlag)) {
         $searchForFlag = AbstractFlagHandler::FLAG_NEW;
     }
     foreach ($this->topicFlagHandler->findAll($topic) as $flag) {
         if ($flag->getFlag() == $searchForFlag) {
             return true;
         }
     }
     return false;
 }