You are here

public function ValidatorBuilder::setApiVersion in Plug 7

Sets the API version that the returned validator should support.

Parameters

int $apiVersion The required API version:

Return value

ValidatorBuilderInterface The builder object

Overrides ValidatorBuilderInterface::setApiVersion

See also

Validation::API_VERSION_2_4

Validation::API_VERSION_2_5

Validation::API_VERSION_2_5_BC

File

lib/Symfony/validator/Symfony/Component/Validator/ValidatorBuilder.php, line 320

Class

ValidatorBuilder
The default implementation of {@link ValidatorBuilderInterface}.

Namespace

Symfony\Component\Validator

Code

public function setApiVersion($apiVersion) {
  if (!in_array($apiVersion, array(
    Validation::API_VERSION_2_4,
    Validation::API_VERSION_2_5,
    Validation::API_VERSION_2_5_BC,
  ))) {
    throw new InvalidArgumentException(sprintf('The requested API version is invalid: "%s"', $apiVersion));
  }
  if (PHP_VERSION_ID < 50309 && $apiVersion === Validation::API_VERSION_2_5_BC) {
    throw new InvalidArgumentException(sprintf('The Validator API that is compatible with both Symfony 2.4 ' . 'and Symfony 2.5 can only be used on PHP 5.3.9 and higher. ' . 'Your current PHP version is %s.', PHP_VERSION));
  }
  $this->apiVersion = $apiVersion;
  return $this;
}