GraphAware\Neo4j\Client\Stack::create PHP Method

create() public static method

public static create ( null | string $tag = null, null | string $connectionAlias = null ) : GraphAware\Neo4j\Client\StackInterface
$tag null | string
$connectionAlias null | string
return GraphAware\Neo4j\Client\StackInterface
    public static function create($tag = null, $connectionAlias = null)
    {
        return new static($tag, $connectionAlias);
    }

Usage Example

 private function createLabeledNodesCreationStack(array $byLabelsMap)
 {
     $stack = Stack::create(self::TAG_NODES_CREATE);
     $statements = [];
     foreach ($byLabelsMap as $label => $entities) {
         foreach ($entities as $entity) {
             $query = sprintf('UNWIND {nodes} as node
             CREATE (n:`%s`) SET n += node.props', $label);
             $metadata = $this->em->getClassMetadataFor(get_class($entity));
             $oid = spl_object_hash($entity);
             $labeledProperties = $metadata->getLabeledPropertiesToBeSet($entity);
             $lblKey = sprintf('%s_%s', $metadata->getLabel(), implode('_', array_map(function (LabeledPropertyMetadata $labeledPropertyMetadata) {
                 return $labeledPropertyMetadata->getLabelName();
             }, $labeledProperties)));
             foreach ($labeledProperties as $labeledPropertyMetadata) {
                 $query .= sprintf(' SET n:`%s`', $labeledPropertyMetadata->getLabelName());
             }
             $query .= ' RETURN id(n) as id, node.oid as oid';
             $statements[$lblKey]['query'] = $query;
             $statements[$lblKey]['nodes'][] = ['props' => $metadata->getPropertyValuesArray($entity), 'oid' => $oid];
         }
     }
     foreach ($statements as $key => $statement) {
         $stack->push($statement['query'], ['nodes' => $statement['nodes']], $key);
     }
     return $stack;
 }
All Usage Examples Of GraphAware\Neo4j\Client\Stack::create