/**
  * It should create a translated property.
  *
  * @depends testCreateProperty
  */
 public function testCreateTranslated()
 {
     $this->setUpProperty($this->property1);
     $this->namespaceRegistry->getPrefix('content_localized')->willReturn('i18n');
     $translatedProperty = $this->factory->createTranslatedProperty($this->property1->reveal(), 'de');
     $this->assertEquals('de', $translatedProperty->getLocalization());
     $this->assertEquals('i18n:de-name', $translatedProperty->getName());
 }
 /**
  * It should persist data from extensions.
  */
 public function testPersistExtensionsData()
 {
     $document = new TestExtensionDocument(['ext_1' => ['foo' => 'bar']]);
     $this->persistEvent->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->getExtensions('foobar')->willReturn(['ext_1' => $this->extension->reveal()]);
     $this->extension->getName()->willReturn('ext_1');
     $this->extension->setLanguageCode('de', 'ext_prefix', '')->shouldBeCalled();
     $this->extension->save($this->node->reveal(), ['foo' => 'bar'], 'sulu_io', 'de')->shouldBeCalled();
     $this->subscriber->handlePersist($this->persistEvent->reveal());
 }
 private function hydrate(AbstractMappingEvent $event)
 {
     $document = $event->getDocument();
     $node = $event->getNode();
     $locale = $this->inspector->getLocale($document);
     $webspaceName = $this->inspector->getWebspace($document);
     $structureType = $document->getStructureType();
     if (null === $structureType) {
         return;
     }
     $prefix = $this->namespaceRegistry->getPrefix('extension_localized');
     $extensionContainer = new ManagedExtensionContainer($structureType, $this->extensionManager, $node, $locale, $prefix, $this->internalPrefix, $webspaceName);
     $document->setExtensionsData($extensionContainer);
 }
Exemple #4
0
 /**
  * TODO: Move this to ResourceLocator repository>
  *
  * {@inheritdoc}
  */
 public function restoreHistoryPath($path, $userId, $webspaceKey, $locale, $segmentKey = null)
 {
     $this->strategy->restoreByPath($path, $webspaceKey, $locale, $segmentKey);
     $content = $this->loadByResourceLocator($path, $webspaceKey, $locale, $segmentKey);
     $property = $content->getPropertyByTagName('sulu.rlp');
     $property->setValue($path);
     $node = $this->sessionManager->getSession()->getNodeByIdentifier($content->getUuid());
     $contentType = $this->contentTypeManager->get($property->getContentTypeName());
     $contentType->write($node, new TranslatedProperty($property, $locale, $this->namespaceRegistry->getPrefix('content_localized')), $userId, $webspaceKey, $locale, $segmentKey);
     $this->sessionManager->getSession()->save();
 }
Exemple #5
0
 /**
  * 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);
 }