示例#1
0
 public function testResolve()
 {
     $this->contentTypeManager->get('content_type')->willReturn($this->contentType);
     $this->contentType->getViewData(Argument::any())->willReturn('view');
     $this->contentType->getContentData(Argument::any())->willReturn('content');
     $excerptExtension = $this->prophesize('Sulu\\Component\\Content\\Extension\\ExtensionInterface');
     $excerptExtension->getContentData(['test1' => 'test1'])->willReturn(['test1' => 'test1']);
     $this->structureManager->getExtension('test', 'excerpt')->willReturn($excerptExtension);
     $property = $this->prophesize('Sulu\\Component\\Content\\Compat\\PropertyInterface');
     $property->getName()->willReturn('property');
     $property->getContentTypeName()->willReturn('content_type');
     $structure = $this->prophesize('Sulu\\Component\\Content\\Compat\\Structure\\PageBridge');
     $structure->getKey()->willReturn('test');
     $structure->getExt()->willReturn(new ExtensionContainer(['excerpt' => ['test1' => 'test1']]));
     $structure->getUuid()->willReturn('some-uuid');
     $structure->getProperties(true)->willReturn([$property->reveal()]);
     $structure->getCreator()->willReturn(1);
     $structure->getChanger()->willReturn(1);
     $structure->getCreated()->willReturn('date');
     $structure->getChanged()->willReturn('date');
     $structure->getPublished()->willReturn('date');
     $structure->getPath()->willReturn('test-path');
     $structure->getUrls()->willReturn(['en' => '/description', 'de' => '/beschreibung', 'es' => null]);
     $structure->getShadowBaseLanguage()->willReturn('en');
     $expected = ['extension' => ['excerpt' => ['test1' => 'test1']], 'uuid' => 'some-uuid', 'view' => ['property' => 'view'], 'content' => ['property' => 'content'], 'creator' => 1, 'changer' => 1, 'created' => 'date', 'changed' => 'date', 'published' => 'date', 'template' => 'test', 'urls' => ['en' => '/description', 'de' => '/beschreibung', 'es' => null], 'path' => 'test-path', 'shadowBaseLocale' => 'en'];
     $this->assertEquals($expected, $this->structureResolver->resolve($structure->reveal()));
 }
示例#2
0
 /**
  * Returns a select statement for excerpt data.
  */
 private function buildSelectorForExcerpt($locale, &$additionalFields)
 {
     $excerptStructure = $this->structureManager->getStructure('excerpt');
     $extension = $this->structureManager->getExtension('', 'excerpt');
     foreach ($excerptStructure->getProperties(true) as $property) {
         $additionalFields[$locale][] = ['extension' => $extension, 'target' => 'excerpt', 'property' => $property->getName(), 'name' => $property->getName()];
     }
 }
示例#3
0
 /**
  * {@inheritDoc}
  */
 public function resolve(StructureInterface $structure)
 {
     $data = ['view' => [], 'content' => [], 'uuid' => $structure->getUuid(), 'creator' => $structure->getCreator(), 'changer' => $structure->getChanger(), 'created' => $structure->getCreated(), 'changed' => $structure->getChanged(), 'template' => $structure->getKey(), 'path' => $structure->getPath()];
     if ($structure instanceof PageBridge) {
         $data['extension'] = $structure->getExt()->toArray();
         $data['urls'] = $structure->getUrls();
         $data['published'] = $structure->getPublished();
         $data['shadowBaseLocale'] = $structure->getShadowBaseLanguage();
         foreach ($data['extension'] as $name => $value) {
             $extension = $this->structureManager->getExtension($structure->getKey(), $name);
             $data['extension'][$name] = $extension->getContentData($value);
         }
     }
     foreach ($structure->getProperties(true) as $property) {
         $contentType = $this->contentTypeManager->get($property->getContentTypeName());
         $data['view'][$property->getName()] = $contentType->getViewData($property);
         $data['content'][$property->getName()] = $contentType->getContentData($property);
     }
     return $data;
 }