1. sfValidation.class.php
  2. /** * Abstract class for validation classes. * * @package symfony * @subpackage task * @author Fabien Potencier * @version SVN: $Id: sfValidation.class.php 24610 2009-11-30 22:07:34Z FabianLange $ */
  3. abstract class sfValidation extends sfBaseTask
  4. {
  5. protected
  6. $task = null;
  7. /**
  8. * Validates the current project.
  9. */
  10. abstract public function validate();
  11. abstract public function getHeader();
  12. public function execute($arguments = array(), $options = array())
  13. {
  14. throw new sfException('You can\'t execute this task.');
  15. }
  16. /**
  17. * Returns a finder that exclude upgrade scripts from being upgraded!
  18. *
  19. * @param string $type String directory or file or any (for both file and directory)
  20. *
  21. * @return sfFinder A sfFinder instance
  22. */
  23. protected function getFinder($type)
  24. {
  25. return sfFinder::type($type)->prune('symfony')->discard('symfony');
  26. }
  27. /**
  28. * Returns all project directories where you can put PHP classes.
  29. */
  30. protected function getProjectClassDirectories()
  31. {
  32. return array_merge(
  33. $this->getProjectLibDirectories(),
  34. $this->getProjectActionDirectories()
  35. );
  36. }
  37. /**
  38. * Returns all project directories where you can put templates.
  39. */
  40. protected function getProjectTemplateDirectories()
  41. {
  42. return array_merge(
  43. glob(sfConfig::get('sf_apps_dir').'/*/modules/*/templates'),
  44. glob(sfConfig::get('sf_apps_dir').'/*/templates')
  45. );
  46. }
  47. /**
  48. * Returns all project directories where you can put actions and components.
  49. */
  50. protected function getProjectActionDirectories()
  51. {
  52. return glob(sfConfig::get('sf_apps_dir').'/*/modules/*/actions');
  53. }
  54. /**
  55. * Returns all project lib directories.
  56. *
  57. * @param string $subdirectory A subdirectory within lib (i.e. "/form")
  58. */
  59. protected function getProjectLibDirectories($subdirectory = null)
  60. {
  61. return array_merge(
  62. glob(sfConfig::get('sf_apps_dir').'/*/modules/*/lib'.$subdirectory),
  63. glob(sfConfig::get('sf_apps_dir').'/*/lib'.$subdirectory),
  64. array(
  65. sfConfig::get('sf_apps_dir').'/lib'.$subdirectory,
  66. sfConfig::get('sf_lib_dir').$subdirectory,
  67. )
  68. );
  69. }
  70. /**
  71. * Returns all project config directories.
  72. */
  73. protected function getProjectConfigDirectories()
  74. {
  75. return array_merge(
  76. glob(sfConfig::get('sf_apps_dir').'/*/modules/*/config'),
  77. glob(sfConfig::get('sf_apps_dir').'/*/config'),
  78. glob(sfConfig::get('sf_config_dir'))
  79. );
  80. }
  81. /**
  82. * Returns all application names.
  83. *
  84. * @return array An array of application names
  85. */
  86. protected function getApplications()
  87. {
  88. return sfFinder::type('dir')->maxdepth(0)->relative()->in(sfConfig::get('sf_apps_dir'));
  89. }
  90. }

Debug toolbar