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->setParent($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_file_test'));
 }
Ejemplo n.º 2
0
    public function load(ObjectManager $manager)
    {
        NodeHelper::createPath($manager->getPhpcrSession(), '/test');
        $root = $manager->find(null, '/test');

        $contentRoot = new Generic;
        $contentRoot->setNodename('contents');
        $contentRoot->setParent($root);
        $manager->persist($contentRoot);

        $content = new StaticContent;
        $content->setName('content-1');
        $content->setTitle('Content 1');
        $content->setBody('Content 1');
        $content->setParentDocument($contentRoot);
        $manager->persist($content);

        $content = new StaticContent;
        $content->setName('content-2');
        $content->setTitle('Content 2');
        $content->setBody('Content 2');
        $content->setParentDocument($contentRoot);
        $manager->persist($content);

        $manager->flush();
    }
Ejemplo n.º 3
0
 public function load(ObjectManager $manager)
 {
     NodeHelper::createPath($manager->getPhpcrSession(), '/test');
     $testDataDir = realpath(__DIR__ . '/../../app/Resources/data');
     $root = $manager->find(null, '/test');
     // media root
     $mediaRoot = new Generic();
     $mediaRoot->setNodename('media');
     $mediaRoot->setParent($root);
     $manager->persist($mediaRoot);
     // content root
     $contentRoot = new Generic();
     $contentRoot->setNodename('content');
     $contentRoot->setParent($root);
     $manager->persist($contentRoot);
     // File
     $file = new File();
     $file->setParent($mediaRoot);
     $file->setName('file-1.txt');
     $file->setContentFromString('Test file 1.');
     $file->setContentType('text/plain');
     $manager->persist($file);
     // Image
     $image = new Image();
     $image->setParent($mediaRoot);
     $image->setName('cmf-logo.png');
     $image->setFileContentFromFilesystem($testDataDir . '/cmf-logo.png');
     $manager->persist($image);
     $image2 = new Image();
     $image2->setParent($contentRoot);
     $image2->setName('cmf-logo-2.png');
     $image2->setFileContentFromFilesystem($testDataDir . '/cmf-logo.png');
     $manager->persist($image2);
     // Content with image
     $content = new Content();
     $content->setParent($contentRoot);
     $content->setName('content-with-image');
     $content->setTitle('Content document with image embedded');
     $contentImage = new Image();
     $contentImage->setFileContentFromFilesystem($testDataDir . '/cmf-logo.png');
     $content->setFile($contentImage);
     $manager->persist($content);
     // Content with file
     $content2 = new Content();
     $content2->setParent($contentRoot);
     $content2->setName('content-with-file');
     $content2->setTitle('Content document with file attached');
     $contentFile = new File();
     $contentFile->setFileContentFromFilesystem($testDataDir . '/testfile.txt');
     $content2->setFile($contentFile);
     $manager->persist($content2);
     $manager->flush();
 }
Ejemplo n.º 4
0
 public function load(ObjectManager $manager)
 {
     NodeHelper::createPath($manager->getPhpcrSession(), '/test');
     $root = $manager->find(null, '/test');
     $parent = new Generic();
     $parent->setParent($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.º 5
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->setParent($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();
 }
 public function testGetRouteCollectionForRequest()
 {
     $route = new Route();
     $root = self::$dm->find(null, self::ROUTE_ROOT);
     $route->setPosition($root, 'testroute');
     self::$dm->persist($route);
     // smuggle a non-route thing into the repository
     $noroute = new Generic();
     $noroute->setParent($route);
     $noroute->setNodename('noroute');
     self::$dm->persist($noroute);
     $childroute = new Route();
     $childroute->setPosition($noroute, 'child');
     self::$dm->persist($childroute);
     self::$dm->flush();
     self::$dm->clear();
     $routes = self::$repository->getRouteCollectionForRequest(Request::create('/testroute/noroute/child'));
     $this->assertCount(3, $routes);
     foreach ($routes as $route) {
         $this->assertInstanceOf('Symfony\\Cmf\\Component\\Routing\\RouteObjectInterface', $route);
     }
 }
Ejemplo n.º 7
0
 public function load(ObjectManager $manager)
 {
     $root = $manager->find(null, '/');
     $test = new Generic();
     $test->setNodename('test');
     $test->setParent($root);
     $manager->persist($test);
     $content = new Generic();
     $content->setNodename('content');
     $content->setParent($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->setParent($test);
     $manager->persist($cms);
     $routes = new Generic();
     $routes->setNodename('routes');
     $routes->setParent($cms);
     $manager->persist($routes);
     $aRoute = new Route();
     $aRoute->setName('a');
     $aRoute->setParent($routes);
     $aRoute->setContent($aContent);
     $manager->persist($aRoute);
     $bRoute = new Route();
     $bRoute->setName('b');
     $bRoute->setParent($routes);
     $bRoute->setContent($bContent);
     $manager->persist($bRoute);
     $manager->flush();
 }
Ejemplo n.º 8
0
 public function load(ObjectManager $manager)
 {
     NodeHelper::createPath($manager->getPhpcrSession(), '/test');
     $root = $manager->find(null, '/test');
     $parent = new Generic();
     $parent->setParent($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 setParent($parent)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'setParent', array($parent));
     return parent::setParent($parent);
 }
Ejemplo n.º 10
0
 /**
  * {@inheritdoc}
  */
 public function createAutoRoute($uri, $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('#/#', $uri, 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->setParent($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->setParent($document);
     $headRoute->setAutoRouteTag($autoRouteTag);
     $headRoute->setType(AutoRouteInterface::TYPE_PRIMARY);
     return $headRoute;
 }
Ejemplo n.º 11
0
 /**
  * {@inheritDoc}
  */
 public function createAutoRoute($uri, $contentDocument, $autoRouteTag)
 {
     $path = $this->baseRoutePath;
     $document = $parentDocument = $this->dm->find(null, $path);
     if (null === $parentDocument) {
         throw new \RuntimeException(sprintf('The "route_basepath" configuration points to a non-existant path "%s".', $path));
     }
     $segments = preg_split('#/#', $uri, null, PREG_SPLIT_NO_EMPTY);
     $headName = array_pop($segments);
     foreach ($segments as $segment) {
         $path .= '/' . $segment;
         $document = $this->dm->find(null, $path);
         if (null === $document) {
             $document = new Generic();
             $document->setParent($parentDocument);
             $document->setNodeName($segment);
             $this->dm->persist($document);
         }
         $parentDocument = $document;
     }
     $headRoute = new $this->autoRouteFqcn();
     $headRoute->setContent($contentDocument);
     $headRoute->setName($headName);
     $headRoute->setParent($document);
     $headRoute->setAutoRouteTag($autoRouteTag);
     $headRoute->setType(AutoRouteInterface::TYPE_PRIMARY);
     return $headRoute;
 }