public function validate($value, Constraint $constraint) { if (!$constraint instanceof OrchestrationOrConfigEntity) { throw new \InvalidArgumentException('Given constraint must ne instance of OrchestrationOrConfigEntity class'); } // orchestration exists try { $orchestrationId = $constraint->parseOrchestrationId($value); if (!$orchestrationId) { throw new \Exception('Orchestration does not exists'); } $value = $orchestrationId; $orchestration = $constraint->getOrchestrationManager()->findOrchestrationById($value, $constraint->getToken(), true); if (!$orchestration) { throw new \Exception('Orchestration does not exists'); } } catch (\Exception $e) { $this->context->addViolation($constraint->message, array('%string%' => $value)); return; } }