Chris@0
|
1 <?php
|
Chris@0
|
2
|
Chris@0
|
3 /*
|
Chris@0
|
4 * This file is part of the Symfony package.
|
Chris@0
|
5 *
|
Chris@0
|
6 * (c) Fabien Potencier <fabien@symfony.com>
|
Chris@0
|
7 *
|
Chris@0
|
8 * For the full copyright and license information, please view the LICENSE
|
Chris@0
|
9 * file that was distributed with this source code.
|
Chris@0
|
10 */
|
Chris@0
|
11
|
Chris@0
|
12 namespace Symfony\Component\Routing\Generator;
|
Chris@0
|
13
|
Chris@0
|
14 /**
|
Chris@0
|
15 * ConfigurableRequirementsInterface must be implemented by URL generators that
|
Chris@0
|
16 * can be configured whether an exception should be generated when the parameters
|
Chris@0
|
17 * do not match the requirements. It is also possible to disable the requirements
|
Chris@0
|
18 * check for URL generation completely.
|
Chris@0
|
19 *
|
Chris@0
|
20 * The possible configurations and use-cases:
|
Chris@0
|
21 * - setStrictRequirements(true): Throw an exception for mismatching requirements. This
|
Chris@0
|
22 * is mostly useful in development environment.
|
Chris@0
|
23 * - setStrictRequirements(false): Don't throw an exception but return null as URL for
|
Chris@0
|
24 * mismatching requirements and log the problem. Useful when you cannot control all
|
Chris@0
|
25 * params because they come from third party libs but don't want to have a 404 in
|
Chris@0
|
26 * production environment. It should log the mismatch so one can review it.
|
Chris@0
|
27 * - setStrictRequirements(null): Return the URL with the given parameters without
|
Chris@0
|
28 * checking the requirements at all. When generating a URL you should either trust
|
Chris@0
|
29 * your params or you validated them beforehand because otherwise it would break your
|
Chris@0
|
30 * link anyway. So in production environment you should know that params always pass
|
Chris@0
|
31 * the requirements. Thus this option allows to disable the check on URL generation for
|
Chris@0
|
32 * performance reasons (saving a preg_match for each requirement every time a URL is
|
Chris@0
|
33 * generated).
|
Chris@0
|
34 *
|
Chris@0
|
35 * @author Fabien Potencier <fabien@symfony.com>
|
Chris@0
|
36 * @author Tobias Schultze <http://tobion.de>
|
Chris@0
|
37 */
|
Chris@0
|
38 interface ConfigurableRequirementsInterface
|
Chris@0
|
39 {
|
Chris@0
|
40 /**
|
Chris@0
|
41 * Enables or disables the exception on incorrect parameters.
|
Chris@0
|
42 * Passing null will deactivate the requirements check completely.
|
Chris@0
|
43 *
|
Chris@0
|
44 * @param bool|null $enabled
|
Chris@0
|
45 */
|
Chris@0
|
46 public function setStrictRequirements($enabled);
|
Chris@0
|
47
|
Chris@0
|
48 /**
|
Chris@0
|
49 * Returns whether to throw an exception on incorrect parameters.
|
Chris@0
|
50 * Null means the requirements check is deactivated completely.
|
Chris@0
|
51 *
|
Chris@0
|
52 * @return bool|null
|
Chris@0
|
53 */
|
Chris@0
|
54 public function isStrictRequirements();
|
Chris@0
|
55 }
|