当前位置: 首页>>代码示例>>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;未经允许,请勿转载。