private function createPage() { $page = new PageDocument(); $page->setTitle('Hello'); $page->setResourceSegment('/hello'); $page->setParent($this->contentDocument); $page->setStructureType('internallinks'); $page->getStructure()->bind(['title' => 'World', 'internalLinks' => [$this->contentDocument->getUuid()]], true); $this->documentManager->persist($page, 'fr'); $this->documentManager->flush(); return $page; }
public function testGetItemsTags() { $client = $this->createAuthenticatedClient(); $client->request('GET', '/api/items?webspace=sulu_io&locale=en&dataSource=' . $this->team->getUuid() . '&provider=content&excluded=' . $this->team->getUuid() . '&limitResult=2&tags[]=' . $this->tag1->getName()); $this->assertEquals(200, $client->getResponse()->getStatusCode()); $result = json_decode($client->getResponse()->getContent(), true); $this->assertEquals(['id' => $this->team->getUuid(), 'title' => 'Team', 'path' => '/team'], $result['datasource']); $this->assertEquals([['id' => $this->johannes->getUuid(), 'title' => 'Johannes']], $result['_embedded']['items']); }
public function testSaveDocumentWithBlocks() { $document = new PageDocument(); $document->setTitle('Places'); $document->setStructureType('blocks'); $document->setResourceSegment('/places'); $document->setWorkflowStage(WorkflowStage::PUBLISHED); $document->getStructure()->bind(['block' => [['type' => 'article', 'title' => 'Dornbirn', 'article' => 'Dornbirn Austrua'], ['type' => 'article', 'title' => 'Basel', 'article' => 'Basel Switzerland', 'lines' => ['line1', 'line2']]]], false); $document->setParent($this->homeDocument); $this->documentManager->persist($document, 'de'); $this->documentManager->flush(); $searchManager = $this->getSearchManager(); $searches = ['Places' => 1, 'Basel' => 1, 'Dornbirn' => 1]; foreach ($searches as $search => $count) { $res = $searchManager->createSearch($search)->locale('de')->index('page')->execute(); $this->assertCount($count, $res, 'Searching for: ' . $search); } }
public function generateDocumentIndex($count, $urlPrefix = '/test-') { $documents = []; for ($i = 1; $i <= $count; ++$i) { $pageDocument = new PageDocument(); $pageDocument->setStructureType('default'); $pageDocument->setParent($this->homeDocument); $pageDocument->setTitle('Document Title ' . $i); $pageDocument->setWorkflowStage(WorkflowStage::PUBLISHED); $pageDocument->setResourceSegment($urlPrefix . $i); $this->documentManager->persist($pageDocument, 'de'); $documents[] = $pageDocument; } $this->documentManager->flush(); return $documents; }
/** * @param string $title * @param string $locale * @param array $data * @param PageDocument $parent * @param array $permissions * @param string $path * * @return PageDocument */ private function createPage($title, $locale, $data = [], $parent = null, array $permissions = [], $path = null) { /** @var PageDocument $document */ $document = $this->documentManager->create('page'); if (!$path) { $path = $this->sessionManager->getContentPath('sulu_io') . '/' . $title; } if ($parent !== null) { $path = $parent->getPath(); $document->setParent($parent); } $data['title'] = $title; $data['url'] = '/' . $title; $document->setStructureType('simple'); $document->setTitle($title); $document->setResourceSegment($data['url']); $document->setLocale($locale); $document->setRedirectType(RedirectType::NONE); $document->setShadowLocaleEnabled(false); $document->getStructure()->bind($data); $document->setPermissions($permissions); $this->documentManager->persist($document, $locale, ['path' => $path, 'auto_create' => true]); $this->documentManager->flush(); return $document; }
private function createPage($data) { $page = new PageDocument(); $page->setTitle('Hello'); $page->setParent($this->parent); $page->setStructureType('contact'); $page->setResourceSegment('/foo'); $page->getStructure()->bind($data, true); return $page; }