/** * 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; } }