protected function _checkPersistenceStatus($sourceEntity, array $targetEntities)
    {
        if ($sourceEntity->isNew()) {
            $error = 'Source entity needs to be persisted before links can be created or removed.';
            throw new InvalidArgumentException($error);
        }

        foreach ($targetEntities as $entity) {
            if ($entity->isNew()) {
                $error = 'Cannot link entities that have not been persisted yet.';
                throw new InvalidArgumentException($error);
            }
        }

        return true;
    }
protected function _checkPersistenceStatus($sourceEntity, array $targetEntities)
    {
        if ($sourceEntity->isNew()) {
            $error = 'Source entity needs to be persisted before links can be created or removed.';
            throw new InvalidArgumentException($error);
        }

        foreach ($targetEntities as $entity) {
            if ($entity->isNew()) {
                $error = 'Cannot link entities that have not been persisted yet.';
                throw new InvalidArgumentException($error);
            }
        }

        return true;
    }
protected function _checkPersistenceStatus ( $ sourceEntity , array $ targetEntities ) { if ( $ sourceEntity -> isNew ( ) ) { $ error = 'Source entity needs to be persisted before links can be created or removed.' ; throw new InvalidArgumentException ( $ error ) ; } foreach ( $ targetEntities as $ entity ) { if ( $ entity -> isNew ( ) ) { $ error = 'Cannot link entities that have not been persisted yet.' ; throw new InvalidArgumentException ( $ error ) ; } } return true ; }
Throws an exception should any of the passed entities is not persisted.

@param \Cake\Datasource\EntityInterface $sourceEntity the row belonging to the `source` side
of this association
@param array $targetEntities list of entities belonging to the `target` side
of this association
@return bool
@throws \InvalidArgumentException
Throws an exception should any of the passed entities is not persisted .