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


PHP PHPCR\DocumentManager類代碼示例

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


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

示例1: createMenuNode

 /**
  * @return a Navigation instance with the specified information
  */
 protected function createMenuNode(DocumentManager $dm, $parent, $name, $label, $content, $uri = null, $route = null)
 {
     if (!$parent instanceof MenuNode && !$parent instanceof Menu) {
         $menuNode = new Menu();
     } else {
         $menuNode = new MenuNode();
     }
     $menuNode->setParent($parent);
     $menuNode->setName($name);
     $dm->persist($menuNode);
     // do persist before binding translation
     if (null !== $content) {
         $menuNode->setContent($content);
     } else {
         if (null !== $uri) {
             $menuNode->setUri($uri);
         } else {
             if (null !== $route) {
                 $menuNode->setRoute($route);
             }
         }
     }
     if (is_array($label)) {
         foreach ($label as $locale => $l) {
             $menuNode->setLabel($l);
             $dm->bindTranslation($menuNode, $locale);
         }
     } else {
         $menuNode->setLabel($label);
     }
     return $menuNode;
 }
開發者ID:reyostallenberg,項目名稱:PiccoloStandard,代碼行數:35,代碼來源:LoadMenuData.php

示例2: __construct

 /**
  * Constructor
  *
  * @param SessionInterface $session
  * @param DocumentManager  $dm
  */
 public function __construct(SessionInterface $session = null, DocumentManager $dm = null)
 {
     if (!$session && $dm) {
         $session = $dm->getPhpcrSession();
     }
     parent::__construct($session);
     $this->dm = $dm;
 }
開發者ID:nikophil,項目名稱:cmf-tests,代碼行數:14,代碼來源:DocumentManagerHelper.php

示例3: validateClassName

 /**
  * @param DocumentManager
  * @param object $document
  * @param string $className
  * @throws \InvalidArgumentException
  */
 public function validateClassName(DocumentManager $dm, $document, $className)
 {
     if (!$document instanceof $className) {
         $class = $dm->getClassMetadata(get_class($document));
         $path = $class->getIdentifierValue($document);
         $msg = "Doctrine metadata mismatch! Requested type '{$className}' type does not match type '" . get_class($document) . "' stored in the metadata at path '{$path}'";
         throw new \InvalidArgumentException($msg);
     }
 }
開發者ID:richardmiller,項目名稱:phpcr-odm,代碼行數:15,代碼來源:DocumentClassMapper.php

示例4: setUp

 public function setUp()
 {
     $this->dm = $this->getMockBuilder('Doctrine\\ODM\\PHPCR\\DocumentManager')->disableOriginalConstructor()->getMock();
     $this->dm->expects($this->once())->method('find')->will($this->returnValue(new \stdClass()));
     $this->defaultModelManager = $this->getMockBuilder('Sonata\\DoctrinePHPCRAdminBundle\\Model\\ModelManager')->disableOriginalConstructor()->getMock();
     $this->translator = $this->getMockBuilder('Symfony\\Component\\Translation\\TranslatorInterface')->disableOriginalConstructor()->getMock();
     $this->assetHelper = $this->getMockBuilder('Symfony\\Component\\Templating\\Helper\\CoreAssetsHelper')->disableOriginalConstructor()->getMock();
     $this->pool = $this->getMockBuilder('Sonata\\AdminBundle\\Admin\\Pool')->disableOriginalConstructor()->getMock();
 }
開發者ID:Aaike,項目名稱:SonataDoctrinePhpcrAdminBundle,代碼行數:9,代碼來源:PhpcrOdmTreeTest.php

示例5: createPage

 /**
  * @return Page instance with the specified information
  */
 protected function createPage(DocumentManager $manager, $parent, $name, $label, $title, $body)
 {
     $page = new Page();
     $page->setPosition($parent, $name);
     $page->setLabel($label);
     $page->setTitle($title);
     $page->setBody($body);
     $manager->persist($page);
     return $page;
 }
開發者ID:nikophil,項目名稱:cmf-tests,代碼行數:13,代碼來源:LoadPageData.php

示例6: createRepository

 /**
  * Create a new repository instance for a document class.
  *
  * @param DocumentManager $documentManager The DocumentManager instance.
  * @param string          $documentName    The name of the document.
  *
  * @return \Doctrine\Common\Persistence\ObjectRepository
  */
 protected function createRepository(DocumentManager $documentManager, $documentName)
 {
     $metadata = $documentManager->getClassMetadata($documentName);
     $repositoryClassName = $metadata->customRepositoryClassName;
     if ($repositoryClassName === null) {
         $configuration = $documentManager->getConfiguration();
         $repositoryClassName = $configuration->getDefaultRepositoryClassName();
     }
     return new $repositoryClassName($documentManager, $metadata);
 }
