Skip to content

Commit f1b9908

Browse files
committed
Merge branch '2.8' into 3.4
* 2.8: Simplify Apache config with FallbackResource Made the code of a validation example more robust
2 parents f61e70c + 677b9b2 commit f1b9908

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

setup/web_server_configuration.rst

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,7 @@ and increase web server performance:
7979
Order Allow,Deny
8080
Allow from All
8181
82-
<IfModule mod_rewrite.c>
83-
Options -MultiViews
84-
RewriteEngine On
85-
RewriteCond %{REQUEST_FILENAME} !-f
86-
RewriteRule ^(.*)$ app.php [QSA,L]
87-
</IfModule>
82+
FallbackResource /app.php
8883
</Directory>
8984
9085
# uncomment the following lines if you install assets as symlinks
@@ -93,13 +88,11 @@ and increase web server performance:
9388
# Options FollowSymlinks
9489
# </Directory>
9590
96-
# optionally disable the RewriteEngine for the asset directories
97-
# which will allow apache to simply reply with a 404 when files are
98-
# not found instead of passing the request into the full symfony stack
91+
# optionally disable the fallback resource for the asset directories
92+
# which will allow Apache to return a 404 error when files are
93+
# not found instead of passing the request to Symfony
9994
<Directory /var/www/project/web/bundles>
100-
<IfModule mod_rewrite.c>
101-
RewriteEngine Off
102-
</IfModule>
95+
FallbackResource disabled
10396
</Directory>
10497
ErrorLog /var/log/apache2/project_error.log
10598
CustomLog /var/log/apache2/project_access.log combined

validation/custom_constraint.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,22 @@ The validator class is also simple, and only has one required method ``validate(
5959

6060
use Symfony\Component\Validator\Constraint;
6161
use Symfony\Component\Validator\ConstraintValidator;
62+
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
6263

6364
class ContainsAlphanumericValidator extends ConstraintValidator
6465
{
6566
public function validate($value, Constraint $constraint)
6667
{
68+
// custom constraints should ignore null and empty values to allow
69+
// other constraints (NotBlank, NotNull, etc.) take care of that
70+
if (null === $value || '' === $value) {
71+
return;
72+
}
73+
74+
if (!is_string($value)) {
75+
throw new UnexpectedTypeException($value, 'string');
76+
}
77+
6778
if (!preg_match('/^[a-zA-Z0-9]+$/', $value, $matches)) {
6879
$this->context->buildViolation($constraint->message)
6980
->setParameter('{{ string }}', $value)

0 commit comments

Comments
 (0)