PageRenderTime 52ms CodeModel.GetById 20ms RepoModel.GetById 0ms app.codeStats 0ms

/oiclient/data/symfony/task/project/upgrade1.1/sfUpgrade.class.php

http://openirudi.googlecode.com/
PHP | 112 lines | 56 code | 11 blank | 45 comment | 0 complexity | 9788ab2a6a74eff11375cae5e9bb711e MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-3.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 8148 2008-03-29 07:58:59Z fabien $
  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 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. protected function getProjectLibDirectories()
  71. {
  72. return array_merge(
  73. glob(sfConfig::get('sf_apps_dir').'/*/modules/*/lib'),
  74. glob(sfConfig::get('sf_apps_dir').'/*/lib'),
  75. array(
  76. sfConfig::get('sf_apps_dir').'/lib',
  77. sfConfig::get('sf_lib_dir'),
  78. )
  79. );
  80. }
  81. /**
  82. * Returns all project config directories.
  83. */
  84. protected function getProjectConfigDirectories()
  85. {
  86. return array_merge(
  87. glob(sfConfig::get('sf_apps_dir').'/*/modules/*/config'),
  88. glob(sfConfig::get('sf_apps_dir').'/*/config'),
  89. glob(sfConfig::get('sf_config_dir'))
  90. );
  91. }
  92. /**
  93. * Returns all application names.
  94. *
  95. * @return array An array of application names
  96. */
  97. protected function getApplications()
  98. {
  99. return sfFinder::type('dir')->maxdepth(0)->relative()->in(sfConfig::get('sf_apps_dir'));
  100. }
  101. }