Example #1
0
 /**
  * Checks if the passed value is valid.
  *
  * @param string $value The value that should be validated
  * @param IsAvailable|Constraint $constraint The constraint for the validation
  */
 public function validate($value, Constraint $constraint)
 {
     $available = $this->repository->getAvailability($value);
     if (!$available) {
         $this->context->buildViolation($constraint->message)->addViolation();
     }
 }
Example #2
0
 /**
  * @inheritdoc
  */
 public function getAvailability(\string $id) : \bool
 {
     $key = sprintf(self::QUANTITY_KEY, $id);
     if (!$this->predis->exists($key)) {
         $value = $this->repository->getAvailability($id);
         $this->saveAvailability($id, $value);
     } else {
         $value = (int) $this->predis->get($key);
     }
     return $value;
 }
Example #3
0
 public function getProductAvailabilityById(GetProductAvailabilityByIdQuery $query)
 {
     $result = $this->viewRepository->getAvailability($query->getId());
     $query->setResult($result);
 }