2
0

Uri.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @category Zend
  16. * @package Zend_Navigation
  17. * @subpackage Page
  18. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. */
  21. /**
  22. * @see Zend_Navigation_Page_Abstract
  23. */
  24. require_once 'Zend/Navigation/Page.php';
  25. /**
  26. * Represents a page that is defined by specifying a URI
  27. *
  28. * @category Zend
  29. * @package Zend_Navigation
  30. * @subpackage Page
  31. * @copyright Copyright (c) 2005-2008 Zend Technologies USA Inc. (http://www.zend.com)
  32. * @license http://framework.zend.com/license/new-bsd New BSD License
  33. */
  34. class Zend_Navigation_Page_Uri extends Zend_Navigation_Page
  35. {
  36. /**
  37. * Page URI
  38. *
  39. * @var string|null
  40. */
  41. protected $_uri = null;
  42. /**
  43. * Sets page URI
  44. *
  45. * @param string $uri page URI, must a string or null
  46. * @return Zend_Navigation_Page_Uri fluent interface, returns self
  47. * @throws Zend_Navigation_Exception if $uri is invalid
  48. */
  49. public function setUri($uri)
  50. {
  51. if (null !== $uri && !is_string($uri)) {
  52. require_once 'Zend/Navigation/Exception.php';
  53. throw new Zend_Navigation_Exception(
  54. 'Invalid argument: $uri must be a string or null');
  55. }
  56. $this->_uri = $uri;
  57. return $this;
  58. }
  59. /**
  60. * Returns URI
  61. *
  62. * @return string
  63. */
  64. public function getUri()
  65. {
  66. return $this->_uri;
  67. }
  68. /**
  69. * Returns href for this page
  70. *
  71. * @return string
  72. */
  73. public function getHref()
  74. {
  75. return $this->getUri();
  76. }
  77. // Public methods:
  78. /**
  79. * Returns an array representation of the page
  80. *
  81. * @return array
  82. */
  83. public function toArray()
  84. {
  85. return array_merge(
  86. parent::toArray(),
  87. array(
  88. 'uri' => $this->getUri()
  89. ));
  90. }
  91. }