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