Пример #1
0
 /**
  * Saves a new existing snippet.
  *
  * @param Request $request
  * @param string $uuid
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function putSnippetAction(Request $request, $uuid)
 {
     $this->initEnv($request);
     $data = $request->request->all();
     $mapperRequest = ContentMapperRequest::create()->setType('snippet')->setTemplateKey($this->getRequired($request, 'template'))->setUuid($uuid)->setLocale($this->languageCode)->setUserId($this->getUser()->getId())->setData($data)->setState(intval($request->get('state', StructureInterface::STATE_PUBLISHED)));
     $snippet = $this->contentMapper->saveRequest($mapperRequest);
     $view = View::create($this->decorateSnippet($snippet->toArray(), $this->languageCode));
     return $this->viewHandler->handle($view);
 }
Пример #2
0
 public function testLoadWithSmartContent()
 {
     $startPage = $this->mapper->loadStartPage('sulu_io', 'de');
     $data = ContentMapperRequest::create('page')->setLocale('de')->setTemplateKey('overview_smart_content')->setData(['title' => 'Testname', 'tags' => ['tag1', 'tag2'], 'url' => '/news', 'article' => 'sulu_io', 'smartcontent' => ['dataSource' => $startPage->getUuid()]])->setWebspaceKey('sulu_io')->setState(Structure::STATE_PUBLISHED)->setUserId(1);
     $structure = $this->mapper->saveRequest($data);
     $childData = ContentMapperRequest::create('page')->setLocale('de')->setTemplateKey('default')->setData(['title' => 'Testname', 'url' => '/news/child', 'article' => 'sulu_io'])->setWebspaceKey('sulu_io')->setState(Structure::STATE_PUBLISHED)->setUserId(1);
     $childStructure = $this->mapper->saveRequest($childData);
     $content = $this->mapper->load($structure->getUuid(), 'sulu_io', 'de');
     $smartContentType = $this->contentTypeManager->get('smart_content');
     $smartContentData = $smartContentType->getContentData($content->getProperty('smartcontent'));
     $this->assertInstanceOf('DateTime', $smartContentData[0]['published']);
 }
Пример #3
0
 /**
  * @expectedException Sulu\Component\DocumentManager\Exception\DocumentNotFoundException
  * @expectedExceptionMessage Requested document of type "page" but got
  */
 public function testUpdatePageWrongType()
 {
     $req = ContentMapperRequest::create()->setUuid($this->snippet1->getUuid())->setType(Structure::TYPE_PAGE)->setWebspaceKey('sulu_io')->setTemplateKey('test_page')->setLocale('de')->setState(StructureInterface::STATE_PUBLISHED)->setUserId(1)->setData(['title' => 'Foo']);
     $this->contentMapper->saveRequest($req);
 }