Ejemplo n.º 1
0
 public function setUp()
 {
     $this->dm = $this->createDocumentManager(array(__DIR__));
     $repository = $this->dm->getPhpcrSession()->getRepository();
     if (!$repository->getDescriptor('node.type.management.orderable.child.nodes.supported')) {
         $this->markTestSkipped('PHPCR repository doesn\'t support orderable child nodes');
     }
     $this->node = $this->resetFunctionalNode($this->dm);
     $parent = $this->dm->find(null, $this->node->getPath());
     $node1 = new Generic();
     $node1->setParentDocument($parent);
     $node1->setNodename('source');
     $this->dm->persist($node1);
     $this->childrenNames = array('first', 'second', 'third', 'fourth');
     foreach ($this->childrenNames as $childName) {
         $child = new Generic();
         $child->setNodename($childName);
         $child->setParentDocument($node1);
         $this->dm->persist($child);
     }
     $node2 = new Generic();
     $node2->setNodename('target');
     $node2->setParentDocument($parent);
     $this->dm->persist($node2);
     $this->dm->flush();
     $this->dm->clear();
 }
 public function setUp()
 {
     $this->dm = $this->db('PHPCR')->getOm();
     $this->db('PHPCR')->purgeRepository(true);
     $this->db('PHPCR')->createTestNode();
     $rootDocument = $this->dm->find(null, '/test');
     $document = new Generic();
     $document->setNodeName('foo');
     $document->setParentDocument($rootDocument);
     $this->dm->persist($document);
     $document = new Generic();
     $document->setNodeName('bar');
     $document->setParentDocument($rootDocument);
     $this->dm->persist($document);
     $this->dm->flush();
     $this->repositoryRegistry = $this->container->get('cmf_resource.registry');
 }
Ejemplo n.º 3
0
 public function load(ObjectManager $manager)
 {
     NodeHelper::createPath($manager->getPhpcrSession(), '/test');
     $root = $manager->find(null, '/test');
     $parent = new Generic();
     $parent->setParentDocument($root);
     $parent->setNodename('routing');
     $manager->persist($parent);
     $route = new Route();
     $route->setParentDocument($parent);
     $route->setName('route-1');
     $manager->persist($route);
     $redirectRoute = new RedirectRoute();
     $redirectRoute->setParentDocument($parent);
     $redirectRoute->setName('redirect-route-1');
     $manager->persist($redirectRoute);
     $manager->flush();
 }
Ejemplo n.º 4
0
 private function buildRoutes()
 {
     $root = $this->getDm()->find(null, self::ROUTE_ROOT);
     $route = new Route();
     $route->setPosition($root, 'testroute');
     $route->setDefault('_format', 'html');
     $this->getDm()->persist($route);
     // smuggle a non-route thing into the repository
     $noroute = new Generic();
     $noroute->setParentDocument($route);
     $noroute->setNodename('noroute');
     $this->getDm()->persist($noroute);
     $childroute = new Route();
     $childroute->setPosition($noroute, 'child');
     $childroute->setDefault('_format', 'json');
     $this->getDm()->persist($childroute);
     $this->getDm()->flush();
     $this->getDm()->clear();
 }
Ejemplo n.º 5
0
 public function load(ObjectManager $manager)
 {
     NodeHelper::createPath($manager->getPhpcrSession(), '/test');
     $root = $manager->find(null, '/test');
     $parent = new Generic();
     $parent->setParentDocument($root);
     $parent->setNodename('routing');
     $manager->persist($parent);
     $routeCollection = new Route();
     $routeCollection->setParentDocument($parent);
     $routeCollection->setMethods(array('POST', 'GET', 'PUT'));
     # Todo check if we can add a type and set defaults prePersist?
     $routeCollection->setName('collection');
     $manager->persist($routeCollection);
     $route = new Route();
     $route->setParentDocument($routeCollection);
     $route->setName('get-1');
     $route->setMethods(array(Request::METHOD_GET));
     $manager->persist($route);
     $route = new Route();
     $route->setParentDocument($routeCollection);
     $route->setName('post-1');
     $route->setMethods(array(Request::METHOD_POST));
     $manager->persist($route);
     $route = new Route();
     $route->setParentDocument($routeCollection);
     $route->setName('put-1');
     $route->setMethods(array(Request::METHOD_PUT));
     $manager->persist($route);
     $route = new Route();
     $route->setParentDocument($routeCollection);
     $route->setName('delete-1');
     $route->setMethods(array(Request::METHOD_DELETE));
     $manager->persist($route);
     $route = new Route();
     $route->setParentDocument($routeCollection);
     $route->setName('patch-1');
     $route->setMethods(array(Request::METHOD_PATCH));
     $manager->persist($route);
     $manager->flush();
 }
