/**
  * Executes this configuration handler.
  *
  * @param array An array of absolute filesystem path to a configuration file
  *
  * @return string Data to be written to a cache file
  */
 public function execute($configFiles)
 {
     $data = parent::execute($configFiles);
     if ($this->enabled) {
         $data .= "\n\$logger = sfLogger::getInstance();\n";
         // log level
         $data .= "\$logger->setLogLevel(constant('SF_LOG_'.strtoupper(sfConfig::get('sf_logging_level'))));\n";
         // register loggers defined in the logging.yml configuration file
         foreach ($this->loggers as $name => $keys) {
             if (isset($keys['enabled']) && !$keys['enabled']) {
                 continue;
             }
             if (!isset($keys['class'])) {
                 // missing class key
                 throw new sfParseException(sprintf('Configuration file "%s" specifies filter "%s" with missing class key', $configFiles[0], $name));
             }
             $condition = true;
             if (isset($keys['param']['condition'])) {
                 $condition = $this->replaceConstants($keys['param']['condition']);
                 unset($keys['param']['condition']);
             }
             if ($condition) {
                 // parse parameters
                 $parameters = isset($keys['param']) ? var_export($keys['param'], true) : '';
                 // create logger instance
                 $data .= sprintf("\n\$log = new %s();\n\$log->initialize(%s);\n\$logger->registerLogger(\$log);\n", $keys['class'], $parameters);
             }
         }
     }
     return $data;
 }
 * This file is part of the symfony package.
 * (c) 2004-2006 Fabien Potencier <*****@*****.**>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

require_once(dirname(__FILE__).'/../../bootstrap/unit.php');

sfConfig::set('sf_symfony_lib_dir', realpath(dirname(__FILE__).'/../../../lib'));

$t = new lime_test(1);

// prefix
$handler = new sfDefineEnvironmentConfigHandler();
$handler->initialize(array('prefix' => 'sf_'));

$dir = dirname(__FILE__).DIRECTORY_SEPARATOR.'fixtures'.DIRECTORY_SEPARATOR.'sfDefineEnvironmentConfigHandler'.DIRECTORY_SEPARATOR;

$files = array(
  $dir.'prefix_default.yml',
  $dir.'prefix_all.yml',
);

sfConfig::set('sf_environment', 'prod');

$data = $handler->execute($files);
$data = preg_replace('#date\: \d+/\d+/\d+ \d+\:\d+\:\d+#', '', $data);

$t->is($data, str_replace("\r\n", "\n", file_get_contents($dir.'prefix_result.php')));