Skip to content

Commit b0e9014

Browse files
authored
Merge pull request #62 from sherlockode/fix/length-validator-compatibility
Fix length validator compatibility SF >= 6.3
2 parents 86246f1 + f0fa97e commit b0e9014

File tree

1 file changed

+35
-15
lines changed

1 file changed

+35
-15
lines changed

src/Validator/Constraints/Length.php

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Sherlockode\SyliusFAQPlugin\Validator\Constraints;
44

5+
use Symfony\Component\HttpKernel\Kernel;
56
use Symfony\Component\Validator\Constraints\Length as BaseLength;
67
use Symfony\Component\Validator\Constraints\LengthValidator;
78

@@ -13,6 +14,7 @@ public function __construct(
1314
int $max = null,
1415
string $charset = null,
1516
callable $normalizer = null,
17+
string $countUnit = null,
1618
string $exactMessage = null,
1719
string $minMessage = null,
1820
string $maxMessage = null,
@@ -27,21 +29,39 @@ public function __construct(
2729
return strip_tags(trim($str));
2830
};
2931
}
30-
31-
parent::__construct(
32-
$exactly,
33-
$min,
34-
$max,
35-
$charset,
36-
$normalizer,
37-
$exactMessage,
38-
$minMessage,
39-
$maxMessage,
40-
$charsetMessage,
41-
$groups,
42-
$payload,
43-
$options
44-
);
32+
33+
if (Kernel::VERSION_ID >= 60300) {
34+
parent::__construct(
35+
$exactly,
36+
$min,
37+
$max,
38+
$charset,
39+
$normalizer,
40+
$countUnit,
41+
$exactMessage,
42+
$minMessage,
43+
$maxMessage,
44+
$charsetMessage,
45+
$groups,
46+
$payload,
47+
$options
48+
);
49+
} else {
50+
parent::__construct(
51+
$exactly,
52+
$min,
53+
$max,
54+
$charset,
55+
$normalizer,
56+
$exactMessage,
57+
$minMessage,
58+
$maxMessage,
59+
$charsetMessage,
60+
$groups,
61+
$payload,
62+
$options
63+
);
64+
}
4565
}
4666

4767
/**

0 commit comments

Comments
 (0)