PageRenderTime 25ms CodeModel.GetById 24ms RepoModel.GetById 1ms app.codeStats 0ms

/bluebox/libraries/Package/Configure.php

https://github.com/robertleeplummerjr/bluebox
PHP | 311 lines | 85 code | 31 blank | 195 comment | 0 complexity | 896b87c5cedabb3397e856962f733c92 MD5 | raw file
  1. <?php defined('SYSPATH') or die('No direct access allowed.');
  2. /**
  3. * @package Core/Libraries/Package
  4. * @author K Anderson <bitbashing@gmail.com>
  5. * @license Mozilla Public License (MPL)
  6. */
  7. abstract class Package_Configure
  8. {
  9. /**
  10. * Version of this module. Use any php version string
  11. * see http://php.net/manual/en/function.version-compare.php
  12. * @var mixed
  13. */
  14. public static $version = 0.0;
  15. /**
  16. * The display name of this module
  17. * @var string
  18. */
  19. public static $displayName = NULL;
  20. /**
  21. * The string to display as the name of the author(s)
  22. * @var string
  23. */
  24. public static $author = 'Unspecified';
  25. /**
  26. * The string to display as the name organization
  27. * @var string
  28. */
  29. public static $vendor = 'Unspecified';
  30. /**
  31. * The string to display as the type of license
  32. * @var string
  33. */
  34. public static $license = 'MPL';
  35. /**
  36. * A breif description of the module, should to be under 150 charaters
  37. * Used in module listings to brief the user to the purpose of the module
  38. * @var string
  39. */
  40. public static $summary = 'This is a generic package.';
  41. /**
  42. * The full description of the module, used to provide users with more details
  43. * @var string
  44. */
  45. public static $description = '';
  46. /**
  47. * The default enabled value, if true it will attempt to install by default
  48. * @var bool
  49. */
  50. public static $default = FALSE;
  51. /**
  52. * If true this module can not be uninstalled
  53. * @var bool
  54. */
  55. public static $denyRemoval = FALSE;
  56. /**
  57. * This is a list of catagories constants as defined in Core_PackageManager
  58. * @var string
  59. */
  60. public static $type = Package_Manager::TYPE_DEFAULT;
  61. /**
  62. * This variable is useful for making sure the user has other modules installed that may be required
  63. * @var array Key/value pair of modules and dependencies
  64. */
  65. public static $required = array();
  66. /**
  67. *
  68. * @var string
  69. */
  70. public static $navBranch = '/';
  71. /**
  72. *
  73. * @var string
  74. */
  75. public static $navURL = NULL;
  76. /**
  77. *
  78. * @var string
  79. */
  80. public static $navLabel = NULL;
  81. /**
  82. *
  83. * @var string
  84. */
  85. public static $navSummary = NULL;
  86. /**
  87. * This is an array optionally defining a submenu
  88. * @var array
  89. */
  90. public static $navSubmenu = array();
  91. /**
  92. * The constuctor for this class ensures that the modules manditory defaults are fulfilled
  93. * @return void
  94. */
  95. public function __construct()
  96. {
  97. $this->noMethodMethod(__FUNCTION__);
  98. }
  99. /*************************
  100. * INSTALLATION ROUTINES *
  101. *************************/
  102. /**
  103. * Do any pre-installation preparation.
  104. *
  105. * Things like making a temp directory or downloading stuff you might need.
  106. * All modules have their preInstall() methods run first, before install() runs, so if you may need to setup
  107. * something another module's install method depends on, do it here.
  108. *
  109. * You do not need to override this class if you are not adding additional functionality to it.
  110. *
  111. * @return array | NULL Array of failures, or NULL if everything is OK
  112. */
  113. public function preInstall()
  114. {
  115. $this->noMethodMethod(__FUNCTION__);
  116. }
  117. /**
  118. * Do the actual installation.
  119. *
  120. * Make sure you rollback any changes if your install fails (using uninstall())!
  121. *
  122. * By default, the install routine just installs your models. If that's all you need for your install,
  123. * you don't need to override this function. All models in the directory of your module will be installed.
  124. *
  125. * You do not need to override this class if you are not adding additional functionality to it.
  126. *
  127. * @return array | NULL Array of failures, or NULL if everything is OK
  128. */
  129. public function install($package = NULL)
  130. {
  131. $this->noMethodMethod(__FUNCTION__);
  132. }
  133. /**
  134. * Post-install routine for this module.
  135. *
  136. * Do any post-installation configuration that should happen after ALL modules have installed.
  137. *
  138. * You do not need to override this class if you are not adding additional functionality to it.
  139. *
  140. * @return array | NULL Array of failures, or NULL if everything is OK
  141. */
  142. public function postInstall()
  143. {
  144. $this->noMethodMethod(__FUNCTION__);
  145. }
  146. /**
  147. * Finalize-install routine for this module.
  148. *
  149. * Do any post-installation configuration that should happen after ALL modules have installed and the models commited to the db.
  150. * This is the safest place to do things that may depend on other modules.
  151. *
  152. * You do not need to override this class if you are not adding additional functionality to it.
  153. *
  154. * @return array | NULL Array of failures, or NULL if everything is OK
  155. */
  156. public function finalizeInstall()
  157. {
  158. $this->noMethodMethod(__FUNCTION__);
  159. }
  160. /**********************
  161. * MIGRATION ROUTINES *
  162. **********************/
  163. /**
  164. * Do any pre-migration preparation.
  165. *
  166. * Things like making a temp directory or downloading stuff you might need.
  167. * All modules have their preMigrate() methods run first, before mirgrate() runs, so if you may need to setup
  168. * something another module's install method depends on, do it here.
  169. *
  170. * You do not need to override this class if you are not adding additional functionality to it.
  171. *
  172. * @return array | NULL Array of failures, or NULL if everything is OK
  173. */
  174. public function preMigrate()
  175. {
  176. $this->noMethodMethod(__FUNCTION__);
  177. }
  178. /**
  179. * Perform a migration of this module.
  180. *
  181. * Make sure you rollback any changes if your migration fails!
  182. *
  183. * By default, the migrate routine just runs the migrations in Doctrine for your models, based on the version of
  184. * this module and the version registered in the database.
  185. * If that's all you need for your migrations, you don't need to override this function.
  186. * All models in the directory of your module will be migrated.
  187. *
  188. * You do not need to override this class if you are not adding additional functionality to it.
  189. *
  190. * @return array | NULL Array of failures, or NULL if everything is OK
  191. */
  192. public function migrate()
  193. {
  194. $this->noMethodMethod(__FUNCTION__);
  195. }
  196. /**
  197. * Post-migration routine for this module.
  198. *
  199. * Do any post-migration configuration that should happen after ALL modules have migrated.
  200. * This is the safest place to do things that may depend on other modules.
  201. *
  202. * You do not need to override this class if you are not adding additional functionality to it.
  203. *
  204. * @return array | NULL Array of failures, or NULL if everything is OK
  205. */
  206. public function postMigrate()
  207. {
  208. $this->noMethodMethod(__FUNCTION__);
  209. }
  210. /**********************
  211. * UNINSTALL ROUTINES *
  212. **********************/
  213. public function preUninstall()
  214. {
  215. $this->noMethodMethod(__FUNCTION__);
  216. }
  217. /**
  218. * Removes your module.
  219. *
  220. * This method MUST WORK as a last-resort rollback method on a botched install.
  221. *
  222. * By default, Core_PackageManager will remove any models associated with this module and then remove all files
  223. * in the module's directory. It will also remove the module entry from the Modules and ModuleUser tables.
  224. *
  225. * You do not need to override this class if you are not adding additional functionality to it.
  226. *
  227. * @return array | NULL Array of failures, or NULL if everything is OK
  228. */
  229. public function uninstall($package = NULL)
  230. {
  231. $this->noMethodMethod(__FUNCTION__);
  232. }
  233. public function postUninstall()
  234. {
  235. $this->noMethodMethod(__FUNCTION__);
  236. }
  237. /************************
  238. * MAINTENANCE ROUTINES *
  239. ************************/
  240. /**
  241. * Preform any possible automatic repairs
  242. *
  243. * By default this will update the package datastore, and numbertype tables.
  244. *
  245. * You do not need to override this class if you are not adding additional functionality to it.
  246. *
  247. * @return array | NULL Array of failures, or NULL if everything is OK
  248. */
  249. public function repair()
  250. {
  251. $this->noMethodMethod(__FUNCTION__);
  252. }
  253. /**
  254. * Verify module is intact.
  255. *
  256. * Verify that this module has all it's parts and nothing looks out of whack.
  257. * This gets called by install, upgrade, downgrade, repair and sanityCheck.
  258. *
  259. * You do not need to override this class if you are not adding additional functionality to it.
  260. *
  261. * @return array | NULL Array of failures, or NULL if everything is OK
  262. */
  263. public function verify()
  264. {
  265. $this->noMethodMethod(__FUNCTION__);
  266. }
  267. public function sanityCheck()
  268. {
  269. $this->noMethodMethod(__FUNCTION__);
  270. }
  271. public function completedInstall()
  272. {
  273. $this->noMethodMethod(__FUNCTION__);
  274. }
  275. private function noMethodMethod($method)
  276. {
  277. $class = str_replace('_Configure', '', get_class($this));
  278. Package_Message::log('debug', "$class doesn't have a $method method");
  279. }
  280. }