示例#1
0
 /**
  * @param $object
  * @param $flags
  * @return array
  */
 protected function addStaticFlags($object, $flags, $searchFlag = null)
 {
     if ($object instanceof Topic) {
         if ($object->isLocked() && ($searchFlag === null || $searchFlag == "locked")) {
             $flag = new Flag();
             $flag->setFlag("locked");
             $flag->setObject($object);
             $flag->setUser($this->getUser());
             $flags[] = $flag;
         }
         if ($object->getAuthor() && $object->getAuthor()->getId() == $this->getUser()->getId() && ($searchFlag === null || $searchFlag == "author")) {
             $flag = new Flag();
             $flag->setFlag("author");
             $flag->setObject($object);
             $flag->setUser($this->getUser());
             $flags[] = $flag;
         }
     }
     return $flags;
 }
示例#2
0
 /**
  * @param $object
  * @param UserInterface $user
  * @param $flag
  * @return Flag
  */
 public function createNewFlag($object, \Symbb\Core\UserBundle\Entity\UserInterface $user, $flag)
 {
     $flagObject = new Flag();
     $flagObject->setObject($object);
     $flagObject->setUser($user);
     $flagObject->setFlag($flag);
     return $flagObject;
 }