Development

/branches/1.4/lib/task/project/sfProjectValidateTask.class.php

You must first sign up to be able to contribute.

root/branches/1.4/lib/task/project/sfProjectValidateTask.class.php

Revision 24610, 2.4 kB (checked in by FabianLange, 5 years ago)

[1.3, 1.4] added svn properties for project:validate task

  • Property svn:mime-type set to text/x-php
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
Line 
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  * Finds deprecated usage in a project.
13  *
14  * @package    symfony
15  * @subpackage task
16  * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
17  * @version    SVN: $Id$
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
Note: See TracBrowser for help on using the browser.