Sulu\Bundle\ContentBundle\Repository\NodeRepositoryInterface::getFilteredNodes PHP Метод

getFilteredNodes() публичный Метод

Returns the content of a smart content configuration.
public getFilteredNodes ( array $filterConfig, string $languageCode, string $webspaceKey, boolean $preview = false, boolean $api = false ) : array
$filterConfig array The config of the smart content
$languageCode string The desired language code
$webspaceKey string The webspace key
$preview boolean If true also unpublished pages will be returned
$api boolean If true result will be formated for HAL API
Результат array
    public function getFilteredNodes(array $filterConfig, $languageCode, $webspaceKey, $preview = false, $api = false);

Usage Example

Пример #1
0
 public function testGetFilteredNodesInOrderByTitle()
 {
     $data = [['title' => 'hello you', 'tags' => ['tag1', 'tag2'], 'url' => '/news/test1', 'article' => 'Test'], ['title' => 'Hello me', 'tags' => ['tag1', 'tag2'], 'url' => '/news/test2', 'article' => 'Test'], ['title' => 'Test', 'tags' => ['tag1', 'tag2'], 'url' => '/news/test3', 'article' => 'Test']];
     foreach ($data as &$element) {
         $element = $this->mapper->save($element, 'overview', 'sulu_io', 'en', 1, true, null, null, StructureInterface::STATE_PUBLISHED);
         sleep(1);
     }
     $nodes = $this->nodeRepository->getFilteredNodes(['sortBy' => ['title'], 'sortMethod' => 'asc'], 'en', 'sulu_io');
     $this->assertEquals('Hello me', $nodes[0]['title']);
     $this->assertEquals('hello you', $nodes[1]['title']);
     $this->assertEquals('Test', $nodes[2]['title']);
     $nodes = $this->nodeRepository->getFilteredNodes(['sortBy' => ['title'], 'sortMethod' => 'desc'], 'en', 'sulu_io');
     $this->assertEquals('Hello me', $nodes[2]['title']);
     $this->assertEquals('hello you', $nodes[1]['title']);
     $this->assertEquals('Test', $nodes[0]['title']);
 }