/** * It should hydrate data from extensions. */ public function testHydrateExtensionsData() { $expectedData = ['foo' => 'bar']; $document = new TestExtensionDocument(); $this->hydrateEvent->getLocale()->shouldNotBeCalled(); $this->hydrateEvent->getDocument()->willReturn($document); $this->inspector->getWebspace($document)->willReturn('sulu_io'); $this->inspector->getLocale($document)->shouldBeCalled()->willReturn('de'); $this->namespaceRegistry->getPrefix('extension_localized')->willReturn('ext_prefix'); $this->extensionManager->getExtension('foobar', 'ext_1')->willReturn($this->extension->reveal()); $this->extension->getName()->willReturn('ext_1'); $this->extension->setLanguageCode('de', 'ext_prefix', '')->shouldBeCalled(); $this->extension->load($this->node->reveal(), 'sulu_io', 'de')->willReturn($expectedData); $this->subscriber->handleHydrate($this->hydrateEvent->reveal()); $this->assertEquals($document->getExtensionsData()->offsetGet('ext_1'), $expectedData); }
/** * load data from extension. */ private function loadExtensionData(NodeInterface $node, ExtensionInterface $extension, $webspaceKey, $locale) { $extension->setLanguageCode($locale, $this->namespaceRegistry->getPrefix('extension_localized'), ''); $data = $extension->load($node, $webspaceKey, $locale); return $extension->getContentData($data); }