public function Callback::__construct in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/validator/Constraints/Callback.php \Symfony\Component\Validator\Constraints\Callback::__construct()
Initializes the constraint with options.
You should pass an associative array. The keys should be the names of existing properties in this class. The values should be the value for these properties.
Alternatively you can override the method getDefaultOption() to return the name of an existing property. If no associative array is passed, this property is set instead.
You can force that certain options are set by overriding getRequiredOptions() to return the names of these options. If any option is not set here, an exception is thrown.
Parameters
mixed $options The options (as associative array): or the value for the default option (any other type)
Throws
InvalidOptionsException When you pass the names of non-existing options
MissingOptionsException When you don't pass any of the options returned by getRequiredOptions()
ConstraintDefinitionException When you don't pass an associative array, but getDefaultOption() returns null
Overrides Constraint::__construct
File
- vendor/
symfony/ validator/ Constraints/ Callback.php, line 41
Class
- Callback
- @Target({"CLASS", "PROPERTY", "METHOD", "ANNOTATION"})
Namespace
Symfony\Component\Validator\ConstraintsCode
public function __construct($options = null) {
// Invocation through annotations with an array parameter only
if (is_array($options) && 1 === count($options) && isset($options['value'])) {
$options = $options['value'];
}
if (is_array($options) && isset($options['methods'])) {
@trigger_error('The "methods" option of the ' . __CLASS__ . ' class is deprecated since version 2.4 and will be removed in 3.0. Use the "callback" option instead.', E_USER_DEPRECATED);
}
if (is_array($options) && !isset($options['callback']) && !isset($options['methods']) && !isset($options['groups'])) {
if (is_callable($options) || !$options) {
$options = array(
'callback' => $options,
);
}
else {
// @deprecated, to be removed in 3.0
$options = array(
'methods' => $options,
);
}
}
parent::__construct($options);
}