You are here

class Callback in Zircon Profile 8.0

Same name in this branch
  1. 8.0 vendor/symfony/validator/Constraints/Callback.php \Symfony\Component\Validator\Constraints\Callback
  2. 8.0 vendor/zendframework/zend-feed/src/PubSubHubbub/Subscriber/Callback.php \Zend\Feed\PubSubHubbub\Subscriber\Callback
  3. 8.0 core/modules/migrate/src/Plugin/migrate/process/Callback.php \Drupal\migrate\Plugin\migrate\process\Callback
Same name and namespace in other branches
  1. 8 vendor/symfony/validator/Constraints/Callback.php \Symfony\Component\Validator\Constraints\Callback

@Target({"CLASS", "PROPERTY", "METHOD", "ANNOTATION"})

@author Bernhard Schussek <bschussek@gmail.com>

Hierarchy

  • class \Symfony\Component\Validator\Constraint
    • class \Symfony\Component\Validator\Constraints\Callback

Expanded class hierarchy of Callback

Related topics

8 files declare their use of Callback
Abstract2Dot5ApiTest.php in vendor/symfony/validator/Tests/Validator/Abstract2Dot5ApiTest.php
AbstractLegacyApiTest.php in vendor/symfony/validator/Tests/Validator/AbstractLegacyApiTest.php
AbstractValidatorTest.php in vendor/symfony/validator/Tests/Validator/AbstractValidatorTest.php
AnnotationLoader.php in vendor/symfony/validator/Mapping/Loader/AnnotationLoader.php
AnnotationLoaderTest.php in vendor/symfony/validator/Tests/Mapping/Loader/AnnotationLoaderTest.php

... See full list

3 string references to 'Callback'
ConstraintManager::registerDefinitions in core/lib/Drupal/Core/Validation/ConstraintManager.php
Callback for registering definitions for constraints shipped with Symfony.
RecursiveContextualValidatorTest::setupTypedData in core/tests/Drupal/Tests/Core/TypedData/RecursiveContextualValidatorTest.php
Setups a typed data object used for test purposes.
RecursiveContextualValidatorTest::testBasicValidateWithConstraint in core/tests/Drupal/Tests/Core/TypedData/RecursiveContextualValidatorTest.php
@covers ::validate

File

vendor/symfony/validator/Constraints/Callback.php, line 22

Namespace

Symfony\Component\Validator\Constraints
View source
class Callback extends Constraint {

  /**
   * @var string|callable
   *
   * @since 2.4
   */
  public $callback;

  /**
   * @var array
   *
   * @deprecated since version 2.4, to be removed in 3.0.
   */
  public $methods;

  /**
   * {@inheritdoc}
   */
  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);
  }

  /**
   * {@inheritdoc}
   */
  public function getDefaultOption() {
    return 'callback';
  }

  /**
   * {@inheritdoc}
   */
  public function getTargets() {
    return array(
      self::CLASS_CONSTRAINT,
      self::PROPERTY_CONSTRAINT,
    );
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Callback::$callback public property @since 2.4
Callback::$methods Deprecated 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 Initializes the constraint with options. Overrides Constraint::__construct
Constraint::$errorNames protected static property Maps error codes to the names of their constants. 16
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. 1
Constraint::CLASS_CONSTRAINT constant Marks a constraint that can be put onto classes.
Constraint::DEFAULT_GROUP constant The name of the group given to all constraints with no explicit group.
Constraint::getErrorName public static function Returns the name of the given error code.
Constraint::getRequiredOptions public function Returns the name of the required options. 11
Constraint::PROPERTY_CONSTRAINT constant Marks a constraint that can be put onto properties.
Constraint::validatedBy public function Returns the name of the class that validates this constraint. 11
Constraint::__get public function Returns the value of a lazily initialized option. 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.