Source for file Mapping.php

Documentation is available at Mapping.php

  1. <?php
  2.  
  3. /**
  4. * MVCnPHP - Mapping.class.php
  5. *
  6. * This source file is subject to version 2.02 of the PHP license,
  7. * that is bundled with this package in the file LICENSE, and is
  8. * available at through the world-wide-web at
  9. * http://www.php.net/license/2_02.txt.
  10. * If you did not receive a copy of the PHP license and are unable to
  11. * obtain it through the world-wide-web, please send a note to
  12. * license@php.net so we can mail you a copy immediately.
  13. *
  14. * @author Tony Bibbs <tony@geeklog.net>
  15. * @copyright Tony Bibbs 2003
  16. * @package net.geeklog.mvc
  17. * @version $Id: Mapping.class.php,v 1.2 2003/08/28 01:31:22 tony Exp $
  18. *
  19. */
  20.  
  21. /**
  22. * This is the mapping object. This holds all pertinent mapping data for
  23. * a specific model or view. NOTE: not all available mappings are loaded
  24. * for each request, only those needed for the current request.
  25. *
  26. * @author Tony Bibbs <tony@geeklog.net>
  27. * @package net.geeklog.mvc
  28. *
  29. */
  30. class MVCnPHP_Mapping {
  31. /**
  32. * @access private
  33. * @var string
  34. */
  35. private $name = null;
  36. /**
  37. * @access private
  38. * @var string
  39. */
  40. private $type = null;
  41. /**
  42. * @access private
  43. * @var string
  44. */
  45. private $typePath = null;
  46. /**
  47. * @access private
  48. * @var string
  49. */
  50. private $forwards = null;
  51. /**
  52. * @access private
  53. * @var string
  54. */
  55. private $baseURL = null;
  56. /**
  57. * Sets the base URL for any redirects
  58. *
  59. * @author Tony Bibbs <tony@geeklog.net>
  60. * @access public
  61. * @param string $url Base url for all redirects
  62. *
  63. */
  64. public function setBaseURL($url)
  65. {
  66. $this->baseURL = $url;
  67. }
  68. /**
  69. * Gets the base URL for any redirects
  70. * Any forwards to other URL's must be relative to the
  71. * base URL provided
  72. *
  73. * @author Tony Bibbs <tony@geeklog.net>
  74. * @access public
  75. * @return string Base url
  76. *
  77. */
  78. public function getBaseURL()
  79. {
  80. return $this->baseURL;
  81. }
  82. /**
  83. * Sets the name for the model or view this mapping
  84. * belongs to.
  85. *
  86. * @author Tony Bibbs <tony@geeklog.net>
  87. * @access public
  88. * @param string $name Name of model or view
  89. *
  90. */
  91. public function setName($name)
  92. {
  93. $this->name = $name;
  94. }
  95. /**
  96. * Gets the name for the model or view this mapping
  97. * belongs to.
  98. *
  99. * @author Tony Bibbs <tony@geeklog.net>
  100. * @access public
  101. * @return string Name of the model or view
  102. *
  103. */
  104. public function getName()
  105. {
  106. return $this->name;
  107. }
  108. /**
  109. * Sets the type of object this mapping belongs to (model or view)
  110. *
  111. * @author Tony Bibbs <tony@geeklog.net>
  112. * @access public
  113. * @param string $type Type of object (model or view)
  114. *
  115. */
  116. public function setType($type)
  117. {
  118. $this->type = $type;
  119. }
  120. /**
  121. * Gets the type of object this mapping belongs to (model or view)
  122. *
  123. * @author Tony Bibbs <tony@geeklog.net>
  124. * @access public
  125. * @return string Type of object (model or view)
  126. *
  127. */
  128. public function getType()
  129. {
  130. return $this->type;
  131. }
  132. /**
  133. * Sets all forwards associated with this mapping. Note
  134. * that you won't have forwards for any views
  135. *
  136. * @author Tony Bibbs <tony@geeklog.net>
  137. * @access public
  138. * @param array $forwards Array of forwards tied to this object
  139. *
  140. */
  141. public function setForwards($forwards)
  142. {
  143. $this->forwards = $forwards;
  144. }
  145. public function getForwards()
  146. {
  147. return $this->forwards;
  148. }
  149. /**
  150. * Retrieves the requested forward
  151. *
  152. * @author Tony Bibbs <tony@geeklog.net>
  153. * @access public
  154. * @param string $name Name of forward to get
  155. * @return array|booleanThe forward data or false if not found
  156. *
  157. */
  158. public function getForward($name)
  159. {
  160. if (!empty($this->forwards[$name])) {
  161. return $this->forwards[$name];
  162. } else {
  163. return false;
  164. }
  165. }
  166. /**
  167. * Sets the path where the models or views can be found
  168. *
  169. * @author Tony Bibbs <tony@geeklog.net>
  170. * @access public
  171. * @param string $path Absolute path ending with trailing slash
  172. *
  173. */
  174. public function setTypePath($path)
  175. {
  176. $this->typePath = $path;
  177. }
  178.  
  179. /**
  180. * Gets the absolute path where the code for this model or view this
  181. * mapping belongs to can be found
  182. *
  183. * @author Tony Bibbs <tony@geeklog.net>
  184. * @access public
  185. * @return string Path to model or view directory
  186. *
  187. */
  188. public function getPath()
  189. {
  190. return $this->typePath;
  191. }
  192. }
  193.  
  194. ?>

Documentation generated on Mon, 7 Mar 2005 22:36:22 -0600 by phpDocumentor 1.3.0RC3