| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
class sfValidateTask extends sfBaseTask |
|---|
| 20 |
{ |
|---|
| 21 |
|
|---|
| 22 |
* @see sfTask |
|---|
| 23 |
*/ |
|---|
| 24 |
protected function configure() |
|---|
| 25 |
{ |
|---|
| 26 |
$this->namespace = 'project'; |
|---|
| 27 |
$this->name = 'validate'; |
|---|
| 28 |
$this->briefDescription = 'Finds deprecated usage in a project'; |
|---|
| 29 |
|
|---|
| 30 |
$this->detailedDescription = <<<EOF |
|---|
| 31 |
The [project:validate|INFO] task detects deprecated usage in your project. |
|---|
| 32 |
|
|---|
| 33 |
[./symfony project:validate|INFO] |
|---|
| 34 |
|
|---|
| 35 |
The task lists all the files you need to change before switching to |
|---|
| 36 |
symfony 1.4. |
|---|
| 37 |
EOF; |
|---|
| 38 |
} |
|---|
| 39 |
|
|---|
| 40 |
|
|---|
| 41 |
* @see sfTask |
|---|
| 42 |
*/ |
|---|
| 43 |
protected function execute($arguments = array(), $options = array()) |
|---|
| 44 |
{ |
|---|
| 45 |
foreach ($this->getUpgradeClasses() as $i => $class) |
|---|
| 46 |
{ |
|---|
| 47 |
$v = new $class($this->dispatcher, $this->formatter); |
|---|
| 48 |
|
|---|
| 49 |
$this->logBlock(($i + 1).'. '.$v->getHeader(), 'QUESTION_LARGE'); |
|---|
| 50 |
|
|---|
| 51 |
$v->setCommandApplication($this->commandApplication); |
|---|
| 52 |
$v->setConfiguration($this->configuration); |
|---|
| 53 |
$files = $v->validate(); |
|---|
| 54 |
|
|---|
| 55 |
if (!$files) |
|---|
| 56 |
{ |
|---|
| 57 |
$this->log(' '.$this->formatter->format(' OK ', 'INFO')); |
|---|
| 58 |
|
|---|
| 59 |
continue; |
|---|
| 60 |
} |
|---|
| 61 |
|
|---|
| 62 |
$this->log(' '.$this->formatter->format(' '.count($files).' file(s) need to be changed. ', 'ERROR')); |
|---|
| 63 |
|
|---|
| 64 |
foreach ($files as $file => $value) |
|---|
| 65 |
{ |
|---|
| 66 |
$this->log(' '.$this->formatter->format($this->formatFile($file), 'INFO')); |
|---|
| 67 |
|
|---|
| 68 |
if (true !== $value) |
|---|
| 69 |
{ |
|---|
| 70 |
$this->log(' '.$value); |
|---|
| 71 |
} |
|---|
| 72 |
} |
|---|
| 73 |
|
|---|
| 74 |
$this->log($v->getExplanation()); |
|---|
| 75 |
} |
|---|
| 76 |
} |
|---|
| 77 |
|
|---|
| 78 |
protected function formatFile($file) |
|---|
| 79 |
{ |
|---|
| 80 |
return str_replace(realpath(sfConfig::get('sf_root_dir')), 'ROOT', realpath($file)); |
|---|
| 81 |
} |
|---|
| 82 |
|
|---|
| 83 |
protected function getUpgradeClasses() |
|---|
| 84 |
{ |
|---|
| 85 |
$baseDir = dirname(__FILE__).'/validation/'; |
|---|
| 86 |
$classes = array(); |
|---|
| 87 |
|
|---|
| 88 |
foreach (glob($baseDir.'*.class.php') as $file) |
|---|
| 89 |
{ |
|---|
| 90 |
$class = str_replace(array($baseDir, '.class.php'), '', $file); |
|---|
| 91 |
|
|---|
| 92 |
if ('sfValidation' != $class) |
|---|
| 93 |
{ |
|---|
| 94 |
$classes[] = $class; |
|---|
| 95 |
|
|---|
| 96 |
require_once $baseDir.$class.'.class.php'; |
|---|
| 97 |
} |
|---|
| 98 |
} |
|---|
| 99 |
|
|---|
| 100 |
return $classes; |
|---|
| 101 |
} |
|---|
| 102 |
} |
|---|
| 103 |
|
|---|