Drupal investigation

ConfigurableRequirementsInterface.php 2.2KB

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