Abstract.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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_Controller
  17. * @subpackage Router
  18. * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @version $Id$
  20. * @license http://framework.zend.com/license/new-bsd New BSD License
  21. */
  22. /**
  23. * @see Zend_Controller_Router_Route_Interface
  24. */
  25. require_once 'Zend/Controller/Router/Route/Interface.php';
  26. /**
  27. * Abstract Route
  28. *
  29. * Implements interface and provides convenience methods
  30. *
  31. * @package Zend_Controller
  32. * @subpackage Router
  33. * @copyright Copyright (c) 2005-2014 Zend Technologies USA Inc. (http://www.zend.com)
  34. * @license http://framework.zend.com/license/new-bsd New BSD License
  35. */
  36. abstract class Zend_Controller_Router_Route_Abstract implements Zend_Controller_Router_Route_Interface
  37. {
  38. /**
  39. * URI delimiter
  40. */
  41. const URI_DELIMITER = '/';
  42. /**
  43. * Wether this route is abstract or not
  44. *
  45. * @var boolean
  46. */
  47. protected $_isAbstract = false;
  48. /**
  49. * Path matched by this route
  50. *
  51. * @var string
  52. */
  53. protected $_matchedPath = null;
  54. /**
  55. * Get the version of the route
  56. *
  57. * @return integer
  58. */
  59. public function getVersion()
  60. {
  61. return 2;
  62. }
  63. /**
  64. * Set partially matched path
  65. *
  66. * @param string $path
  67. * @return void
  68. */
  69. public function setMatchedPath($path)
  70. {
  71. $this->_matchedPath = $path;
  72. }
  73. /**
  74. * Get partially matched path
  75. *
  76. * @return string
  77. */
  78. public function getMatchedPath()
  79. {
  80. return $this->_matchedPath;
  81. }
  82. /**
  83. * Check or set wether this is an abstract route or not
  84. *
  85. * @param boolean $flag
  86. * @return boolean
  87. */
  88. public function isAbstract($flag = null)
  89. {
  90. if ($flag !== null) {
  91. $this->_isAbstract = $flag;
  92. }
  93. return $this->_isAbstract;
  94. }
  95. /**
  96. * Create a new chain
  97. *
  98. * @param Zend_Controller_Router_Route_Abstract $route
  99. * @param string $separator
  100. * @return Zend_Controller_Router_Route_Chain
  101. */
  102. public function chain(Zend_Controller_Router_Route_Abstract $route, $separator = '/')
  103. {
  104. require_once 'Zend/Controller/Router/Route/Chain.php';
  105. $chain = new Zend_Controller_Router_Route_Chain();
  106. $chain->chain($this)->chain($route, $separator);
  107. return $chain;
  108. }
  109. }