1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <?php
- class sfProjectClearControllersTask extends sfBaseTask
- {
-
- protected function configure()
- {
- $this->aliases = array('clear-controllers');
- $this->namespace = 'project';
- $this->name = 'clear-controllers';
- $this->briefDescription = 'Clears all non production environment controllers';
- $this->detailedDescription = <<<EOF
- The [project:clear-controllers|INFO] task clears all non production environment
- controllers:
- [./symfony project:clear-controllers|INFO]
- You can use this task on a production server to remove all front
- controller scripts except the production ones.
- If you have two applications named [frontend|COMMENT] and [backend|COMMENT],
- you have four default controller scripts in [web/|COMMENT]:
- [index.php
- frontend_dev.php
- backend.php
- backend_dev.php|INFO]
- After executing the [project:clear-controllers|COMMENT] task, two front
- controller scripts are left in [web/|COMMENT]:
- [index.php
- backend.php|INFO]
- Those two controllers are safe because debug mode and the web debug
- toolbar are disabled.
- EOF;
- }
-
- protected function execute($arguments = array(), $options = array())
- {
- $finder = sfFinder::type('file')->maxdepth(1)->name('*.php');
- foreach ($finder->in(sfConfig::get('sf_web_dir')) as $controller)
- {
- $content = file_get_contents($controller);
- if (preg_match('/ProjectConfiguration::getApplicationConfiguration\(\'(.*?)\', \'(.*?)\'/', $content, $match))
- {
-
- if ($match[2] != 'prod')
- {
- $this->getFilesystem()->remove($controller);
- }
- }
- }
- }
- }
|