NOTE: This class is not supposed to be subclassed by userland code. If this API is modified, make sure to also implement the additional methods inside NodeData, NodeTemplate and Node and keep NodeInterface in sync!
 /**
  * Render a node label
  *
  * @param AbstractNodeData $nodeData
  * @param boolean $crop This argument is deprecated as of Neos 1.2 and will be removed. Don't rely on this behavior and crop labels in the view.
  * @return string
  */
 public function getLabel(AbstractNodeData $nodeData, $crop = true)
 {
     if ($nodeData->hasProperty('title') === true && $nodeData->getProperty('title') !== '') {
         $label = strip_tags($nodeData->getProperty('title'));
     } elseif ($nodeData->hasProperty('text') === true && $nodeData->getProperty('text') !== '') {
         $label = strip_tags($nodeData->getProperty('text'));
     } else {
         $label = ($nodeData->getNodeType()->getLabel() ?: $nodeData->getNodeType()->getName()) . ' (' . $nodeData->getName() . ')';
     }
     if ($crop === false) {
         return $label;
     }
     $croppedLabel = trim(Functions::substr($label, 0, 30));
     return $croppedLabel . (strlen($croppedLabel) < strlen($label) ? ' …' : '');
 }
Exemplo n.º 2
0
 /**
  * Make the node "similar" to the given source node. That means,
  *  - all properties
  *  - index
  *  - node type
  *  - content object
  * will be set to the same values as in the source node.
  *
  * @param AbstractNodeData $sourceNode
  * @param boolean $isCopy
  * @return void
  */
 public function similarize(AbstractNodeData $sourceNode, $isCopy = false)
 {
     $this->properties = [];
     foreach ($sourceNode->getProperties() as $propertyName => $propertyValue) {
         $this->setProperty($propertyName, $propertyValue);
     }
     $propertyNames = ['nodeType', 'hidden', 'hiddenAfterDateTime', 'hiddenBeforeDateTime', 'hiddenInIndex', 'accessRoles'];
     if (!$isCopy) {
         $propertyNames[] = 'creationDateTime';
         $propertyNames[] = 'lastModificationDateTime';
     }
     if ($sourceNode instanceof NodeData) {
         $propertyNames[] = 'index';
     }
     foreach ($propertyNames as $propertyName) {
         ObjectAccess::setProperty($this, $propertyName, ObjectAccess::getProperty($sourceNode, $propertyName));
     }
     $contentObject = $sourceNode->getContentObject();
     if ($contentObject !== null) {
         $this->setContentObject($contentObject);
     }
 }