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

getLabel() public method

public getLabel ( ) : string
return string
    public function getLabel()
    {
        return $this->nodeAnnotationMetadata->getLabel();
    }

Usage Example

 public function getCreateQuery($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();
         }
     }
     $query = sprintf('CREATE (n:%s) SET n += {properties}', $this->classMetadata->getLabel());
     if (!empty($extraLabels)) {
         foreach ($extraLabels as $label) {
             $query .= ' SET n:' . $label;
         }
     }
     if (!empty($removeLabels)) {
         foreach ($removeLabels as $label) {
             $query .= ' REMOVE n:' . $label;
         }
     }
     $query .= ' RETURN id(n) as id';
     return Statement::create($query, ['properties' => $propertyValues], spl_object_hash($object));
 }