コード例 #1
0
ファイル: Photo.php プロジェクト: Mesoptier/gewisweb
 /**
  * Tags a user in the specified photo.
  *
  * @param integer $photoId
  * @param integer $lidnr
  *
  * @return \Photo\Model\Tag|null
  */
 public function addTag($photoId, $lidnr)
 {
     if (!$this->isAllowed('add', 'tag')) {
         throw new \User\Permissions\NotAllowedException($this->getTranslator()->translate('Not allowed to add tags.'));
     }
     if (is_null($this->findTag($photoId, $lidnr))) {
         $photo = $this->getPhoto($photoId);
         $member = $this->getMemberService()->findMemberByLidnr($lidnr);
         $tag = new TagModel();
         $tag->setMember($member);
         $photo->addTag($tag);
         $this->getPhotoMapper()->flush();
         return $tag;
     } else {
         // Tag exists
         return null;
     }
 }
コード例 #2
0
ファイル: Photo.php プロジェクト: efueger/gewisweb
 /**
  * Add a tag to a photo.
  *
  * @param \Photo\Model\Tag $tag
  */
 public function addTag($tag)
 {
     $tag->setPhoto($this);
     $this->tags[] = $tag;
 }