示例#1
0
 /**
  * {@inheritDoc}
  */
 public function getContentData(PropertyInterface $property)
 {
     $params = array_merge($this->getDefaultParams(), $property->getParams());
     $data = $property->getValue();
     $container = new SmartContentContainer($this->contentQuery, $this->contentQueryBuilder, $this->tagManager, $params, $property->getStructure()->getWebspaceKey(), $property->getStructure()->getLanguageCode(), null, $this->stopwatch);
     $container->setConfig($data === null || !is_array($data) ? [] : $data);
     $pages = $this->loadData($container, $property, $params);
     $data['page'] = $container->getPage();
     $data['hasNextPage'] = $container->getHasNextPage();
     $property->setValue($data);
     return $pages;
 }
示例#2
0
 public function testReadPreview()
 {
     $smartContentContainerPreview = new SmartContentContainer($this->contentQuery, $this->contentQueryBuilder, $this->tagManager, ['page_parameter' => 'p', 'properties' => []], 'test', 'en', 's');
     $smartContentContainerPreview->setConfig(['tags' => ['Tag1', 'Tag2'], 'limitResult' => '2']);
     $node = $this->getMockForAbstractClass('Sulu\\Bundle\\ContentBundle\\Tests\\Unit\\Content\\Types\\NodeInterface', [], '', true, true, true, ['getPropertyValueWithDefault']);
     $property = $this->getMockForAbstractClass('Sulu\\Component\\Content\\Compat\\PropertyInterface', [], '', true, true, true, ['setValue']);
     $node->expects($this->any())->method('getPropertyValueWithDefault')->will($this->returnValueMap([['property', '{}', '{"tags":[1,2],"limitResult":"2"}']]));
     $property->expects($this->any())->method('getName')->will($this->returnValue('property'));
     $property->expects($this->any())->method('getParams')->will($this->returnValue([]));
     $property->expects($this->exactly(1))->method('setValue')->with($smartContentContainerPreview->getConfig());
     $this->smartContent->readForPreview(['tags' => ['Tag1', 'Tag2'], 'limitResult' => 2], $property, 'test', 'en', 's');
 }