Ejemplo n.º 6
0
 public function load(ObjectManager $manager)
 {
     $root = $manager->find(null, '/');
     $test = new Generic();
     $test->setNodename('test');
     $test->setParentDocument($root);
     $manager->persist($test);
     $content = new Generic();
     $content->setNodename('content');
     $content->setParentDocument($test);
     $manager->persist($content);
     $aContent = new Content();
     $aContent->id = '/test/content/a';
     $manager->persist($aContent);
     $bContent = new Content();
     $bContent->id = '/test/content/b';
     $manager->persist($bContent);
     $cms = new Generic();
     $cms->setNodename('cms');
     $cms->setParentDocument($test);
     $manager->persist($cms);
     $routes = new Generic();
     $routes->setNodename('routes');
     $routes->setParentDocument($cms);
     $manager->persist($routes);
     $aRoute = new Route();
     $aRoute->setName('a');
     $aRoute->setParentDocument($routes);
     $aRoute->setContent($aContent);
     $manager->persist($aRoute);
     $bRoute = new Route();
     $bRoute->setName('b');
     $bRoute->setParentDocument($routes);
     $bRoute->setContent($bContent);
     $manager->persist($bRoute);
     $manager->flush();
 }
Ejemplo n.º 7
0
 /**
  * @param DocumentManager $manager
  */
 public function load(ObjectManager $manager)
 {
     $base = new Generic();
     $base->setNodename('test');
     $base->setParentDocument($manager->find(null, '/'));
     $doc = new TestDocument();
     $doc->parent = $base;
     $doc->nodename = 'doc';
     $doc->bool = true;
     $doc->date = new \DateTime('2014-01-14');
     $doc->integer = 42;
     $doc->long = 24;
     $doc->number = 3.14;
     $doc->text = 'text content';
     $manager->persist($doc);
     $doc = new TestDocument();
     $doc->parent = $base;
     $doc->nodename = 'doc2';
     $doc->bool = true;
     $doc->date = new \DateTime('2014-01-14');
     $doc->integer = 42;
     $doc->long = 24;
     $doc->number = 3.14;
     $doc->text = 'text content';
     $manager->persist($doc);
     $ref = new ReferrerDocument();
     $ref->id = '/test/ref';
     $ref->addDocument($doc);
     $manager->persist($ref);
     $manager->flush();
     $node = $manager->getPhpcrSession()->getNode('/test/doc');
     $node->addNode('child');
     $node->addNode('second');
     $manager->getPhpcrSession()->save();
     $manager->clear();
 }
