/**
  * Merges a message from an existing translation catalogue.
  *
  * Do not use this if you want to merge a message from an extracted catalogue.
  * In these cases, use merge() instead.
  *
  * @param Message $message
  */
 public function mergeExisting(Message $message)
 {
     if ($this->id !== $message->getId()) {
         throw new RuntimeException(sprintf('You can only merge messages with the same id. Expected id "%s", but got "%s".', $this->id, $message->getId()));
     }
     if (null !== ($meaning = $message->getMeaning())) {
         $this->meaning = $meaning;
     }
     if (null !== ($desc = $message->getDesc())) {
         $this->desc = $desc;
     }
     $this->new = $message->isNew();
     if ($localeString = $message->getLocaleString()) {
         $this->localeString = $localeString;
     }
 }
 /**
  * {@inheritDoc}
  */
 public function mergeExisting(Message $message)
 {
     if ($this->getId() !== $message->getId()) {
         throw new RuntimeException(sprintf('You can only merge messages with the same id. Expected id "%s", but got "%s".', $this->id, $message->getId()));
     }
     $oldDesc = $this->getDesc();
     if ($this->isWritable()) {
         if (null !== ($meaning = $message->getMeaning())) {
             $this->setMeaning($meaning);
         }
         if (null !== ($desc = $message->getDesc())) {
             $this->setDesc($desc);
         }
         $this->setNew($message->isNew());
         if ($localeString = $message->getLocaleString()) {
             $this->setLocaleString($localeString);
         }
     }
     $this->mergeXliffMeta($message, $oldDesc);
 }
 public function testGetIsNew()
 {
     $message = new Message('foo');
     $this->assertTrue($message->isNew());
     $this->assertSame($message, $message->setNew(false));
     $this->assertFalse($message->isNew());
 }
 /**
  * @param $message
  * @return Message\XliffMessage
  */
 private function makeXliffMessage(Message $message)
 {
     $newMessage = new Message\XliffMessage($message->getId(), $message->getDomain());
     $newMessage->setNew($message->isNew());
     $newMessage->setLocaleString($message->getLocaleString());
     $newMessage->setSources($message->getSources());
     $newMessage->addNote('key: ' . $message->getId());
     if ($desc = $message->getDesc()) {
         $newMessage->setDesc($desc);
     }
     return $newMessage;
 }