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

        foreach ($entities as $entity) {
            if (!$entity->populatedByService() && !$allowOverwrite) {
                throw new \InvalidArgumentException(sprintf(
                    'Given entity cannot be saved because it may overwrite an '.
                    'existing record. When updating manually created entities, '.
                    'please set the options `$allowOverwrite` flag to `true`. '.
                    'Invalid entity key was %s',
                    (string) $entity->key()
                ));
            }
        }
    }
public function checkOverwrite(array $entities, $allowOverwrite = false)
    {
        $this->validateBatch($entities, EntityInterface::class);

        foreach ($entities as $entity) {
            if (!$entity->populatedByService() && !$allowOverwrite) {
                throw new \InvalidArgumentException(sprintf(
                    'Given entity cannot be saved because it may overwrite an '.
                    'existing record. When updating manually created entities, '.
                    'please set the options `$allowOverwrite` flag to `true`. '.
                    'Invalid entity key was %s',
                    (string) $entity->key()
                ));
            }
        }
    }
public function checkOverwrite ( array $ entities , $ allowOverwrite = false ) { $ this -> validateBatch ( $ entities , EntityInterface :: class ) ; foreach ( $ entities as $ entity ) { if ( ! $ entity -> populatedByService ( ) && ! $ allowOverwrite ) { throw new \ InvalidArgumentException ( sprintf ( 'Given entity cannot be saved because it may overwrite an ' . 'existing record. When updating manually created entities, ' . 'please set the options `$allowOverwrite` flag to `true`. ' . 'Invalid entity key was %s' , ( string ) $ entity -> key ( ) ) ) ; } } }
Check whether an update or upsert operation may proceed safely

@param EntityInterface[] $entities the entities to be updated or upserted.
@param bool $allowOverwrite If `true`, entities may be overwritten.
**Defaults to** `false`.
@throws InvalidArgumentException
@return void
Check whether an update or upsert operation may proceed safely