Exemplo n.º 1
0
 /**
  * Returns provider for given property.
  *
  * @param PropertyInterface $property
  *
  * @return DataProviderInterface
  */
 private function getProvider(PropertyInterface $property)
 {
     $params = $property->getParams();
     // default fallback to content
     $providerAlias = 'content';
     if (array_key_exists('provider', $params)) {
         $providerAlias = $params['provider']->getValue();
     }
     return $this->dataProviderPool->get($providerAlias);
 }
Exemplo n.º 2
0
 public function setUp()
 {
     $this->contentDataProvider = $this->prophesize(DataProviderInterface::class);
     $this->contentDataProvider->getConfiguration()->willReturn($this->getProviderConfiguration());
     $this->contentDataProvider->getDefaultPropertyParameter()->willReturn([]);
     $this->dataProviderPool = new DataProviderPool();
     $this->dataProviderPool->add('content', $this->contentDataProvider->reveal());
     $this->tagManager = $this->getMockForAbstractClass(TagManagerInterface::class, [], '', false, true, true, ['resolveTagIds', 'resolveTagNames']);
     $this->requestStack = $this->getMockBuilder(RequestStack::class)->getMock();
     $this->request = $this->getMockBuilder(Request::class)->getMock();
     $this->requestStack->expects($this->any())->method('getCurrentRequest')->will($this->returnValue($this->request));
     $this->tagRequestHandler = $this->prophesize(TagRequestHandlerInterface::class);
     $this->tagRequestHandler->getTags('tags')->willReturn([]);
     $this->categoryRequestHandler = $this->prophesize(CategoryRequestHandlerInterface::class);
     $this->categoryRequestHandler->getCategories('categories')->willReturn([]);
     $this->smartContent = new SmartContent($this->dataProviderPool, $this->tagManager, $this->requestStack, $this->tagRequestHandler->reveal(), $this->categoryRequestHandler->reveal(), 'SuluContentBundle:Template:content-types/smart_content.html.twig');
     $this->tagManager->expects($this->any())->method('resolveTagIds')->will($this->returnValueMap([[[1, 2], ['Tag1', 'Tag2']]]));
     $this->tagManager->expects($this->any())->method('resolveTagName')->will($this->returnValueMap([[['Tag1', 'Tag2'], [1, 2]]]));
 }