本文整理汇总了PHP中JMS\TranslationBundle\Model\Message::setNew方法的典型用法代码示例。如果您正苦于以下问题:PHP Message::setNew方法的具体用法?PHP Message::setNew怎么用?PHP Message::setNew使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JMS\TranslationBundle\Model\Message
的用法示例。
在下文中一共展示了Message::setNew方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetLocaleString
public function testGetLocaleString()
{
$message = new Message('foo');
$message->setDesc('bar');
$message->setNew(true);
$existingMessage = new Message('foo');
$existingMessage->setDesc('bar');
$existingMessage->setNew(false);
$this->assertEquals($message->getDesc(), $message->getLocaleString());
$this->assertEquals('', $existingMessage->getLocaleString());
}
示例2: testMergeExisting
public function testMergeExisting()
{
$scannedMessage = new XliffMessage('foo');
$scannedMessage->setDesc('foo');
$existingMessage = new XliffMessage('foo');
$existingMessage->setLocaleString('bar');
$existingMessage->addSource(new FileSource('bar'));
$existingMessage->setApproved(true);
$existingMessage->setState(XliffMessage::STATE_TRANSLATED);
$existingMessage2 = new Message('foo');
$existingMessage2->setLocaleString('bar');
$existingMessage2->setNew(false);
$existingMessage2->addSource(new FileSource('bar'));
$scannedMessage1 = clone $scannedMessage;
$existingMessage1 = clone $existingMessage;
$scannedMessage1->mergeExisting($existingMessage1);
$this->assertEquals('foo', $scannedMessage1->getDesc());
$this->assertEquals('bar', $scannedMessage1->getLocaleString());
$this->assertFalse($scannedMessage1->isNew());
$this->assertEquals(array(), $scannedMessage1->getSources());
$this->assertFalse($scannedMessage1->isApproved());
$this->assertEquals(XliffMessage::STATE_NONE, $scannedMessage1->getState());
$scannedMessage2 = clone $scannedMessage;
$scannedMessage2->setApproved(true);
$scannedMessage2->setState(XliffMessage::STATE_TRANSLATED);
$existingMessage2 = clone $existingMessage;
$existingMessage2->setDesc('bar');
$existingMessage2->setApproved(false);
$existingMessage2->setState(XliffMessage::STATE_NONE);
$scannedMessage2->mergeExisting($existingMessage2);
$this->assertEquals('foo', $scannedMessage2->getDesc());
$this->assertTrue($scannedMessage2->isApproved());
$this->assertEquals(XliffMessage::STATE_TRANSLATED, $scannedMessage2->getState());
$scannedMessage3 = clone $scannedMessage;
$existingMessage3 = clone $existingMessage1;
$scannedMessage3->mergeExisting($existingMessage3);
$this->assertEquals('foo', $scannedMessage3->getDesc());
$this->assertEquals('bar', $scannedMessage3->getLocaleString());
$this->assertFalse($scannedMessage3->isNew());
$this->assertEquals(array(), $scannedMessage3->getSources());
$this->assertFalse($scannedMessage3->isApproved());
$this->assertEquals(XliffMessage::STATE_NONE, $scannedMessage3->getState());
$scannedMessage4 = clone $scannedMessage;
$scannedMessage4->setApproved(true);
$scannedMessage4->setState(XliffMessage::STATE_TRANSLATED);
$existingMessage4 = clone $existingMessage1;
$existingMessage4->setDesc('bar');
$scannedMessage4->mergeExisting($existingMessage4);
$this->assertEquals('foo', $scannedMessage4->getDesc());
$this->assertTrue($scannedMessage4->isApproved());
$this->assertEquals(XliffMessage::STATE_TRANSLATED, $scannedMessage4->getState());
}
示例3: setNew
public function setNew($bool)
{
if ($bool) {
$this->state = static::STATE_NEW;
} else {
if ($this->isNew()) {
// $bool==false => leave state untouched unless it is set to STATE_NEW
$this->state = null;
}
}
return parent::setNew($bool);
}
示例4: 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());
}