original_string: 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;
      }
code: 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;
      }
code_tokens: 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 ; }
docstring: 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
docstring_tokens: Throws an exception should any of the passed entities is not persisted .