Esempio n. 1
0
 public function testLoadWithoutData()
 {
     $content = [];
     $this->node->getPropertyValueWithDefault(Argument::any(), Argument::any())->will(function ($arguments) use(&$content) {
         if (isset($content[$arguments[0]])) {
             return $content[$arguments[0]];
         } else {
             return $arguments[1];
         }
     });
     $this->extension->setLanguageCode('de', 'i18n', null);
     $result = $this->extension->load($this->node->reveal(), 'default', 'de');
     $this->assertEquals(['title' => '', 'description' => '', 'keywords' => '', 'canonicalUrl' => '', 'noIndex' => false, 'noFollow' => false, 'hideInSitemap' => false], $result);
 }
Esempio n. 2
0
 /**
  * {@inheritdoc}
  */
 public function read(NodeInterface $node, PropertyInterface $property, $webspaceKey, $languageCode, $segmentKey)
 {
     $data = $node->getPropertyValueWithDefault($property->getName(), '{}');
     if (is_string($data)) {
         $data = json_decode($data, true);
     }
     if (!empty($data['tags'])) {
         $data['tags'] = $this->tagManager->resolveTagIds($data['tags']);
     }
     $property->setValue($data);
 }
Esempio n. 3
0
 /**
  * {@inheritdoc}
  */
 public function read(NodeInterface $node, PropertyInterface $property, $webspaceKey, $languageCode, $segmentKey)
 {
     $data = [];
     $categoryIds = $node->getPropertyValueWithDefault($property->getName(), []);
     $categories = $this->categoryManager->findByIds($categoryIds);
     $categories = $this->categoryManager->getApiObjects($categories, $languageCode);
     foreach ($categories as $category) {
         $data[] = $category->toArray();
     }
     $this->setData($data, $property);
 }
Esempio n. 4
0
 /**
  * {@inheritdoc}
  */
 public function read(NodeInterface $node, PropertyInterface $property, $webspaceKey, $languageCode, $segmentKey)
 {
     $value = $node->getPropertyValueWithDefault($property->getName(), $this->defaultValue);
     $property->setValue($this->validate($value, $languageCode));
     return $value;
 }
Esempio n. 5
0
 private function getShadowLocale(NodeInterface $node, $locale)
 {
     return $node->getPropertyValueWithDefault($this->encoder->localizedSystemName(self::SHADOW_LOCALE_FIELD, $locale), null);
 }
Esempio n. 6
0
 /**
  * load a single property value.
  *
  * @param NodeInterface $node
  * @param string        $name    name of property in node
  * @param string        $default value if no property exists with given name
  *
  * @return mixed
  */
 protected function loadProperty(NodeInterface $node, $name, $default = '')
 {
     return $node->getPropertyValueWithDefault($this->getPropertyName($name), $default);
 }
Esempio n. 7
0
 /**
  * {@inheritdoc}
  */
 public function load(NodeInterface $node, $webspaceKey, $languageCode)
 {
     return ['a' => $node->getPropertyValueWithDefault($this->getPropertyName('a'), ''), 'b' => $node->getPropertyValueWithDefault($this->getPropertyName('b'), '')];
 }
Esempio n. 8
0
 /**
  * Return true if the given node has the given
  * nodeType property (or properties).
  *
  * The sulu node type is the local name of node types
  * with the sulu namespace.
  *
  * Example:
  *   sulu:snippet is the PHPCR node type
  *   snippet is the Sulu node type
  *
  * @param NodeInterface $node
  * @param string|array  $suluNodeTypes One or more node sulu types
  *
  * @return bool
  */
 public function hasSuluNodeType($node, $suluNodeTypes)
 {
     foreach ((array) $suluNodeTypes as $suluNodeType) {
         if (in_array($suluNodeType, $node->getPropertyValueWithDefault('jcr:mixinTypes', []))) {
             return true;
         }
     }
     return false;
 }
Esempio n. 9
0
 private function getWorkflowStage(NodeInterface $node, $locale)
 {
     $value = $node->getPropertyValueWithDefault($this->encoder->localizedSystemName(self::WORKFLOW_STAGE_FIELD, $locale), null);
     return $value;
 }
 /**
  * {@inheritdoc}
  */
 public function read(NodeInterface $node, PropertyInterface $property, $webspaceKey, $languageCode, $segmentKey)
 {
     $data = json_decode($node->getPropertyValueWithDefault($property->getName(), '{}'), true);
     $this->setData($data, $property, $languageCode);
 }
 /**
  * Returns navigation context of given node and locale.
  *
  * @param NodeInterface $node
  * @param $locale
  *
  * @return array
  */
 private function getNavigationContext(NodeInterface $node, $locale)
 {
     return $node->getPropertyValueWithDefault(sprintf(self::NAVIGATION_CONTEXT_PROPERTY, $locale), []);
 }
Esempio n. 12
0
 /**
  * {@inheritdoc}
  */
 public function read(NodeInterface $node, PropertyInterface $property, $webspaceKey, $languageCode, $segmentKey)
 {
     $tags = $this->tagManager->resolveTagIds($node->getPropertyValueWithDefault($property->getName(), []));
     $property->setValue($tags);
 }
Esempio n. 13
0
 /**
  * Cleanup specific node and his children.
  *
  * @param NodeInterface $node
  * @param string        $rootPath
  * @param bool          $dryRun
  */
 private function cleanup(OutputInterface $output, NodeInterface $node, $rootPath, $dryRun)
 {
     foreach ($node->getNodes() as $childNode) {
         $this->cleanup($output, $childNode, $rootPath, $dryRun);
     }
     $path = ltrim(str_replace($rootPath, '', $node->getPath()), '/');
     if (!$node->getPropertyValueWithDefault('sulu:history', false)) {
         $output->writeln('<info>Processing aborted: </info>/' . $path . ' <comment>(no history url)</comment>');
         return;
     }
     if ($dryRun === false) {
         $node->remove();
     }
     $output->writeln('<info>Processing: </info>/' . $path);
 }
Esempio n. 14
0
 /**
  * {@inheritdoc}
  */
 public function getPropertyValueWithDefault($relPath, $defaultValue)
 {
     return $this->node->getPropertyValueWithDefault($relPath, $defaultValue);
 }
Esempio n. 15
0
 /**
  * {@inheritdoc}
  */
 public function read(NodeInterface $node, PropertyInterface $property, $webspaceKey, $languageCode, $segmentKey)
 {
     $categoryIds = $node->getPropertyValueWithDefault($property->getName(), []);
     $this->setData($categoryIds, $property);
 }
 private function getCreator(NodeInterface $node, $locale)
 {
     return $node->getPropertyValueWithDefault($this->encoder->localizedSystemName(self::CREATOR, $locale), null);
 }