Ejemplo n.º 8
0
 public function load(ObjectManager $manager)
 {
     NodeHelper::createPath($manager->getPhpcrSession(), '/test');
     $root = $manager->find(null, '/test');
     $parent = new Generic();
     $parent->setParentDocument($root);
     $parent->setNodename('blocks');
     $manager->persist($parent);
     //Simple
     $block = new SimpleBlock();
     $block->setParentDocument($parent);
     $block->setName('block-1');
     $block->setTitle('block-1-title');
     $block->setBody('block-1-body');
     $manager->persist($block);
     $block = new SimpleBlock();
     $block->setParentDocument($parent);
     $block->setName('block-2');
     $block->setTitle('block-2-title');
     $block->setBody('block-2-body');
     $block->setPublishable(false);
     $manager->persist($block);
     //Action
     $actionBlockOne = new ActionBlock();
     $actionBlockOne->setParentDocument($parent);
     $actionBlockOne->setName('action-block-1');
     $actionBlockOne->setActionName('cmf_block_test.test_controller:dummyAction');
     $actionBlockOne->setPublishable(true);
     $manager->persist($actionBlockOne);
     $actionBlockTwo = new ActionBlock();
     $actionBlockTwo->setParentDocument($parent);
     $actionBlockTwo->setName('action-block-2');
     $actionBlockTwo->setActionName('FooBundle:Bar:actionTwo');
     $actionBlockTwo->setPublishable(false);
     $manager->persist($actionBlockTwo);
     //Container
     $childBlockOne = new SimpleBlock();
     $childBlockOne->setName('block-child-1');
     $childBlockOne->setTitle('block-child-1-title');
     $childBlockOne->setBody('block-child-1-body');
     $containerBlock = new ContainerBlock();
     $containerBlock->setParentDocument($parent);
     $containerBlock->setName('container-block-1');
     $containerBlock->addChild($childBlockOne);
     $manager->persist($containerBlock);
     $block = new ContainerBlock();
     $block->setParentDocument($parent);
     $block->setName('container-block-2');
     $block->setPublishable(false);
     $manager->persist($block);
     //Reference
     $block = new ReferenceBlock();
     $block->setParentDocument($parent);
     $block->setName('reference-block-1');
     $block->setReferencedBlock($actionBlockOne);
     $manager->persist($block);
     $block = new ReferenceBlock();
     $block->setParentDocument($parent);
     $block->setName('reference-block-2');
     $block->setReferencedBlock($actionBlockTwo);
     $block->setPublishable(false);
     $manager->persist($block);
     // Menu Nodes
     NodeHelper::createPath($manager->getPhpcrSession(), '/test/menus');
     $menuRoot = $manager->find(null, '/test/menus');
     $menu = new Menu();
     $menu->setName('test-menu');
     $menu->setLabel('Test Menu');
     $menu->setParentDocument($menuRoot);
     $manager->persist($menu);
     $menuNodeOne = new MenuNode();
     $menuNodeOne->setName('menu-node-1');
     $menuNodeOne->setLabel('menu-node-1');
     $menuNodeOne->setParentDocument($menu);
     $manager->persist($menuNodeOne);
     $menuNodeTwo = new MenuNode();
     $menuNodeTwo->setName('menu-node-2');
     $menuNodeTwo->setLabel('menu-node-2');
     $menuNodeTwo->setParentDocument($menu);
     $manager->persist($menuNodeTwo);
     //Menu
     $block = new MenuBlock();
     $block->setParentDocument($parent);
     $block->setName('menu-block-1');
     $block->setMenuNode($menuNodeOne);
     $manager->persist($block);
     $block = new MenuBlock();
     $block->setParentDocument($parent);
     $block->setName('menu-block-2');
     $block->setMenuNode($menuNodeTwo);
     $block->setPublishable(false);
     $manager->persist($block);
     //String
     $block = new StringBlock();
     $block->setParentDocument($parent);
     $block->setName('string-block-1');
     $block->setBody('string-block-1-body');
     $manager->persist($block);
     $block = new StringBlock();
     $block->setParentDocument($parent);
     $block->setName('string-block-2');
     $block->setBody('string-block-2-body');
     $block->setPublishable(false);
     $manager->persist($block);
     $manager->flush();
 }
 /**
  * {@inheritDoc}
  */
 public function setParentDocument($parent)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setParentDocument', array($parent));
     return parent::setParentDocument($parent);
 }
 public function newAction(Request $request)
 {
     $dm = $this->get('doctrine_phpcr')->getManager('default');
     $contentRoot = $dm->find(null, '/test/content');
     if (!$contentRoot) {
         $root = $dm->find(null, '/test');
         $contentRoot = new Generic();
         $contentRoot->setNodename('content');
         $contentRoot->setParentDocument($root);
         $dm->persist($contentRoot);
     }
     $contentObject = new Content();
     $contentObject->setParent($contentRoot);
     $form = $this->getContentForm($contentObject);
     if ($request->isMethod('POST')) {
         $form->bind($request);
         if ($form->isValid()) {
             // persist
             $dm = $this->get('doctrine_phpcr')->getManager('default');
             $dm->persist($contentObject);
             $dm->flush();
         }
     }
     return $this->redirect($this->generateUrl('phpcr_image_test'));
 }
 /**
  * {@inheritdoc}
  */
 public function createAutoRoute(UriContext $uriContext, $contentDocument, $autoRouteTag)
 {
     $basePath = $this->baseRoutePath;
     $document = $parentDocument = $this->dm->find(null, $basePath);
     if (null === $parentDocument) {
         throw new \RuntimeException(sprintf('The "route_basepath" configuration points to a non-existant path "%s".', $basePath));
     }
     $segments = preg_split('#/#', $uriContext->getUri(), null, PREG_SPLIT_NO_EMPTY);
     $headName = array_pop($segments);
     foreach ($segments as $segment) {
         $basePath .= '/' . $segment;
         $document = $this->dm->find(null, $basePath);
         if (null === $document) {
             $document = new Generic();
             $document->setParentDocument($parentDocument);
             $document->setNodeName($segment);
             $this->dm->persist($document);
         }
         $parentDocument = $document;
     }
     $path = $basePath . '/' . $headName;
     $existingDocument = $this->dm->find(null, $path);
     if ($existingDocument) {
         if ($existingDocument instanceof Generic) {
             return $this->migrateGenericToAutoRoute($existingDocument, $contentDocument, $autoRouteTag, AutoRouteInterface::TYPE_PRIMARY);
         }
         throw new \RuntimeException(sprintf('Encountered existing PHPCR-ODM document at path "%s" of class "%s", the route tree should ' . 'contain only instances of AutoRouteInterface.', $path, get_class($existingDocument)));
     }
     $headRoute = new $this->autoRouteFqcn();
     $headRoute->setContent($contentDocument);
     $headRoute->setName($headName);
     $headRoute->setParentDocument($document);
     $headRoute->setAutoRouteTag($autoRouteTag);
     $headRoute->setType(AutoRouteInterface::TYPE_PRIMARY);
     foreach ($uriContext->getDefaults() as $key => $value) {
         $headRoute->setDefault($key, $value);
     }
     return $headRoute;
 }