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


PHP DocumentManager::removeTranslation方法代码示例

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


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

示例1: testRemoveTranslation

 public function testRemoveTranslation()
 {
     $this->dm->persist($this->doc);
     $this->dm->bindTranslation($this->doc, 'en');
     $this->dm->flush();
     $this->assertEquals(array('en'), $this->dm->getLocalesFor($this->doc));
     $this->doc->topic = 'Un sujet intéressant';
     $this->dm->bindTranslation($this->doc, 'fr');
     $this->dm->flush();
     $this->dm->clear();
     $this->doc = $this->dm->findTranslation(null, $this->doc->id, 'fr');
     $this->assertEquals(array('en', 'fr'), $this->dm->getLocalesFor($this->doc));
     $this->dm->removeTranslation($this->doc, 'en');
     $this->assertEquals(array('fr'), $this->dm->getLocalesFor($this->doc));
     $this->dm->clear();
     $this->doc = $this->dm->findTranslation(null, $this->doc->id, 'fr');
     $this->assertEquals(array('en', 'fr'), $this->dm->getLocalesFor($this->doc));
     $this->dm->removeTranslation($this->doc, 'en');
     $this->dm->flush();
     $this->assertEquals(array('fr'), $this->dm->getLocalesFor($this->doc));
     $this->dm->clear();
     $this->doc = $this->dm->find(null, $this->doc->id);
     $this->assertEquals(array('fr'), $this->dm->getLocalesFor($this->doc));
     try {
         $this->dm->removeTranslation($this->doc, 'fr');
         $this->fail('Last translation should not be removable');
     } catch (PHPCRException $e) {
     }
 }
开发者ID:steffenbrem,项目名称:phpcr-odm,代码行数:29,代码来源:DocumentManagerTest.php

示例2: testComputingBetweenEventsWithTranslation

 public function testComputingBetweenEventsWithTranslation()
 {
     $this->dm->getEventManager()->addEventListener(array(Event::preCreateTranslation, Event::postLoadTranslation, Event::preRemoveTranslation, Event::postRemoveTranslation), $this->listener);
     $this->dm->setLocaleChooserStrategy(new LocaleChooser($this->localePrefs, 'en'));
     // Create initial user
     $user = new \Doctrine\Tests\Models\CMS\CmsUserTranslatable();
     $user->name = 'mdekrijger';
     $user->username = 'mdekrijger';
     $user->status = 'active';
     $this->dm->persist($user);
     $this->dm->flush();
     $this->dm->clear();
     $user = $this->dm->findTranslation('Doctrine\\Tests\\Models\\CMS\\CmsUserTranslatable', $user->id, 'en');
     // username should be changed after loading the translation
     $this->assertEquals('loadTranslation', $user->username);
     // name had been changed pre binding translation
     $this->assertEquals('preCreateTranslation', $user->name);
     $this->dm->name = 'neuer Name';
     $this->dm->bindTranslation($user, 'de');
     $this->dm->flush();
     $this->dm->clear();
     $user = $this->dm->findTranslation('Doctrine\\Tests\\Models\\CMS\\CmsUserTranslatable', $user->id, 'en');
     $this->dm->removeTranslation($user, 'en');
     $this->assertEquals('preRemoveTranslation', $user->name);
     $this->dm->flush();
     $this->dm->clear();
     $this->assertEquals('postRemoveTranslation', $user->username);
 }
开发者ID:nikophil,项目名称:cmf-tests,代码行数:28,代码来源:EventComputingTest.php

