GraphAware\Neo4j\OGM\Metadata\NodeEntityMetadata::getLabeledProperties PHP Method

getLabeledProperties() public method

public getLabeledProperties ( ) : LabeledPropertyMetadata[]
return LabeledPropertyMetadata[]
    public function getLabeledProperties()
    {
        return $this->labeledPropertiesMetadata;
    }

Usage Example

 public function getUpdateQuery($object)
 {
     $propertyValues = [];
     $extraLabels = [];
     $removeLabels = [];
     foreach ($this->classMetadata->getPropertiesMetadata() as $field => $meta) {
         $propertyValues[$field] = $meta->getValue($object);
     }
     foreach ($this->classMetadata->getLabeledProperties() as $labeledProperty) {
         if ($labeledProperty->isLabelSet($object)) {
             $extraLabels[] = $labeledProperty->getLabelName();
         } else {
             $removeLabels[] = $labeledProperty->getLabelName();
         }
     }
     $id = $this->classMetadata->getIdValue($object);
     $query = 'MATCH (n) WHERE id(n) = {id} SET n += {props}';
     if (!empty($extraLabels)) {
         foreach ($extraLabels as $label) {
             $query .= ' SET n:' . $label;
         }
     }
     if (!empty($removeLabels)) {
         foreach ($removeLabels as $label) {
             $query .= ' REMOVE n:' . $label;
         }
     }
     return Statement::create($query, ['id' => $id, 'props' => $propertyValues]);
 }