PathValidatorInterface.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace Drupal\Core\Path;
  3. /**
  4. * Provides an interface for url path validators.
  5. */
  6. interface PathValidatorInterface {
  7. /**
  8. * Returns a URL object, if the path is valid and accessible.
  9. *
  10. * @param string $path
  11. * The path to check.
  12. *
  13. * @return \Drupal\Core\Url|false
  14. * The url object, or FALSE if the path is not valid.
  15. */
  16. public function getUrlIfValid($path);
  17. /**
  18. * Returns a URL object, if the path is valid.
  19. *
  20. * Unlike getUrlIfValid(), access check is not performed. Do not use this
  21. * method if the $path is about to be presented to a user.
  22. *
  23. * @param string $path
  24. * The path to check.
  25. *
  26. * @return \Drupal\Core\Url|false
  27. * The url object, or FALSE if the path is not valid.
  28. */
  29. public function getUrlIfValidWithoutAccessCheck($path);
  30. /**
  31. * Checks if the URL path is valid and accessible by the current user.
  32. *
  33. * @param string $path
  34. * The path to check.
  35. *
  36. * @return bool
  37. * TRUE if the path is valid.
  38. */
  39. public function isValid($path);
  40. }