開發者ID:nikophil,項目名稱:cmf-tests,代碼行數:18,代碼來源:DefaultRepositoryFactory.php

示例7: generate

 /**
  * @param object $document
  * @param ClassMetadata $cm
  * @param DocumentManager $dm
  * @return string
  */
 public function generate($document, ClassMetadata $cm, DocumentManager $dm)
 {
     $repository = $dm->getRepository($cm->name);
     if (!$repository instanceof RepositoryIdInterface) {
         throw new \RuntimeException("ID could not be determined. Make sure the that the Repository '" . get_class($repository) . "' implements RepositoryIdInterface");
     }
     $id = $repository->generateId($document);
     if (!$id) {
         throw new \RuntimeException("ID could not be determined. Repository was unable to generate an ID");
     }
     return $id;
 }
開發者ID:nicam,項目名稱:phpcr-odm,代碼行數:18,代碼來源:RepositoryIdGenerator.php

示例8: mkdir

 /**
  * @param DocumentManager $dm
  * @param $path
  * @param $name
  *
  * @return bool|Directory
  */
 public static function mkdir(DocumentManager $dm, $path, $name)
 {
     $dirname = self::cleanPath($path, $name);
     if ($dm->find(null, $dirname)) {
         return false;
     }
     $dir = new Directory();
     $dir->setName($name);
     $dir->setId($dirname);
     $dm->persist($dir);
     $dm->flush();
     return $dir;
 }
開發者ID:selfclose,項目名稱:dos-cernel-bundle,代碼行數:20,代碼來源:ManagerHelper.php

示例9: createAction

    public function createAction()
    {
        // bind form to page model
        $page = new Page();
        $this->form->bind($this->request, $page);

        if ($this->form->isValid()) {

            try {

                // path for page
                $parent = $this->form->get('parent')->getData();
                $path = $parent . '/' . $page->name;

                // save page
                $this->dm->persist($page, $path);
                $this->dm->flush();

                // redirect with message
                $this->request->getSession()->setFlash('notice', 'Page created!');
                return $this->redirect($this->generateUrl('admin'));

            } catch (HTTPErrorException $e) {

                $path = new PropertyPath('name');
                $this->form->addError(new DataError('Name already in use.'), $path->getIterator());

            }
        }

        return $this->render('SandboxAdminBundle:Admin:create.html.twig', array('form' => $this->form));
    }
開發者ID:regisg27,項目名稱:cmf-sandbox,代碼行數:32,代碼來源:DefaultController.php

示例10: load

 /**
  * Load meta object by provided type and parameters.
  *
  * @MetaLoaderDoc(
  *     description="Article Loader loads articles from Content Repository",
  *     parameters={
  *         contentPath="SINGLE|required content path",
  *         slug="SINGLE|required content slug",
  *         pageName="COLLECTiON|name of Page for required articles"
  *     }
  * )
  *
  * @param string $type         object type
  * @param array  $parameters   parameters needed to load required object type
  * @param int    $responseType response type: single meta (LoaderInterface::SINGLE) or collection of metas (LoaderInterface::COLLECTION)
  *
  * @return Meta|Meta[]|bool false if meta cannot be loaded, a Meta instance otherwise
  */
 public function load($type, $parameters, $responseType = LoaderInterface::SINGLE)
 {
     $article = null;
     if (empty($parameters)) {
         $parameters = [];
     }
     if ($responseType === LoaderInterface::SINGLE) {
         if (array_key_exists('contentPath', $parameters)) {
             $article = $this->dm->find('SWP\\ContentBundle\\Document\\Article', $parameters['contentPath']);
         } elseif (array_key_exists('slug', $parameters)) {
             $article = $this->dm->getRepository('SWP\\ContentBundle\\Document\\Article')->findOneBy(array('slug' => $parameters['slug']));
         }
         if (!is_null($article)) {
             return new Meta($this->rootDir . '/Resources/meta/article.yml', $article);
         }
     } elseif ($responseType === LoaderInterface::COLLECTION) {
         if (array_key_exists('pageName', $parameters)) {
             $page = $this->em->getRepository('SWP\\ContentBundle\\Model\\Page')->getByName($parameters['pageName'])->getOneOrNullResult();
             if ($page) {
                 $articlePages = $this->em->getRepository('SWP\\ContentBundle\\Model\\PageContent')->getForPage($page)->getResult();
                 $articles = [];
                 foreach ($articlePages as $articlePage) {
                     $article = $this->dm->find('SWP\\ContentBundle\\Document\\Article', $articlePage->getContentPath());
                     if (!is_null($article)) {
                         $articles[] = new Meta($this->rootDir . '/Resources/meta/article.yml', $article);
                     }
                 }
                 return $articles;
             }
         }
     }
     return false;
 }
