diff --git a/composer.json b/composer.json index f0d2cbe..4ca6300 100755 --- a/composer.json +++ b/composer.json @@ -26,19 +26,19 @@ "ext-libxml": "*", "ext-simplexml": "*", "psr/log": "~1.0|~2.0|~3.0", - "symfony/http-foundation": "~5.4|~6.0|~7.0", - "symfony/event-dispatcher": "~5.4|~6.0|~7.0", - "symfony/http-kernel": "~5.4|~6.0|~7.0", - "symfony/validator": "~5.4|~6.0|~7.0", + "symfony/http-foundation": "~5.4|~6.0|~7.0|~8.0", + "symfony/event-dispatcher": "~5.4|~6.0|~7.0|~8.0", + "symfony/http-kernel": "~5.4|~6.0|~7.0|~8.0", + "symfony/validator": "~5.4|~6.0|~7.0|~8.0", "psr/simple-cache": "~1.0|~2.0|~3.0", "psr/container": "~1.0|~2.0", "econea/nusoap": "~0.9" }, "require-dev": { - "symfony/routing": "~5.4|~6.0|~7.0", + "symfony/routing": "~5.4|~6.0|~7.0|~8.0", "phpunit/phpunit": "~9.5", "php-di/php-di": "~7.1", - "symfony/framework-bundle": "~5.4|~6.0|~7.0", + "symfony/framework-bundle": "~5.4|~6.0|~7.0|~8.0", "guzzlehttp/guzzle": "~5.3|~7.0" } } diff --git a/src/Api/Validator/IpRestriction.php b/src/Api/Validator/IpRestriction.php index c2a7652..ad09f1f 100755 --- a/src/Api/Validator/IpRestriction.php +++ b/src/Api/Validator/IpRestriction.php @@ -4,6 +4,8 @@ use Symfony\Component\Validator\Constraint; +use function array_key_exists; + /** * IpRestriction * @@ -14,20 +16,17 @@ class IpRestriction extends Constraint { public $message = 'This ip is not allowed.'; public $allowedIps = []; - - /** - * {@inheritdoc} - */ - public function getDefaultOption(): string - { - return 'allowedIps'; - } - - /** - * {@inheritdoc} - */ - public function getRequiredOptions(): array + + public function __construct(array $allowedIps, ?string $message = null, ?array $groups = null, mixed $payload = null) { - return ['allowedIps']; + parent::__construct(null, $groups, $payload); + + if (array_key_exists('allowedIps', $allowedIps)) { + $this->allowedIps = $allowedIps['allowedIps']; + $this->message = $allowedIps['message'] ?? $this->message; + } else { + $this->allowedIps = $allowedIps; + $this->message = $message ?? $this->message; + } } }