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