Пример #1
0
 public function addParam(Request $request, ParamInterface $param)
 {
     $requestId = spl_object_hash($request);
     $this->getParams($request);
     $this->params[$requestId]['params'][$param->getName()] = $param;
 }
Пример #2
0
 /**
  * Check if current param is not in conflict with other parameters
  * according to the "incompatibles" field.
  *
  * @param ParamInterface $param the configuration for the param fetcher
  *
  * @throws BadRequestHttpException
  */
 protected function checkNotIncompatibleParams(ParamInterface $param)
 {
     $params = $this->getParams();
     foreach ($param->getIncompatibilities() as $incompatibleParamName) {
         if (!array_key_exists($incompatibleParamName, $params)) {
             throw new \InvalidArgumentException(sprintf("No @ParamInterface configuration for parameter '%s'.", $incompatibleParamName));
         }
         $incompatibleParam = $params[$incompatibleParamName];
         if ($incompatibleParam->getValue($this->requestStack->getCurrentRequest(), null) !== null) {
             $exceptionMessage = sprintf("'%s' param is incompatible with %s param.", $param->getName(), $incompatibleParam->getName());
             throw new BadRequestHttpException($exceptionMessage);
         }
     }
 }
 /**
  * {@inheritdoc}
  */
 public function format(ParamInterface $param, ConstraintViolationInterface $violation)
 {
     return sprintf("Parameter %s value '%s' violated a constraint (%s)", $param->getName(), $violation->getInvalidValue(), $violation->getMessage());
 }