/**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     if (1 == count($arguments['app']) && !file_exists(sfConfig::get('sf_apps_dir') . '/' . $arguments['app'][0])) {
         // support previous task signature
         $applications = array($arguments['env']);
         $env = $arguments['app'][0];
     } else {
         $applications = count($arguments['app']) ? $arguments['app'] : sfFinder::type('dir')->relative()->maxdepth(0)->in(sfConfig::get('sf_apps_dir'));
         $env = $arguments['env'];
     }
     foreach ($applications as $app) {
         $lockFile = sfConfig::get('sf_data_dir') . '/' . $app . '_' . $env . '.lck';
         if (!file_exists($lockFile)) {
             $this->logSection('enable', sprintf('%s [%s] is currently ENABLED', $app, $env));
         } else {
             $this->getFilesystem()->remove($lockFile);
             $clearCache = new sfCacheClearTask($this->dispatcher, $this->formatter);
             $clearCache->setCommandApplication($this->commandApplication);
             $clearCache->setConfiguration($this->configuration);
             $clearCache->run(array(), array('--app=' . $app, '--env=' . $env));
             $this->logSection('enable', sprintf('%s [%s] has been ENABLED', $app, $env));
         }
     }
 }
Exemplo n.º 2
0
<?php

/**
 * sfTaskExtraBaseTask tests.
 */
include dirname(__FILE__) . '/../../bootstrap/unit.php';
$task = new sfCacheClearTask($configuration->getEventDispatcher(), new sfFormatter());
$task->setConfiguration($configuration);
$t = new lime_test(5);
// ::doCheckPluginExists()
$t->diag('::doCheckPluginExists()');
try {
    sfTaskExtraBaseTask::doCheckPluginExists($task, 'NonexistantPlugin');
    $t->fail('::doCheckPluginExists() throws an exception if the plugin does not exist');
} catch (Exception $e) {
    $t->pass('::doCheckPluginExists() throws an exception if the plugin does not exist');
}
try {
    sfTaskExtraBaseTask::doCheckPluginExists($task, 'NonexistantPlugin', false);
    $t->pass('::doCheckPluginExists() does not throw an excpetion if a plugin does not exists and is passed false');
} catch (Exception $e) {
    $t->fail('::doCheckPluginExists() does not throw an excpetion if a plugin does not exists and is passed false');
    $t->diag('    ' . $e->getMessage());
}
try {
    sfTaskExtraBaseTask::doCheckPluginExists($task, 'StandardPlugin');
    $t->pass('::doCheckPluginExists() does not throw an exception if a plugin exists');
} catch (Exception $e) {
    $t->fail('::doCheckPluginExists() does not throw an exception if a plugin exists');
    $t->diag('    ' . $e->getMessage());
}