Chris@0: Chris@0: * Chris@0: * For the full copyright and license information, please view the LICENSE Chris@0: * file that was distributed with this source code. Chris@0: */ Chris@0: Chris@0: namespace Symfony\Component\Validator\Constraints; Chris@0: Chris@0: use Symfony\Component\Validator\Constraint; Chris@0: Chris@0: /** Chris@0: * @Annotation Chris@0: * @Target({"CLASS", "PROPERTY", "METHOD", "ANNOTATION"}) Chris@0: * Chris@0: * @author Bernhard Schussek Chris@0: */ Chris@0: class Callback extends Constraint Chris@0: { Chris@0: /** Chris@0: * @var string|callable Chris@0: */ Chris@0: public $callback; Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function __construct($options = null) Chris@0: { Chris@0: // Invocation through annotations with an array parameter only Chris@17: if (\is_array($options) && 1 === \count($options) && isset($options['value'])) { Chris@0: $options = $options['value']; Chris@0: } Chris@0: Chris@17: if (\is_array($options) && !isset($options['callback']) && !isset($options['groups']) && !isset($options['payload'])) { Chris@17: $options = ['callback' => $options]; Chris@0: } Chris@0: Chris@0: parent::__construct($options); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function getDefaultOption() Chris@0: { Chris@0: return 'callback'; Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function getTargets() Chris@0: { Chris@17: return [self::CLASS_CONSTRAINT, self::PROPERTY_CONSTRAINT]; Chris@0: } Chris@0: }