LocalHref.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. declare(strict_types=1);
  3. namespace Sabre\DAV\Xml\Property;
  4. use Sabre\HTTP;
  5. /**
  6. * LocalHref property.
  7. *
  8. * Like the Href property, this element represents {DAV:}href. The difference
  9. * is that this is used strictly for paths on the server. The LocalHref property
  10. * will prepare the path so it's a valid URI.
  11. *
  12. * These two objects behave identically:
  13. * new LocalHref($path)
  14. * new Href(\Sabre\HTTP\encodePath($path))
  15. *
  16. * LocalPath basically ensures that your spaces are %20, and everything that
  17. * needs to be is uri encoded.
  18. *
  19. * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
  20. * @author Evert Pot (http://www.rooftopsolutions.nl/)
  21. * @license http://sabre.io/license/ Modified BSD License
  22. */
  23. class LocalHref extends Href
  24. {
  25. /**
  26. * Constructor.
  27. *
  28. * You must either pass a string for a single href, or an array of hrefs.
  29. *
  30. * If auto-prefix is set to false, the hrefs will be treated as absolute
  31. * and not relative to the servers base uri.
  32. *
  33. * @param string|string[] $hrefs
  34. */
  35. public function __construct($hrefs)
  36. {
  37. parent::__construct(array_map(
  38. function ($href) {
  39. return \Sabre\HTTP\encodePath($href);
  40. },
  41. (array) $hrefs
  42. ));
  43. }
  44. }