コード例 #1
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);
         }
     }
 }