示例3: testTriggerTranslationEvents

 public function testTriggerTranslationEvents()
 {
     $this->dm->getEventManager()->addEventListener(array(Event::preCreateTranslation, Event::postLoadTranslation, Event::preRemoveTranslation, Event::postRemoveTranslation), $this->listener);
     $this->dm->setLocaleChooserStrategy(new LocaleChooser($this->localePrefs, 'en'));
     $page = new CmsPageTranslatable();
     $page->title = "my-page";
     $page->content = "long story";
     $this->dm->persist($page);
     $this->assertFalse($this->listener->preCreateTranslation);
     $this->assertFalse($this->listener->postLoadTranslation);
     $this->assertFalse($this->listener->postRemoveTranslation);
     $this->assertFalse($this->listener->postRemoveTranslation);
     $this->dm->bindTranslation($page, 'en');
     $this->assertTrue($this->listener->preCreateTranslation);
     $this->assertFalse($this->listener->postLoadTranslation);
     $this->assertFalse($this->listener->postRemoveTranslation);
     $this->dm->flush();
     $this->dm->clear();
     $page = $this->dm->findTranslation('Doctrine\\Tests\\Models\\CMS\\CmsPageTranslatable', $page->id, 'en');
     $this->assertTrue($this->listener->postLoadTranslation);
     $page->title = 'neuer Titel';
     $this->dm->bindTranslation($page, 'de');
     $this->dm->flush();
     $this->dm->removeTranslation($page, 'en');
     $this->assertFalse($this->listener->postRemoveTranslation);
     $this->assertTrue($this->listener->preRemoveTranslation);
     $this->dm->flush();
     $this->assertTrue($this->listener->postRemoveTranslation);
 }
开发者ID:nikophil,项目名称:cmf-tests,代码行数:29,代码来源:EventManagerTest.php

示例4: testFindTranslationPropagateLocale

 public function testFindTranslationPropagateLocale()
 {
     $child = new Article();
     $child->id = '/functional/thename/child';
     $child->author = 'John Doe';
     $child->text = 'Lorem ipsum...';
     $child->topic = 'Interesting Topic';
     $this->dm->persist($child);
     $this->dm->bindTranslation($child, 'en');
     $child->topic = 'Sujet interessant';
     $this->dm->bindTranslation($child, 'fr');
     $related = new Article();
     $related->id = '/functional/thename/related';
     $related->author = 'John Doe';
     $related->text = 'Lorem ipsum...';
     $related->topic = 'Interesting Topic';
     $this->dm->persist($related);
     $this->dm->bindTranslation($related, 'en');
     $related->topic = 'Sujet interessant';
     $this->dm->bindTranslation($related, 'fr');
     $child->relatedArticles[] = $related;
     $this->dm->flush();
     $this->dm->clear();
     // we find document "thename" with a specific locale. the child proxy
     // object must be the same locale
     $doc = $this->dm->findTranslation($this->type, '/functional/thename', 'fr');
     $this->assertInstanceOf('Doctrine\\Common\\Proxy\\Proxy', $doc->child);
     $this->assertEquals('fr', $doc->locale);
     $this->assertEquals('fr', $doc->child->locale);
     $this->assertEquals('fr', $doc->child->relatedArticles[0]->locale);
     $this->assertEquals('Sujet interessant', $doc->child->topic);
     $this->dm->clear();
     $doc = $this->dm->findTranslation($this->type, '/functional/thename', 'en');
     $this->assertInstanceOf('Doctrine\\Common\\Proxy\\Proxy', $doc->child);
     $this->assertEquals('en', $doc->locale);
     $this->assertEquals('en', $doc->child->locale);
     $this->assertEquals('Interesting Topic', $doc->child->topic);
     $this->dm->removeTranslation($doc->child->relatedArticles[0], 'en');
     $this->dm->removeTranslation($doc, 'en');
     $this->dm->flush();
     $this->dm->clear();
     // if we remove the english translation from the doc and the related, loading the child
     // should give the doc and the related in french
     $child = $this->dm->findTranslation($this->type, '/functional/thename/child', 'en');
     $this->assertInstanceOf('Doctrine\\Common\\Proxy\\Proxy', $child->parent);
     $this->assertEquals('en', $child->locale);
     $this->assertEquals('fr', $child->parent->locale);
     $this->assertEquals('french', $child->parent->topic);
     $this->assertEquals('fr', $child->relatedArticles[0]->locale);
 }
开发者ID:steffenbrem,项目名称:phpcr-odm,代码行数:50,代码来源:TranslationHierarchyTest.php


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