class Callback
Same name in this branch
- 11.1.x vendor/phpunit/phpunit/src/Framework/Constraint/Callback.php \PHPUnit\Framework\Constraint\Callback
- 11.1.x core/modules/migrate/src/Plugin/migrate/process/Callback.php \Drupal\migrate\Plugin\migrate\process\Callback
Defines custom validation rules through arbitrary callback methods.
@author Bernhard Schussek <bschussek@gmail.com>
Hierarchy
- class \Symfony\Component\Validator\Constraint
- class \Symfony\Component\Validator\Constraints\Callback extends \Symfony\Component\Validator\Constraint
Expanded class hierarchy of Callback
3 files declare their use of Callback
- AttributeLoader.php in vendor/
symfony/ validator/ Mapping/ Loader/ AttributeLoader.php - ConstraintManager.php in core/
lib/ Drupal/ Core/ Validation/ ConstraintManager.php - Recipe.php in core/
lib/ Drupal/ Core/ Recipe/ Recipe.php
19 string references to 'Callback'
- Callback::getDefaultOption in vendor/
symfony/ validator/ Constraints/ Callback.php - Returns the name of the default option.
- ConstraintManager::registerDefinitions in core/
lib/ Drupal/ Core/ Validation/ ConstraintManager.php - Callback for registering definitions for constraints shipped with Symfony.
- CreateWidgetTypeCallbackSniff::process in vendor/
squizlabs/ php_codesniffer/ src/ Standards/ MySource/ Sniffs/ Objects/ CreateWidgetTypeCallbackSniff.php - Processes this test, when one of its tokens is encountered.
- d6_action.yml in core/
modules/ system/ migrations/ d6_action.yml - core/modules/system/migrations/d6_action.yml
- d6_block.yml in core/
modules/ block/ migrations/ d6_block.yml - core/modules/block/migrations/d6_block.yml
File
-
vendor/
symfony/ validator/ Constraints/ Callback.php, line 21
Namespace
Symfony\Component\Validator\ConstraintsView source
class Callback extends Constraint {
/**
* @var string|callable
*/
public $callback;
/**
* @param string|string[]|callable|array<string,mixed>|null $callback The callback definition
* @param string[]|null $groups
*/
public function __construct(array|string|callable|null $callback = null, ?array $groups = null, mixed $payload = null, array $options = []) {
// Invocation through attributes with an array parameter only
if (\is_array($callback) && 1 === \count($callback) && isset($callback['value'])) {
$callback = $callback['value'];
}
if (!\is_array($callback) || !isset($callback['callback']) && !isset($callback['groups']) && !isset($callback['payload'])) {
$options['callback'] = $callback;
}
else {
$options = array_merge($callback, $options);
}
parent::__construct($options, $groups, $payload);
}
public function getDefaultOption() : ?string {
return 'callback';
}
public function getTargets() : string|array {
return [
self::CLASS_CONSTRAINT,
self::PROPERTY_CONSTRAINT,
];
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
Callback::$callback | public | property | |||
Callback::getDefaultOption | public | function | Returns the name of the default option. | Overrides Constraint::getDefaultOption | |
Callback::getTargets | public | function | Returns whether the constraint can be put onto classes, properties or both. |
Overrides Constraint::getTargets | |
Callback::__construct | public | function | Overrides Constraint::__construct | ||
Constraint::$groups | public | property | The groups that the constraint belongs to. | ||
Constraint::$payload | public | property | Domain-specific data attached to a constraint. | ||
Constraint::addImplicitGroupName | public | function | Adds the given group if this constraint is in the Default group. | 2 | |
Constraint::CLASS_CONSTRAINT | public | constant | Marks a constraint that can be put onto classes. | ||
Constraint::DEFAULT_GROUP | public | constant | The name of the group given to all constraints with no explicit group. | ||
Constraint::ERROR_NAMES | protected | constant | Maps error codes to the names of their constants. | 59 | |
Constraint::getErrorName | public static | function | Returns the name of the given error code. | ||
Constraint::getRequiredOptions | public | function | Returns the name of the required options. | 22 | |
Constraint::normalizeOptions | protected | function | |||
Constraint::PROPERTY_CONSTRAINT | public | constant | Marks a constraint that can be put onto properties. | ||
Constraint::validatedBy | public | function | Returns the name of the class that validates this constraint. | 9 | |
Constraint::__get | public | function | Returns the value of a lazily initialized option. | 2 | |
Constraint::__isset | public | function | 1 | ||
Constraint::__set | public | function | Sets the value of a lazily initialized option. | 1 | |
Constraint::__sleep | public | function | Optimizes the serialized value to minimize storage space. |