PageRenderTime 50ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/oiserver/lib/symfony/task/project/validation/sfValidation.class.php

http://openirudi.googlecode.com/
PHP | 116 lines | 57 code | 12 blank | 47 comment | 0 complexity | 77875b048920fa3cd565d3f03e024624 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) 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 validation 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 sfValidation extends sfBaseTask
  18. {
  19. protected
  20. $task = null;
  21. /**
  22. * Validates the current project.
  23. */
  24. abstract public function validate();
  25. abstract public function getHeader();
  26. public function execute($arguments = array(), $options = array())
  27. {
  28. throw new sfException('You can\'t execute this task.');
  29. }
  30. /**
  31. * Returns a finder that exclude upgrade scripts from being upgraded!
  32. *
  33. * @param string $type String directory or file or any (for both file and directory)
  34. *
  35. * @return sfFinder A sfFinder instance
  36. */
  37. protected function getFinder($type)
  38. {
  39. return sfFinder::type($type)->prune('symfony')->discard('symfony');
  40. }
  41. /**
  42. * Returns all project directories where you can put PHP classes.
  43. */
  44. protected function getProjectClassDirectories()
  45. {
  46. return array_merge(
  47. $this->getProjectLibDirectories(),
  48. $this->getProjectActionDirectories()
  49. );
  50. }
  51. /**
  52. * Returns all project directories where you can put templates.
  53. */
  54. protected function getProjectTemplateDirectories()
  55. {
  56. return array_merge(
  57. glob(sfConfig::get('sf_apps_dir').'/*/modules/*/templates'),
  58. glob(sfConfig::get('sf_apps_dir').'/*/templates')
  59. );
  60. }
  61. /**
  62. * Returns all project directories where you can put actions and components.
  63. */
  64. protected function getProjectActionDirectories()
  65. {
  66. return glob(sfConfig::get('sf_apps_dir').'/*/modules/*/actions');
  67. }
  68. /**
  69. * Returns all project lib directories.
  70. *
  71. * @param string $subdirectory A subdirectory within lib (i.e. "/form")
  72. */
  73. protected function getProjectLibDirectories($subdirectory = null)
  74. {
  75. return array_merge(
  76. glob(sfConfig::get('sf_apps_dir').'/*/modules/*/lib'.$subdirectory),
  77. glob(sfConfig::get('sf_apps_dir').'/*/lib'.$subdirectory),
  78. array(
  79. sfConfig::get('sf_apps_dir').'/lib'.$subdirectory,
  80. sfConfig::get('sf_lib_dir').$subdirectory,
  81. )
  82. );
  83. }
  84. /**
  85. * Returns all project config directories.
  86. */
  87. protected function getProjectConfigDirectories()
  88. {
  89. return array_merge(
  90. glob(sfConfig::get('sf_apps_dir').'/*/modules/*/config'),
  91. glob(sfConfig::get('sf_apps_dir').'/*/config'),
  92. glob(sfConfig::get('sf_config_dir'))
  93. );
  94. }
  95. /**
  96. * Returns all application names.
  97. *
  98. * @return array An array of application names
  99. */
  100. protected function getApplications()
  101. {
  102. return sfFinder::type('dir')->maxdepth(0)->relative()->in(sfConfig::get('sf_apps_dir'));
  103. }
  104. }