|
@@ -28,7 +28,7 @@ class DeviceValidator extends ConstraintValidator
|
|
|
{
|
|
|
$this->webservice = $webservice;
|
|
|
$this->deviceCheckUrl = $deviceCheckUrl;
|
|
|
- $this->enabled = true;
|
|
|
+ $this->enabled = true;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -37,18 +37,29 @@ class DeviceValidator extends ConstraintValidator
|
|
|
*/
|
|
|
public function validate($entity, Constraint $constraint)
|
|
|
{
|
|
|
- if(!$this->enabled) return;
|
|
|
+ if (!$this->enabled) return;
|
|
|
|
|
|
$result = $this->webservice->makeGetRequest($this->deviceCheckUrl);
|
|
|
$data = json_decode($result, true);
|
|
|
if (is_null($entity->getId()) && isset($data['result']) && $data['result'] == false) {
|
|
|
$this->context->buildViolation($constraint->message)
|
|
|
- ->addViolation();
|
|
|
+ ->addViolation();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- function remoteCheck($enable){
|
|
|
+ function remoteCheck($enable)
|
|
|
+ {
|
|
|
$this->enabled = $enable;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Se utiliza para las pruebas de phpunit
|
|
|
+ * @param Webservice $webservice
|
|
|
+ */
|
|
|
+ public function setWebservice($webservice)
|
|
|
+ {
|
|
|
+ $this->webservice = $webservice;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
}
|