/** * Check if entity is not attached to another repository. * @param IEntity * @param bool * @return bool * @throws InvalidEntityException */ private function checkEntityRepository(IEntity $entity, $throw = true) { $r = $entity->getRepository(false); if ($r and $r !== $this->repository) { if ($throw) { throw new InvalidEntityException(EntityHelper::toString($entity) . ' is attached to another repository.'); } return false; } return true; }