getProperty() public method

returns a property instance with given name.
public getProperty ( $name ) : Sulu\Component\Content\Compat\PropertyInterface
$name string name of property
return Sulu\Component\Content\Compat\PropertyInterface
Esempio n. 1
0
 /**
  * extracts sequence information from property name.
  *
  * @param StructureInterface $content
  * @param string             $property sequence like (block,1,title,0)
  *
  * @return array|bool
  */
 public function getSequence(StructureInterface $content, $property)
 {
     if (false !== strpos($property, ',')) {
         $sequence = explode(',', $property);
         $propertyPath = [];
         $indexSequence = [];
         $propertyInstance = $content->getProperty($sequence[0]);
         for ($i = 1; $i < sizeof($sequence); ++$i) {
             // is not integer
             if (!ctype_digit(strval($sequence[$i]))) {
                 $propertyPath[] = $sequence[$i];
                 if ($propertyInstance instanceof BlockPropertyInterface) {
                     $lastIndex = $indexSequence[sizeof($indexSequence) - 1];
                     unset($indexSequence[sizeof($indexSequence) - 1]);
                     $indexSequence = array_values($indexSequence);
                     $propertyInstance = $propertyInstance->getProperties($lastIndex)->getProperty($sequence[$i]);
                 }
             } else {
                 $indexSequence[] = intval($sequence[$i]);
             }
         }
         return ['sequence' => $sequence, 'propertyPath' => $propertyPath, 'property' => $propertyInstance, 'index' => $indexSequence];
     }
     return false;
 }
Esempio n. 2
0
 /**
  * Returns select of a single structure with title and url selector.
  */
 private function buildSelectForStructure($locale, StructureInterface $structure, &$names)
 {
     $nodeNameProperty = $structure->getProperty('title');
     $result = '';
     $name = $this->getTranslatedProperty($nodeNameProperty, $locale)->getName();
     if (!in_array($name, $names)) {
         $names[] = $name;
         $result .= ', ' . $this->buildSelector($name);
     }
     if ($structure->hasTag('sulu.rlp')) {
         $urlProperty = $structure->getPropertyByTagName('sulu.rlp');
         $name = $this->getTranslatedProperty($urlProperty, $locale)->getName();
         if ($urlProperty->getContentTypeName() !== 'resource_locator' && !in_array($name, $names)) {
             $names[] = $name;
             $result .= ', ' . $this->buildSelector($name);
         }
     }
     return $result;
 }