当前位置: 首页>>代码示例>>PHP>>正文


PHP Message::getSources方法代码示例

本文整理汇总了PHP中JMS\TranslationBundle\Model\Message::getSources方法的典型用法代码示例。如果您正苦于以下问题:PHP Message::getSources方法的具体用法?PHP Message::getSources怎么用?PHP Message::getSources使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JMS\TranslationBundle\Model\Message的用法示例。


在下文中一共展示了Message::getSources方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: merge

 /**
  * Merges an extracted message.
  *
  * Do not use this if you want to merge a message from an existing catalogue.
  * In these cases, use mergeExisting() instead.
  *
  * @param Message $message
  * @throws RuntimeException
  */
 public function merge(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->localeString = null;
         if ($localeString = $message->getLocaleString()) {
             $this->localeString = $localeString;
         }
     }
     foreach ($message->getSources() as $source) {
         $this->addSource($source);
     }
     $this->new = $message->isNew();
 }
开发者ID:pixel-cookers,项目名称:JMSTranslationBundle,代码行数:29,代码来源:Message.php

示例2: testMergeExisting

 public function testMergeExisting()
 {
     $message = new Message('foo');
     $message->setDesc('bar');
     $existingMessage = new Message('foo');
     $existingMessage->setLocaleString('foobar');
     $existingMessage->setNew(false);
     $existingMessage->addSource(new FileSource('foo/bar'));
     $message->mergeExisting($existingMessage);
     $this->assertEquals('bar', $message->getDesc());
     $this->assertEquals('foobar', $message->getLocaleString());
     $this->assertFalse($message->isNew());
     $this->assertEquals(array(), $message->getSources());
 }
开发者ID:AntoineLemaire,项目名称:JMSTranslationBundle,代码行数:14,代码来源:MessageTest.php

示例3: mergeScanned

 /**
  * {@inheritDoc}
  */
 public function mergeScanned(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()));
     }
     $this->setSources($message->getSources());
     $oldDesc = $this->getDesc();
     if ($this->isWritable()) {
         if (null === $this->getMeaning()) {
             $this->setMeaning($message->getMeaning());
         }
         if (null === $this->getDesc()) {
             $this->setDesc($message->getDesc());
         }
         if (!$this->getLocaleString()) {
             $this->setLocaleString($message->getLocaleString());
         }
     }
     $this->mergeXliffMeta($message, $oldDesc);
 }
开发者ID:GabLeRoux,项目名称:JMSTranslationBundle,代码行数:23,代码来源:XliffMessage.php

示例4: mergeScanned

 /**
  * Merge a scanned message into an extising message.
  *
  * This method does essentially the same as {@link mergeExisting()} but with reversed operands.
  * Whereas {@link mergeExisting()} is used to merge an existing message into a scanned message (this),
  * {@link mergeScanned()} is used to merge a scanned message into an existing message (this).
  * The result of both methods is the same, except that the result will end up in the existing message,
  * instead of the scanned message, so extra information read from the existing message is not discarded.
  *
  * @param Message $message
  *
  * @author Dieter Peeters <peetersdiet@gmail.com>
  */
 public function mergeScanned(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 === $this->getMeaning()) {
         $this->meaning = $message->getMeaning();
     }
     if (null === $this->getDesc()) {
         $this->desc = $message->getDesc();
     }
     $this->sources = array();
     foreach ($message->getSources() as $source) {
         $this->addSource($source);
     }
     if (!$this->getLocaleString()) {
         $this->localeString = $message->getLocaleString();
     }
 }
开发者ID:clytemnestra,项目名称:JMSTranslationBundle,代码行数:32,代码来源:Message.php

示例5: makeXliffMessage

 /**
  * @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;
 }
开发者ID:ezsystems,项目名称:ezpublish-kernel,代码行数:16,代码来源:CatalogueMapperFileWriter.php

示例6: checkConsistency

 /**
  * @param Message $oldMessage
  * @param Message $newMessage
  */
 private function checkConsistency(Message $oldMessage, Message $newMessage)
 {
     $oldDesc = $oldMessage->getDesc();
     $newDesc = $newMessage->getDesc();
     if (0 < strlen($oldDesc) && 0 < strlen($newDesc) && $oldDesc != $newDesc) {
         throw new \RuntimeException(sprintf("The message '%s' exists with two different descs: '%s' in %s, and '%s' in %s", $oldMessage->getId(), $oldMessage->getDesc(), current($oldMessage->getSources()), $newMessage->getDesc(), current($newMessage->getSources())));
     }
 }
开发者ID:clytemnestra,项目名称:JMSTranslationBundle,代码行数:12,代码来源:MessageCollection.php


注:本文中的JMS\TranslationBundle\Model\Message::getSources方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。