Development

/branches/1.2/lib/task/project/sfProjectClearControllersTask.class.php

You must first sign up to be able to contribute.

root/branches/1.2/lib/task/project/sfProjectClearControllersTask.class.php

Revision 10582, 2.1 kB (checked in by nicolas, 6 years ago)

[1.2] backport of r10581 - fixed Boolean default values aren't rendered correctly with symfony's input form widget (refs #3996)

  • 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) 2004-2006 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  * Clears all non production environment controllers.
13  *
14  * @package    symfony
15  * @subpackage task
16  * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
17  * @version    SVN: $Id$
18  */
19 class sfProjectClearControllersTask extends sfBaseTask
20 {
21   /**
22    * @see sfTask
23    */
24   protected function configure()
25   {
26     $this->aliases = array('clear-controllers');
27     $this->namespace = 'project';
28     $this->name = 'clear-controllers';
29     $this->briefDescription = 'Clears all non production environment controllers';
30
31     $this->detailedDescription = <<<EOF
32 The [project:clear-controllers|INFO] task clears all non production environment
33 controllers:
34
35   [./symfony project:clear-controllers|INFO]
36
37 You can use this task on a production server to remove all front
38 controller scripts except the production ones.
39
40 If you have two applications named [frontend|COMMENT] and [backend|COMMENT],
41 you have four default controller scripts in [web/|COMMENT]:
42
43   [index.php
44   frontend_dev.php
45   backend.php
46   backend_dev.php|INFO]
47
48 After executing the [project:clear-controllers|COMMENT] task, two front
49 controller scripts are left in [web/|COMMENT]:
50
51   [index.php
52   backend.php|INFO]
53
54 Those two controllers are safe because debug mode and the web debug
55 toolbar are disabled.
56 EOF;
57   }
58
59   /**
60    * @see sfTask
61    */
62   protected function execute($arguments = array(), $options = array())
63   {
64     $finder = sfFinder::type('file')->maxdepth(1)->name('*.php');
65     foreach ($finder->in(sfConfig::get('sf_web_dir')) as $controller)
66     {
67       $content = file_get_contents($controller);
68
69       if (preg_match('/ProjectConfiguration::getApplicationConfiguration\(\'(.*?)\', \'(.*?)\'/', $content, $match))
70       {
71         // Remove file if it has found an application and the environment is not production
72         if ($match[2] != 'prod')
73         {
74           $this->getFilesystem()->remove($controller);
75         }
76       }
77     }
78   }
79 }
80
Note: See TracBrowser for help on using the browser.