You are here

class Callback in Plug 7

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

@author Bernhard Schussek <bschussek@gmail.com>

@api

Hierarchy

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

Expanded class hierarchy of Callback

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

... See full list

File

lib/Symfony/validator/Symfony/Component/Validator/Constraints/Callback.php, line 24

Namespace

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

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

  /**
   * @var array
   *
   * @deprecated Deprecated since version 2.4, to be removed in Symfony 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['callback']) && !isset($options['methods']) && !isset($options['groups'])) {
      if (is_callable($options)) {
        $options = array(
          'callback' => $options,
        );
      }
      else {

        // BC with Symfony < 2.4
        $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. 7
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. 1
Constraint::__get public function Returns the value of a lazily initialized option.
Constraint::__set public function Sets the value of a lazily initialized option.
Constraint::__sleep public function Optimizes the serialized value to minimize storage space.