/**
  * Erstellt eine Avatarnachricht zu einem anderen Avatar
  * @param \DragonJsonServerAvatar\Entity\Avatar $from_avatar
  * @param integer $to_avatar_id
  * @param string $subject
  * @param string $content
  * @return Avatarmessage
  */
 public function createAvatarmessage(\DragonJsonServerAvatar\Entity\Avatar $from_avatar, $to_avatar_id, $subject, $content)
 {
     $serviceManager = $this->getServiceManager();
     $to_avatar = $serviceManager->get('\\DragonJsonServerAvatar\\Service\\Avatar')->getAvatarByAvatarId($to_avatar_id);
     if ($from_avatar->getGameroundId() != $to_avatar->getGameroundId()) {
         throw new \DragonJsonServer\Exception('gameround_id not match', ['from_avatar' => $from_avatar->toArray(), 'to_avatar' => $to_avatar->toArray()]);
     }
     $avatarmessage = (new \DragonJsonServerAvatarmessage\Entity\Avatarmessage())->setFromAvatar($from_avatar)->setToAvatar($to_avatar)->setSubject($subject)->setContent($content);
     $this->getServiceManager()->get('\\DragonJsonServerDoctrine\\Service\\Doctrine')->transactional(function ($entityManager) use($avatarmessage) {
         $entityManager->persist($avatarmessage);
         $entityManager->flush();
         $this->getEventManager()->trigger((new \DragonJsonServerAvatarmessage\Event\CreateAvatarmessage())->setTarget($this)->setAvatarmessage($avatarmessage));
     });
     return $this;
 }
 /**
  * Gibt die Allianzbeziehung mit der übergebenen AvatarID zurück
  * @param \DragonJsonServerAvatar\Entity\Avatar $avatar
  * @param boolean $throwException
  * @return \DragonJsonServerAlliance\Entity\Allianceavatar|null
  * @throws \DragonJsonServer\Exception
  */
 public function getAllianceavatarByAvatar($avatar, $throwException = true)
 {
     $entityManager = $this->getEntityManager();
     $allianceavatar = $entityManager->getRepository('\\DragonJsonServerAlliance\\Entity\\Allianceavatar')->findOneBy(['avatar' => $avatar]);
     if (null === $allianceavatar && $throwException) {
         throw new \DragonJsonServer\Exception('invalid avatar', ['avatar' => $avatar->toArray()]);
     }
     return $allianceavatar;
 }