Exemplo n.º 1
0
 public function getDefinition()
 {
     $path = $this->basePath . DIRECTORY_SEPARATOR . $this->definitionName;
     if (!is_file($path) || !is_readable($path)) {
         throw new RuntimeException('The upgrade base path doesn\'t have a definition file for upgrading (' . $path . ')');
     }
     return sfSimpleYamlConfigHandler::replaceConstants(sfSimpleYamlConfigHandler::getConfiguration(array($path)));
 }
Exemplo n.º 2
0
 public static function getPluginListForDatabase()
 {
     $config = sfSimpleYamlConfigHandler::getConfiguration(array(sfConfig::get('sf_root_dir') . '/config/databases.yml'));
     if (isset($config['all']['master'])) {
         $connConfig = $config['all']['master']['param'];
     } elseif (isset($config['all']['doctrine'])) {
         $connConfig = $config['all']['doctrine']['param'];
     } else {
         $connConfig = array_shift($config['all']);
         $connConfig = $connConfig['param'];
     }
     $connConfig = array_merge(array('password' => null), $connConfig);
     $result = array();
     try {
         $conn = new PDO($connConfig['dsn'], $connConfig['username'], $connConfig['password']);
         $state = $conn->query('SELECT name, is_enabled FROM ' . sfConfig::get('op_table_prefix', '') . 'plugin');
         if ($state) {
             foreach ($state as $row) {
                 $result[$row['name']] = (bool) $row['is_enabled'];
             }
         }
     } catch (PDOException $e) {
         // do nothing
     }
     return $result;
 }
<?php

/*
 * 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';
$t = new lime_test(2);
$config = new sfSimpleYamlConfigHandler();
$config->initialize();
$dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR . 'sfSimpleYamlConfigHandler' . DIRECTORY_SEPARATOR;
$array = get_retval($config, array($dir . 'config.yml'));
$t->is($array['article']['title'], 'foo', '->execute() returns configuration file as an array');
$array = get_retval($config, array($dir . 'config.yml', $dir . 'config_bis.yml'));
$t->is($array['article']['title'], 'bar', '->execute() returns configuration file as an array');
function get_retval($config, $files)
{
    $retval = $config->execute($files);
    $retval = preg_replace('#^<\\?php#', '', $retval);
    $retval = preg_replace('#<\\?php$#s', '', $retval);
    return eval($retval);
}