當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DocumentManager::getTranslationStrategy方法代碼示例

本文整理匯總了PHP中Doctrine\ODM\PHPCR\DocumentManager::getTranslationStrategy方法的典型用法代碼示例。如果您正苦於以下問題:PHP DocumentManager::getTranslationStrategy方法的具體用法?PHP DocumentManager::getTranslationStrategy怎麽用?PHP DocumentManager::getTranslationStrategy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Doctrine\ODM\PHPCR\DocumentManager的用法示例。


在下文中一共展示了DocumentManager::getTranslationStrategy方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: doRemoveAllTranslations

 /**
  * @param object        $document
  * @param ClassMetadata $metadata
  * @throws PHPCRException
  */
 private function doRemoveAllTranslations($document, ClassMetadata $metadata)
 {
     if (!$this->isDocumentTranslatable($metadata)) {
         return;
     }
     $node = $this->session->getNode($this->getDocumentId($document));
     $strategy = $this->dm->getTranslationStrategy($metadata->translator);
     $strategy->removeAllTranslations($document, $node, $metadata);
 }
開發者ID:nikophil,項目名稱:cmf-tests,代碼行數:14,代碼來源:UnitOfWork.php

示例2: testQueryBuilder

 public function testQueryBuilder()
 {
     $strategy = $this->dm->getTranslationStrategy('child');
     $this->dm->setLocaleChooserStrategy(new LocaleChooser(array('en' => array('fr'), 'fr' => array('en')), 'en'));
     // First save some translations
     $data = array();
     $data['topic'] = 'Some interesting subject';
     $data['text'] = 'Lorem ipsum...';
     $data['settings'] = array('is-active' => 'true', 'url' => 'great-article-in-english.html');
     $node = $this->getTestNode();
     $node->setProperty('author', 'John Doe');
     $node->setProperty('phpcr:class', 'Doctrine\\Tests\\Models\\Translation\\ChildTranslationArticle');
     $strategy->saveTranslation($data, $node, $this->metadata, 'en');
     // Save translation in another language
     $data['topic'] = 'Un sujet intéressant';
     $data['settings'] = array('is-active' => 'true', 'url' => 'super-article-en-francais.html');
     $strategy->saveTranslation($data, $node, $this->metadata, 'fr');
     $this->dm->flush();
     $qb = $this->dm->createQueryBuilder();
     $qb->from()->document('Doctrine\\Tests\\Models\\Translation\\ChildTranslationArticle', 'a');
     $qb->where()->eq()->field('a.topic')->literal('Not Exist')->end();
     $res = $qb->getQuery()->execute();
     $this->assertCount(0, $res);
     $qb = $this->dm->createQueryBuilder();
     $qb->from()->document('Doctrine\\Tests\\Models\\Translation\\ChildTranslationArticle', 'a');
     $qb->where()->eq()->field('a.topic')->literal('Un sujet intéressant')->end();
     $res = $qb->getQuery()->execute();
     $this->assertCount(0, $res);
     $qb = $this->dm->createQueryBuilder();
     $qb->setLocale(false);
     $qb->from()->document('Doctrine\\Tests\\Models\\Translation\\ChildTranslationArticle', 'a');
     $qb->where()->eq()->field('a.topic')->literal('Un sujet intéressant')->end();
     $res = $qb->getQuery()->execute();
     $this->assertCount(0, $res);
     $qb = $this->dm->createQueryBuilder();
     $qb->from()->document('Doctrine\\Tests\\Models\\Translation\\ChildTranslationArticle', 'a');
     $qb->where()->eq()->field('a.topic')->literal('Some interesting subject')->end();
     $res = $qb->getQuery()->execute();
     $this->assertCount(1, $res);
     $qb = $this->dm->createQueryBuilder();
     $qb->setLocale('fr');
     $qb->from()->document('Doctrine\\Tests\\Models\\Translation\\ChildTranslationArticle', 'a');
     $qb->where()->eq()->field('a.topic')->literal('Un sujet intéressant')->end();
     $res = $qb->getQuery()->execute();
     $this->assertCount(1, $res);
 }
開發者ID:steffenbrem,項目名稱:phpcr-odm,代碼行數:46,代碼來源:ChildTranslationStrategyTest.php

示例3: walkSourceDocument

 protected function walkSourceDocument(SourceDocument $node)
 {
     $alias = $node->getAlias();
     $documentFqn = $node->getDocumentFqn();
     // make sure we add the phpcr:{class,classparents} constraints
     // From is dispatched first, so these will always be the primary
     // constraints.
     $this->sourceDocumentNodes[$alias] = $node;
     // cache the metadata for this document
     /** @var $meta ClassMetadata */
     $meta = $this->mdf->getMetadataFor($documentFqn);
     if (null === $meta->getName()) {
         throw new \RuntimeException(sprintf('%s is not a mapped document', $documentFqn));
     }
     $this->aliasMetadata[$alias] = $meta;
     if ($this->locale && $meta->translator) {
         $this->translator[$alias] = $this->dm->getTranslationStrategy($meta->translator);
     }
     $nodeType = $meta->getNodeType();
     // get the PHPCR Alias
     $alias = $this->qomf->selector($alias, $nodeType);
     return $alias;
 }
開發者ID:nikophil,項目名稱:cmf-tests,代碼行數:23,代碼來源:BuilderConverterPhpcr.php


注:本文中的Doctrine\ODM\PHPCR\DocumentManager::getTranslationStrategy方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。