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

/lib/vendor/symfony/1.3/lib/task/project/upgrade1.3/sfUpgrade.class.php

http://piwam.googlecode.com/
PHP | 114 lines | 56 code | 11 blank | 47 comment | 0 complexity | bc49042154d75b309eef8b44d84dc6d0 MD5 | raw file
Possible License(s): ISC, LGPL-2.1, AGPL-3.0, BSD-3-Clause, LGPL-3.0, GPL-2.0
  1. <?php
  2. /*
  3. * This file is part of the symfony package.
  4. * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. /**
  10. * Abstract class for upgrade classes.
  11. *
  12. * @package symfony
  13. * @subpackage task
  14. * @author Fabien Potencier <fabien.potencier@symfony-project.com>
  15. * @version SVN: $Id: sfUpgrade.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
  16. */
  17. abstract class sfUpgrade extends sfBaseTask
  18. {
  19. protected
  20. $task = null;
  21. /**
  22. * Upgrades the current project from 1.0 to 1.1.
  23. */
  24. abstract public function upgrade();
  25. public function execute($arguments = array(), $options = array())
  26. {
  27. throw new sfException('You can\'t execute this task.');
  28. }
  29. /**
  30. * Returns a finder that exclude upgrade scripts from being upgraded!
  31. *
  32. * @param string $type String directory or file or any (for both file and directory)
  33. *
  34. * @return sfFinder A sfFinder instance
  35. */
  36. protected function getFinder($type)
  37. {
  38. return sfFinder::type($type)->prune('symfony')->discard('symfony');
  39. }
  40. /**
  41. * Returns all project directories where you can put PHP classes.
  42. */
  43. protected function getProjectClassDirectories()
  44. {
  45. return array_merge(
  46. $this->getProjectLibDirectories(),
  47. $this->getProjectActionDirectories()
  48. );
  49. }
  50. /**
  51. * Returns all project directories where you can put templates.
  52. */
  53. protected function getProjectTemplateDirectories()
  54. {
  55. return array_merge(
  56. glob(sfConfig::get('sf_apps_dir').'/*/modules/*/templates'),
  57. glob(sfConfig::get('sf_apps_dir').'/*/templates')
  58. );
  59. }
  60. /**
  61. * Returns all project directories where you can put actions and components.
  62. */
  63. protected function getProjectActionDirectories()
  64. {
  65. return glob(sfConfig::get('sf_apps_dir').'/*/modules/*/actions');
  66. }
  67. /**
  68. * Returns all project lib directories.
  69. *
  70. * @param string $subdirectory A subdirectory within lib (i.e. "/form")
  71. */
  72. protected function getProjectLibDirectories($subdirectory = null)
  73. {
  74. return array_merge(
  75. glob(sfConfig::get('sf_apps_dir').'/*/modules/*/lib'.$subdirectory),
  76. glob(sfConfig::get('sf_apps_dir').'/*/lib'.$subdirectory),
  77. array(
  78. sfConfig::get('sf_apps_dir').'/lib'.$subdirectory,
  79. sfConfig::get('sf_lib_dir').$subdirectory,
  80. )
  81. );
  82. }
  83. /**
  84. * Returns all project config directories.
  85. */
  86. protected function getProjectConfigDirectories()
  87. {
  88. return array_merge(
  89. glob(sfConfig::get('sf_apps_dir').'/*/modules/*/config'),
  90. glob(sfConfig::get('sf_apps_dir').'/*/config'),
  91. glob(sfConfig::get('sf_config_dir'))
  92. );
  93. }
  94. /**
  95. * Returns all application names.
  96. *
  97. * @return array An array of application names
  98. */
  99. protected function getApplications()
  100. {
  101. return sfFinder::type('dir')->maxdepth(0)->relative()->in(sfConfig::get('sf_apps_dir'));
  102. }
  103. }