Datastore/src/Operation.php
public function allocateIdsToEntities(array $entities)
    {
        $this->validateBatch($entities, EntityInterface::class);

        $incompleteKeys = [];
        foreach ($entities as $entity) {
            if ($entity->key()->state() === Key::STATE_INCOMPLETE) {
                $incompleteKeys[] = $entity->key();
            }
        }

        if (!empty($incompleteKeys)) {
            $keys = $this->allocateIds($incompleteKeys);
        }

        return $entities;
    }
public function allocateIdsToEntities(array $entities)
    {
        $this->validateBatch($entities, EntityInterface::class);

        $incompleteKeys = [];
        foreach ($entities as $entity) {
            if ($entity->key()->state() === Key::STATE_INCOMPLETE) {
                $incompleteKeys[] = $entity->key();
            }
        }

        if (!empty($incompleteKeys)) {
            $keys = $this->allocateIds($incompleteKeys);
        }

        return $entities;
    }
public function allocateIdsToEntities ( array $ entities ) { $ this -> validateBatch ( $ entities , EntityInterface :: class ) ; $ incompleteKeys = [ ] ; foreach ( $ entities as $ entity ) { if ( $ entity -> key ( ) -> state ( ) === Key :: STATE_INCOMPLETE ) { $ incompleteKeys [ ] = $ entity -> key ( ) ; } } if ( ! empty ( $ incompleteKeys ) ) { $ keys = $ this -> allocateIds ( $ incompleteKeys ) ; } return $ entities ; }
Patch any incomplete keys in the given array of entities

Any incomplete keys will be allocated an ID. Named keys in the input
will remain unchanged.

@param EntityInterface[] $entities A list of entities
@return EntityInterface[]
Patch any incomplete keys in the given array of entities