private function isCommandUsed(Command $entity)
 {
     if ($entity->getType() === Command::TYPE_SERVICE_CHECK) {
         return count($this->getServiceRepository()->findByCommand($entity)) !== 0;
     }
     if ($entity->getType() === Command::TYPE_SERVICE_NOTIFICATION) {
         return count($this->getContactRepository()->findByCommand($entity)) !== 0;
     }
     throw new \LogicException('Unknown command type: ' . $entity->getType());
 }