開發者ID:copyfun,項目名稱:web-renderer,代碼行數:51,代碼來源:ArticleLoader.php

示例11: testGetByIdsFilter

 public function testGetByIdsFilter()
 {
     $qb = $this->dm->getRepository('Doctrine\\Bundle\\PHPCRBundle\\Tests\\Resources\\Document\\TestDocument')->createQueryBuilder('e');
     $qb->where()->eq()->field('e.text')->literal('thiswillnotmatch');
     $loader = new PhpcrOdmQueryBuilderLoader($qb, $this->dm);
     $documents = $loader->getEntitiesByIds('id', array('/test/doc'));
     $this->assertCount(0, $documents);
 }
開發者ID:xabbuh,項目名稱:DoctrinePHPCRBundle,代碼行數:8,代碼來源:PhpcrOdmQueryBuilderLoaderTest.php

示例12: testFiltered

 public function testFiltered()
 {
     $qb = $this->dm->getRepository('Doctrine\\Bundle\\PHPCRBundle\\Tests\\Resources\\Document\\TestDocument')->createQueryBuilder('e');
     $qb->where()->eq()->field('e.text')->literal('thiswillnotmatch');
     $formBuilder = $this->createFormBuilder($this->referrer);
     $formBuilder->add('single', $this->legacy ? 'phpcr_document' : 'Doctrine\\Bundle\\PHPCRBundle\\Form\\Type\\DocumentType', array('class' => 'Doctrine\\Bundle\\PHPCRBundle\\Tests\\Resources\\Document\\TestDocument', 'query_builder' => $qb));
     $html = $this->renderForm($formBuilder);
     $this->assertContains('<select id="form_single" name="form[single]"', $html);
     $this->assertNotContains('<option', $html);
 }
開發者ID:xabbuh,項目名稱:DoctrinePHPCRBundle,代碼行數:10,代碼來源:DocumentTypeTest.php

示例13: renderArticleLocale

 /**
  * @param  \ServerGrove\KbBundle\Document\Article $article
  * @param  string                                 $locale
  * @return string
  */
 public function renderArticleLocale(Article $article, $locale)
 {
     try {
         $active = $this->manager->findTranslation(get_class($article), $article->getId(), $locale, false)->getIsActive();
     } catch (\InvalidArgumentException $e) {
         $active = false;
     }
     $this->manager->refresh($article);
     return $this->twig->renderBlock('article_locale', array('active' => $active, 'locale' => $locale, 'locale_name' => Locale::getDisplayLanguage($locale)));
 }
開發者ID:Cohros,項目名稱:KnowledgeBase,代碼行數:15,代碼來源:ArticleExtension.php

示例14: testReferenceOneDifferentTargetDocuments

 public function testReferenceOneDifferentTargetDocuments()
 {
     $ref1 = new RefType1TestObj();
     $ref1->id = '/functional/ref1';
     $ref1->name = 'Ref1';
     $ref2 = new RefType2TestObj();
     $ref2->id = '/functional/ref2';
     $ref2->name = 'Ref2';
     $this->dm->persist($ref1);
     $this->dm->persist($ref2);
     $referer1 = new ReferenceOneObj();
     $referer1->id = '/functional/referer1';
     $referer1->reference = $ref1;
     $this->dm->persist($referer1);
     $referer2 = new ReferenceOneObj();
     $referer2->id = '/functional/referer2';
     $referer2->reference = $ref2;
     $this->dm->persist($referer2);
     $this->dm->flush();
     $this->dm->clear();
     $referer = $this->dm->find('Doctrine\\Tests\\ODM\\PHPCR\\Functional\\ReferenceOneObj', '/functional/referer1');
     $this->assertTrue($referer->reference instanceof RefType1TestObj);
     $referer = $this->dm->find('Doctrine\\Tests\\ODM\\PHPCR\\Functional\\ReferenceOneObj', '/functional/referer2');
     $this->assertTrue($referer->reference instanceof RefType2TestObj);
 }
開發者ID:steffenbrem,項目名稱:phpcr-odm,代碼行數:25,代碼來源:TargetDocumentTest.php

示例15: getContentId

 /**
  * {@inheritDoc}
  */
 public function getContentId($content)
 {
     if (!is_object($content)) {
         return null;
     }
     try {
         return $this->documentManager->getUnitOfWork()->getDocumentId($content);
     } catch (\Exception $e) {
         return null;
     }
 }
開發者ID:symfony-cmf,項目名稱:routing-extra-bundle,代碼行數:14,代碼來源:ContentRepository.php


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