Content is set by binding raw data to the StructureInterface retried through the getContent method. Content is accessed as folows: $this->getContent()->getProperty('foo')->getValue();
Inheritance: extends Sulu\Component\DocumentManager\Behavior\Mapping\LocaleBehavior
Example #1
0
 /**
  * It should act as an array.
  */
 public function testArrayAccess()
 {
     $name = 'test';
     $contentTypeName = 'hello';
     $this->document->getLocale()->shouldNotBeCalled();
     $this->propertyMetadata->isLocalized()->willReturn(false);
     $this->doGetProperty($name, $contentTypeName, null);
 }
Example #2
0
 /**
  * Adds the properties of the structure to the serialization.
  *
  * @param StructureBehavior $document
  * @param VisitorInterface $visitor
  */
 private function addStructureProperties(StructureMetadata $structureMetadata, StructureBehavior $document, VisitorInterface $visitor)
 {
     /** @var ManagedStructure $structure */
     $structure = $document->getStructure();
     $data = $structure->toArray();
     foreach ($structureMetadata->getProperties() as $name => $property) {
         if ($name === 'title' || !array_key_exists($name, $data) || $property->hasTag('sulu.rlp')) {
             continue;
         }
         $visitor->addData($name, $data[$name]);
     }
 }
 /**
  * It should return any localizations if neither parent nor children.
  */
 public function testWebspaceAnyLocalization()
 {
     $this->inspector->getWebspace($this->document->reveal())->willReturn(self::FIX_WEBSPACE);
     $this->inspector->getLocales($this->document->reveal())->willReturn(['de']);
     $this->webspace->getLocalization(self::FIX_LOCALE)->willReturn($this->localization1->reveal());
     $this->localization1->getLocalization()->willReturn('en');
     $this->localization2->getLocalization()->willReturn('de');
     $this->hydrateEvent->getOption('load_ghost_content', true)->willReturn(true);
     $this->localization1->getParent()->willReturn(null);
     $this->localization1->getChildren()->willReturn([]);
     $this->webspace->getLocalizations()->willReturn([$this->localization2->reveal()]);
     $this->registry->updateLocale($this->document->reveal(), 'de', 'en')->shouldBeCalled();
     $this->hydrateEvent->setLocale('de')->shouldBeCalled();
     $this->subscriber->handleHydrate($this->hydrateEvent->reveal());
 }
Example #4
0
 private function doGetProperty($name, $contentTypeName, $locale)
 {
     $this->propertyMetadata->getType()->willReturn($contentTypeName);
     $this->structureMetadata->getProperty($name)->willReturn($this->propertyMetadata);
     $this->contentTypeManager->get($contentTypeName)->willReturn($this->contentType->reveal());
     if ($locale) {
         $this->propertyFactory->createTranslatedProperty($this->propertyMetadata->reveal(), $locale, Argument::type(StructureBridge::class))->willReturn($this->legacyProperty->reveal());
     } else {
         $this->propertyFactory->createProperty($this->propertyMetadata->reveal(), $locale)->willReturn($this->legacyProperty->reveal());
     }
     $this->inspector->getWebspace($this->document->reveal())->willReturn('sulu_io');
     $this->inspector->getOriginalLocale($this->document->reveal())->willReturn($locale);
     $this->contentType->read($this->node->reveal(), $this->legacyProperty->reveal(), 'sulu_io', $locale, null)->shouldBeCalledTimes(1);
     $property = $this->structure->getProperty($name);
     $this->assertInstanceOf(PropertyValue::class, $property);
     $this->assertEquals($name, $property->getName());
 }
Example #5
0
 private function copyDocument($srcLocale, $destLocale, StructureBehavior $document, $overwrite = false)
 {
     if (!$overwrite) {
         $destStructure = $this->contentMapper->load($document->getUuid(), null, $destLocale, true);
         if (!($destStructure->getType() && $destStructure->getType()->getName() === 'ghost')) {
             $this->output->writeln('<info>Processing aborted: </info>' . $document->getNodeName() . ' <comment>(use overwrite option to force)</comment>');
             return;
         }
     }
     $this->contentMapper->copyLanguage($document->getUuid(), $document->getChanger(), null, $srcLocale, $destLocale, Structure::TYPE_SNIPPET);
     $this->output->writeln('<info>Processing: </info>' . $document->getNodeName());
 }