| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
abstract class sfApplicationConfiguration extends ProjectConfiguration |
|---|
| 20 |
{ |
|---|
| 21 |
static protected |
|---|
| 22 |
$coreLoaded = false; |
|---|
| 23 |
|
|---|
| 24 |
protected |
|---|
| 25 |
$configCache = null, |
|---|
| 26 |
$application = null, |
|---|
| 27 |
$environment = null, |
|---|
| 28 |
$debug = false, |
|---|
| 29 |
$config = array(); |
|---|
| 30 |
|
|---|
| 31 |
|
|---|
| 32 |
* Constructor. |
|---|
| 33 |
* |
|---|
| 34 |
* @param string $environment The environment name |
|---|
| 35 |
* @param Boolean $debug true to enable debug mode |
|---|
| 36 |
* @param string $rootDir The project root directory |
|---|
| 37 |
* @param sfEventDispatcher $dispatcher An event dispatcher |
|---|
| 38 |
*/ |
|---|
| 39 |
public function __construct($environment, $debug, $rootDir = null, sfEventDispatcher $dispatcher = null) |
|---|
| 40 |
{ |
|---|
| 41 |
$this->environment = $environment; |
|---|
| 42 |
$this->debug = (boolean) $debug; |
|---|
| 43 |
$this->application = str_replace('Configuration', '', get_class($this)); |
|---|
| 44 |
|
|---|
| 45 |
parent::__construct($rootDir, $dispatcher); |
|---|
| 46 |
|
|---|
| 47 |
$this->configure(); |
|---|
| 48 |
|
|---|
| 49 |
$this->initConfiguration(); |
|---|
| 50 |
|
|---|
| 51 |
if (sfConfig::get('sf_check_lock')) |
|---|
| 52 |
{ |
|---|
| 53 |
$this->checkLock(); |
|---|
| 54 |
} |
|---|
| 55 |
|
|---|
| 56 |
if (sfConfig::get('sf_check_symfony_version')) |
|---|
| 57 |
{ |
|---|
| 58 |
$this->checkSymfonyVersion(); |
|---|
| 59 |
} |
|---|
| 60 |
|
|---|
| 61 |
$this->initialize(); |
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 |
$this->config = sfConfig::getAll(); |
|---|
| 65 |
} |
|---|
| 66 |
|
|---|
| 67 |
|
|---|
| 68 |
* Configures the current configuration. |
|---|
| 69 |
* |
|---|
| 70 |
* Override this method if you want to customize your application configuration. |
|---|
| 71 |
*/ |
|---|
| 72 |
public function configure() |
|---|
| 73 |
{ |
|---|
| 74 |
} |
|---|
| 75 |
|
|---|
| 76 |
|
|---|
| 77 |
* Initialized the current configuration. |
|---|
| 78 |
* |
|---|
| 79 |
* Override this method if you want to customize your application initialization. |
|---|
| 80 |
*/ |
|---|
| 81 |
public function initialize() |
|---|
| 82 |
{ |
|---|
| 83 |
} |
|---|
| 84 |
|
|---|
| 85 |
public function activate() |
|---|
| 86 |
{ |
|---|
| 87 |
sfConfig::clear(); |
|---|
| 88 |
sfConfig::add($this->config); |
|---|
| 89 |
} |
|---|
| 90 |
|
|---|
| 91 |
|
|---|
| 92 |
* @see sfProjectConfiguration |
|---|
| 93 |
*/ |
|---|
| 94 |
public function initConfiguration() |
|---|
| 95 |
{ |
|---|
| 96 |
|
|---|
| 97 |
if ($this->isDebug() && !sfConfig::get('sf_timer_start')) |
|---|
| 98 |
{ |
|---|
| 99 |
sfConfig::set('sf_timer_start', microtime(true)); |
|---|
| 100 |
} |
|---|
| 101 |
|
|---|
| 102 |
$configCache = $this->getConfigCache(); |
|---|
| 103 |
|
|---|
| 104 |
|
|---|
| 105 |
if (!sfConfig::get('sf_debug') && !sfConfig::get('sf_test') && !self::$coreLoaded) |
|---|
| 106 |
{ |
|---|
| 107 |
$configCache->import('config/core_compile.yml', false); |
|---|
| 108 |
} |
|---|
| 109 |
|
|---|
| 110 |
sfAutoload::getInstance()->register(); |
|---|
| 111 |
|
|---|
| 112 |
|
|---|
| 113 |
include($configCache->checkConfig('config/settings.yml')); |
|---|
| 114 |
if ($file = $configCache->checkConfig('config/app.yml', true)) |
|---|
| 115 |
{ |
|---|
| 116 |
include($file); |
|---|
| 117 |
} |
|---|
| 118 |
|
|---|
| 119 |
if (false !== sfConfig::get('sf_csrf_secret')) |
|---|
| 120 |
{ |
|---|
| 121 |
sfForm::enableCSRFProtection(sfConfig::get('sf_csrf_secret')); |
|---|
| 122 |
} |
|---|
| 123 |
|
|---|
| 124 |
sfWidget::setCharset(sfConfig::get('sf_charset')); |
|---|
| 125 |
sfValidatorBase::setCharset(sfConfig::get('sf_charset')); |
|---|
| 126 |
|
|---|
| 127 |
|
|---|
| 128 |
if ($default_timezone = sfConfig::get('sf_default_timezone')) |
|---|
| 129 |
{ |
|---|
| 130 |
date_default_timezone_set($default_timezone); |
|---|
| 131 |
} |
|---|
| 132 |
else if (sfConfig::get('sf_force_default_timezone', true)) |
|---|
| 133 |
{ |
|---|
| 134 |
date_default_timezone_set(@date_default_timezone_get()); |
|---|
| 135 |
} |
|---|
| 136 |
|
|---|
| 137 |
|
|---|
| 138 |
ini_set('display_errors', $this->isDebug() ? 'on' : 'off'); |
|---|
| 139 |
error_reporting(sfConfig::get('sf_error_reporting')); |
|---|
| 140 |
|
|---|
| 141 |
|
|---|
| 142 |
$this->loadPluginConfig(); |
|---|
| 143 |
|
|---|
| 144 |
|
|---|
| 145 |
// If you want to enable it in your application, just copy the spl_autoload_register() line |
|---|
| 146 |
// in your configuration class. |
|---|
| 147 |
if (0 && $this->isDebug()) |
|---|
| 148 |
{ |
|---|
| 149 |
spl_autoload_register(array(sfAutoload::getInstance(), 'autoloadAgain')); |
|---|
| 150 |
} |
|---|
| 151 |
|
|---|
| 152 |
|
|---|
| 153 |
if (!self::$coreLoaded) |
|---|
| 154 |
{ |
|---|
| 155 |
ob_start(sfConfig::get('sf_compressed') ? 'ob_gzhandler' : ''); |
|---|
| 156 |
} |
|---|
| 157 |
|
|---|
| 158 |
self::$coreLoaded = true; |
|---|
| 159 |
} |
|---|
| 160 |
|
|---|
| 161 |
|
|---|
| 162 |
* Returns a configuration cache object for the current configuration. |
|---|
| 163 |
* |
|---|
| 164 |
* @return sfConfigCache A sfConfigCache instance |
|---|
| 165 |
*/ |
|---|
| 166 |
public function getConfigCache() |
|---|
| 167 |
{ |
|---|
| 168 |
if (is_null($this->configCache)) |
|---|
| 169 |
{ |
|---|
| 170 |
$this->configCache = new sfConfigCache($this); |
|---|
| 171 |
} |
|---|
| 172 |
|
|---|
| 173 |
return $this->configCache; |
|---|
| 174 |
} |
|---|
| 175 |
|
|---|
| 176 |
|
|---|
| 177 |
* Check lock files to see if we're not in a cache cleaning process. |
|---|
| 178 |
* |
|---|
| 179 |
* @return void |
|---|
| 180 |
*/ |
|---|
| 181 |
public function checkLock() |
|---|
| 182 |
{ |
|---|
| 183 |
if ( |
|---|
| 184 |
sfToolkit::hasLockFile(sfConfig::get('sf_data_dir').DIRECTORY_SEPARATOR.$this->getApplication().'_'.$this->getEnvironment().'-cli.lck', 5) |
|---|
| 185 |
|| |
|---|
| 186 |
sfToolkit::hasLockFile(sfConfig::get('sf_data_dir').DIRECTORY_SEPARATOR.$this->getApplication().'_'.$this->getEnvironment().'.lck') |
|---|
| 187 |
) |
|---|
| 188 |
{ |
|---|
| 189 |
|
|---|
| 190 |
$files = array( |
|---|
| 191 |
sfConfig::get('sf_app_config_dir').'/unavailable.php', |
|---|
| 192 |
sfConfig::get('sf_config_dir').'/unavailable.php', |
|---|
| 193 |
sfConfig::get('sf_web_dir').'/errors/unavailable.php', |
|---|
| 194 |
sfConfig::get('sf_symfony_lib_dir').'/exception/data/unavailable.php', |
|---|
| 195 |
); |
|---|
| 196 |
|
|---|
| 197 |
foreach ($files as $file) |
|---|
| 198 |
{ |
|---|
| 199 |
if (is_readable($file)) |
|---|
| 200 |
{ |
|---|
| 201 |
include $file; |
|---|
| 202 |
break; |
|---|
| 203 |
} |
|---|
| 204 |
} |
|---|
| 205 |
|
|---|
| 206 |
die(1); |
|---|
| 207 |
} |
|---|
| 208 |
} |
|---|
| 209 |
|
|---|
| 210 |
|
|---|
| 211 |
* Checks symfony version and clears cache if recent update. |
|---|
| 212 |
* |
|---|
| 213 |
* @return void |
|---|
| 214 |
*/ |
|---|
| 215 |
public function checkSymfonyVersion() |
|---|
| 216 |
{ |
|---|
| 217 |
|
|---|
| 218 |
if (SYMFONY_VERSION != @file_get_contents(sfConfig::get('sf_config_cache_dir').'/VERSION')) |
|---|
| 219 |
{ |
|---|
| 220 |
|
|---|
| 221 |
sfToolkit::clearDirectory(sfConfig::get('sf_config_cache_dir')); |
|---|
| 222 |
} |
|---|
| 223 |
} |
|---|
| 224 |
|
|---|
| 225 |
|
|---|
| 226 |
* Sets the project root directory. |
|---|
| 227 |
* |
|---|
| 228 |
* @param string $rootDir The project root directory |
|---|
| 229 |
*/ |
|---|
| 230 |
public function setRootDir($rootDir) |
|---|
| 231 |
{ |
|---|
| 232 |
parent::setRootDir($rootDir); |
|---|
| 233 |
|
|---|
| 234 |
sfConfig::add(array( |
|---|
| 235 |
'sf_app' => $this->getApplication(), |
|---|
| 236 |
'sf_environment' => $this->getEnvironment(), |
|---|
| 237 |
'sf_debug' => $this->isDebug(), |
|---|
| 238 |
)); |
|---|
| 239 |
|
|---|
| 240 |
$this->setAppDir(sfConfig::get('sf_apps_dir').DIRECTORY_SEPARATOR.$this->getApplication()); |
|---|
| 241 |
} |
|---|
| 242 |
|
|---|
| 243 |
|
|---|
| 244 |
* Sets the app directory. |
|---|
| 245 |
* |
|---|
| 246 |
* @param string $appDir The absolute path to the app dir. |
|---|
| 247 |
*/ |
|---|
| 248 |
public function setAppDir($appDir) |
|---|
| 249 |
{ |
|---|
| 250 |
sfConfig::add(array( |
|---|
| 251 |
'sf_app_dir' => $appDir, |
|---|
| 252 |
|
|---|
| 253 |
|
|---|
| 254 |
'sf_app_config_dir' => $appDir.DIRECTORY_SEPARATOR.'config', |
|---|
| 255 |
'sf_app_lib_dir' => $appDir.DIRECTORY_SEPARATOR.'lib', |
|---|
| 256 |
'sf_app_module_dir' => $appDir.DIRECTORY_SEPARATOR.'modules', |
|---|
| 257 |
'sf_app_template_dir' => $appDir.DIRECTORY_SEPARATOR.'templates', |
|---|
| 258 |
'sf_app_i18n_dir' => $appDir.DIRECTORY_SEPARATOR.'i18n', |
|---|
| 259 |
)); |
|---|
| 260 |
} |
|---|
| 261 |
|
|---|
| 262 |
|
|---|
| 263 |
* @see sfProjectConfiguration |
|---|
| 264 |
*/ |
|---|
| 265 |
public function setCacheDir($cacheDir) |
|---|
| 266 |
{ |
|---|
| 267 |
parent::setCacheDir($cacheDir); |
|---|
| 268 |
|
|---|
| 269 |
sfConfig::add(array( |
|---|
| 270 |
'sf_app_base_cache_dir' => $cacheDir.DIRECTORY_SEPARATOR.$this->getApplication(), |
|---|
| 271 |
'sf_app_cache_dir' => $appCacheDir = $cacheDir.DIRECTORY_SEPARATOR.$this->getApplication().DIRECTORY_SEPARATOR.$this->getEnvironment(), |
|---|
| 272 |
|
|---|
| 273 |
|
|---|
| 274 |
'sf_template_cache_dir' => $appCacheDir.DIRECTORY_SEPARATOR.'template', |
|---|
| 275 |
'sf_i18n_cache_dir' => $appCacheDir.DIRECTORY_SEPARATOR.'i18n', |
|---|
| 276 |
'sf_config_cache_dir' => $appCacheDir.DIRECTORY_SEPARATOR.'config', |
|---|
| 277 |
'sf_test_cache_dir' => $appCacheDir.DIRECTORY_SEPARATOR.'test', |
|---|
| 278 |
'sf_module_cache_dir' => $appCacheDir.DIRECTORY_SEPARATOR.'modules', |
|---|
| 279 |
)); |
|---|
| 280 |
} |
|---|
| 281 |
|
|---|
| 282 |
|
|---|
| 283 |
* Gets directories where controller classes are stored for a given module. |
|---|
| 284 |
* |
|---|
| 285 |
* @param string $moduleName The module name |
|---|
| 286 |
* |
|---|
| 287 |
* @return array An array of directories |
|---|
| 288 |
*/ |
|---|
| 289 |
public function getControllerDirs($moduleName) |
|---|
| 290 |
{ |
|---|
| 291 |
$dirs = array(); |
|---|
| 292 |
foreach (sfConfig::get('sf_module_dirs', array()) as $key => $value) |
|---|
| 293 |
{ |
|---|
| 294 |
$dirs[$key.'/'.$moduleName.'/actions'] = $value; |
|---|
| 295 |
} |
|---|
| 296 |
|
|---|
| 297 |
$dirs[sfConfig::get('sf_app_module_dir').'/'.$moduleName.'/actions'] = false; |
|---|
| 298 |
|
|---|
| 299 |
if ($pluginDirs = glob(sfConfig::get('sf_plugins_dir').'/*/modules/'.$moduleName.'/actions')) |
|---|
| 300 |
{ |
|---|
| 301 |
$dirs = array_merge($dirs, array_combine($pluginDirs, array_fill(0, count($pluginDirs), true))); |
|---|
| 302 |
} |
|---|
| 303 |
|
|---|
| 304 |
$dirs[sfConfig::get('sf_symfony_lib_dir').'/controller/'.$moduleName.'/actions'] = true; |
|---|
| 305 |
|
|---|
| 306 |
return $dirs; |
|---|
| 307 |
} |
|---|
| 308 |
|
|---|
| 309 |
|
|---|
| 310 |
* Gets directories where template files are stored for a given module. |
|---|
| 311 |
* |
|---|
| 312 |
* @param string $moduleName The module name |
|---|
| 313 |
* |
|---|
| 314 |
* @return array An array of directories |
|---|
| 315 |
*/ |
|---|
| 316 |
public function getTemplateDirs($moduleName) |
|---|
| 317 |
{ |
|---|
| 318 |
$dirs = array(); |
|---|
| 319 |
foreach (sfConfig::get('sf_module_dirs', array()) as $key => $value) |
|---|
| 320 |
{ |
|---|
| 321 |
$dirs[] = $key.'/'.$moduleName.'/templates'; |
|---|
| 322 |
} |
|---|
| 323 |
|
|---|
| 324 |
$dirs[] = sfConfig::get('sf_app_module_dir').'/'.$moduleName.'/templates'; |
|---|
| 325 |
|
|---|
| 326 |
if ($pluginDirs = glob(sfConfig::get('sf_plugins_dir').'/*/modules/'.$moduleName.'/templates')) |
|---|
| 327 |
{ |
|---|
| 328 |
$dirs = array_merge($dirs, $pluginDirs); |
|---|
| 329 |
} |
|---|
| 330 |
|
|---|
| 331 |
$dirs[] = sfConfig::get('sf_symfony_lib_dir').'/controller/'.$moduleName.'/templates'; |
|---|
| 332 |
$dirs[] = sfConfig::get('sf_module_cache_dir').'/auto'.ucfirst($moduleName.'/templates'); |
|---|
| 333 |
|
|---|
| 334 |
return $dirs; |
|---|
| 335 |
} |
|---|
| 336 |
|
|---|
| 337 |
|
|---|
| 338 |
* Gets the template directory to use for a given module and template file. |
|---|
| 339 |
* |
|---|
| 340 |
* @param string $moduleName The module name |
|---|
| 341 |
* @param string $templateFile The template file |
|---|
| 342 |
* |
|---|
| 343 |
* @return string A template directory |
|---|
| 344 |
*/ |
|---|
| 345 |
public function getTemplateDir($moduleName, $templateFile) |
|---|
| 346 |
{ |
|---|
| 347 |
foreach ($this->getTemplateDirs($moduleName) as $dir) |
|---|
| 348 |
{ |
|---|
| 349 |
if (is_readable($dir.'/'.$templateFile)) |
|---|
| 350 |
{ |
|---|
| 351 |
return $dir; |
|---|
| 352 |
} |
|---|
| 353 |
} |
|---|
| 354 |
|
|---|
| 355 |
return null; |
|---|
| 356 |
} |
|---|
| 357 |
|
|---|
| 358 |
|
|---|
| 359 |
* Gets the template to use for a given module and template file. |
|---|
| 360 |
* |
|---|
| 361 |
* @param string $moduleName The module name |
|---|
| 362 |
* @param string $templateFile The template file |
|---|
| 363 |
* |
|---|
| 364 |
* @return string A template path |
|---|
| 365 |
*/ |
|---|
| 366 |
public function getTemplatePath($moduleName, $templateFile) |
|---|
| 367 |
{ |
|---|
| 368 |
$dir = $this->getTemplateDir($moduleName, $templateFile); |
|---|
| 369 |
|
|---|
| 370 |
return $dir ? $dir.'/'.$templateFile : null; |
|---|
| 371 |
} |
|---|
| 372 |
|
|---|
| 373 |
|
|---|
| 374 |
* Gets the decorator directories. |
|---|
| 375 |
* |
|---|
| 376 |
* @return array An array of the decorator directories |
|---|
| 377 |
*/ |
|---|
| 378 |
public function getDecoratorDirs() |
|---|
| 379 |
{ |
|---|
| 380 |
return array(sfConfig::get('sf_app_template_dir')); |
|---|
| 381 |
} |
|---|
| 382 |
|
|---|
| 383 |
|
|---|
| 384 |
* Gets the decorator directory for a given template. |
|---|
| 385 |
* |
|---|
| 386 |
* @param string $template The template file |
|---|
| 387 |
* |
|---|
| 388 |
* @return string A template directory |
|---|
| 389 |
*/ |
|---|
| 390 |
public function getDecoratorDir($template) |
|---|
| 391 |
{ |
|---|
| 392 |
foreach ($this->getDecoratorDirs() as $dir) |
|---|
| 393 |
{ |
|---|
| 394 |
if (is_readable($dir.'/'.$template)) |
|---|
| 395 |
{ |
|---|
| 396 |
return $dir; |
|---|
| 397 |
} |
|---|
| 398 |
} |
|---|
| 399 |
} |
|---|
| 400 |
|
|---|
| 401 |
|
|---|
| 402 |
* Gets the i18n directories to use globally. |
|---|
| 403 |
* |
|---|
| 404 |
* @return array An array of i18n directories |
|---|
| 405 |
*/ |
|---|
| 406 |
public function getI18NGlobalDirs() |
|---|
| 407 |
{ |
|---|
| 408 |
$dirs = array(); |
|---|
| 409 |
|
|---|
| 410 |
|
|---|
| 411 |
if (is_dir($dir = sfConfig::get('sf_app_i18n_dir'))) |
|---|
| 412 |
{ |
|---|
| 413 |
$dirs[] = $dir; |
|---|
| 414 |
} |
|---|
| 415 |
|
|---|
| 416 |
|
|---|
| 417 |
if ($pluginDirs = glob(sfConfig::get('sf_plugins_dir').'/*/i18n')) |
|---|
| 418 |
{ |
|---|
| 419 |
$dirs = array_merge($dirs, $pluginDirs); |
|---|
| 420 |
} |
|---|
| 421 |
|
|---|
| 422 |
return $dirs; |
|---|
| 423 |
} |
|---|
| 424 |
|
|---|
| 425 |
|
|---|
| 426 |
* Gets the i18n directories to use for a given module. |
|---|
| 427 |
* |
|---|
| 428 |
* @param string $moduleName The module name |
|---|
| 429 |
* |
|---|
| 430 |
* @return array An array of i18n directories |
|---|
| 431 |
*/ |
|---|
| 432 |
public function getI18NDirs($moduleName) |
|---|
| 433 |
{ |
|---|
| 434 |
$dirs = array(); |
|---|
| 435 |
|
|---|
| 436 |
|
|---|
| 437 |
if (is_dir($dir = sfConfig::get('sf_app_module_dir').'/'.$moduleName.'/i18n')) |
|---|
| 438 |
{ |
|---|
| 439 |
$dirs[] = $dir; |
|---|
| 440 |
} |
|---|
| 441 |
|
|---|
| 442 |
|
|---|
| 443 |
if (is_dir($dir = sfConfig::get('sf_app_i18n_dir'))) |
|---|
| 444 |
{ |
|---|
| 445 |
$dirs[] = $dir; |
|---|
| 446 |
} |
|---|
| 447 |
|
|---|
| 448 |
|
|---|
| 449 |
if ($pluginDirs = glob(sfConfig::get('sf_plugins_dir').'/*/modules/'.$moduleName.'/i18n')) |
|---|
| 450 |
{ |
|---|
| 451 |
$dirs = array_merge($dirs, $pluginDirs); |
|---|
| 452 |
} |
|---|
| 453 |
|
|---|
| 454 |
|
|---|
| 455 |
if ($pluginDirs = glob(sfConfig::get('sf_plugins_dir').'/*/i18n')) |
|---|
| 456 |
{ |
|---|
| 457 |
$dirs = array_merge($dirs, $pluginDirs); |
|---|
| 458 |
} |
|---|
| 459 |
|
|---|
| 460 |
return $dirs; |
|---|
| 461 |
} |
|---|
| 462 |
|
|---|
| 463 |
|
|---|
| 464 |
* Gets the configuration file paths for a given relative configuration path. |
|---|
| 465 |
* |
|---|
| 466 |
* @param string $configPath The configuration path |
|---|
| 467 |
* |
|---|
| 468 |
* @return array An array of paths |
|---|
| 469 |
*/ |
|---|
| 470 |
public function getConfigPaths($configPath) |
|---|
| 471 |
{ |
|---|
| 472 |
$globalConfigPath = basename(dirname($configPath)).'/'.basename($configPath); |
|---|
| 473 |
|
|---|
| 474 |
$files = array( |
|---|
| 475 |
sfConfig::get('sf_symfony_lib_dir').'/config/'.$globalConfigPath, |
|---|
| 476 |
); |
|---|
| 477 |
|
|---|
| 478 |
if ($bundledPluginDirs = glob(sfConfig::get('sf_symfony_lib_dir').'/plugins/*/'.$globalConfigPath)) |
|---|
| 479 |
{ |
|---|
| 480 |
$files = array_merge($files, $bundledPluginDirs); |
|---|
| 481 |
} |
|---|
| 482 |
|
|---|
| 483 |
if ($pluginDirs = glob(sfConfig::get('sf_plugins_dir').'/*/'.$globalConfigPath)) |
|---|
| 484 |
{ |
|---|
| 485 |
$files = array_merge($files, $pluginDirs); |
|---|
| 486 |
} |
|---|
| 487 |
|
|---|
| 488 |
$files = array_merge($files, array( |
|---|
| 489 |
sfConfig::get('sf_root_dir').'/'.$globalConfigPath, |
|---|
| 490 |
sfConfig::get('sf_root_dir').'/'.$configPath, |
|---|
| 491 |
sfConfig::get('sf_app_dir').'/'.$globalConfigPath, |
|---|
| 492 |
sfConfig::get('sf_app_cache_dir').'/'.$configPath, |
|---|
| 493 |
)); |
|---|
| 494 |
|
|---|
| 495 |
if ($pluginDirs = glob(sfConfig::get('sf_plugins_dir').'/*/'.$configPath)) |
|---|
| 496 |
{ |
|---|
| 497 |
$files = array_merge($files, $pluginDirs); |
|---|
| 498 |
} |
|---|
| 499 |
|
|---|
| 500 |
$files[] = sfConfig::get('sf_app_dir').'/'.$configPath; |
|---|
| 501 |
|
|---|
| 502 |
$configs = array(); |
|---|
| 503 |
foreach (array_unique($files) as $file) |
|---|
| 504 |
{ |
|---|
| 505 |
if (is_readable($file)) |
|---|
| 506 |
{ |
|---|
| 507 |
$configs[] = $file; |
|---|
| 508 |
} |
|---|
| 509 |
} |
|---|
| 510 |
|
|---|
| 511 |
return $configs; |
|---|
| 512 |
} |
|---|
| 513 |
|
|---|
| 514 |
|
|---|
| 515 |
* Loads config.php files from plugins |
|---|
| 516 |
* |
|---|
| 517 |
* @return void |
|---|
| 518 |
*/ |
|---|
| 519 |
public function loadPluginConfig() |
|---|
| 520 |
{ |
|---|
| 521 |
foreach ($this->getPluginPaths() as $path) |
|---|
| 522 |
{ |
|---|
| 523 |
$config = $path.'/config/config.php'; |
|---|
| 524 |
if (is_readable($config)) |
|---|
| 525 |
{ |
|---|
| 526 |
require $config; |
|---|
| 527 |
} |
|---|
| 528 |
} |
|---|
| 529 |
} |
|---|
| 530 |
|
|---|
| 531 |
|
|---|
| 532 |
* Returns the application name. |
|---|
| 533 |
* |
|---|
| 534 |
* @return string The application name |
|---|
| 535 |
*/ |
|---|
| 536 |
public function getApplication() |
|---|
| 537 |
{ |
|---|
| 538 |
return $this->application; |
|---|
| 539 |
} |
|---|
| 540 |
|
|---|
| 541 |
|
|---|
| 542 |
* Returns the environment name. |
|---|
| 543 |
* |
|---|
| 544 |
* @return string The environment name |
|---|
| 545 |
*/ |
|---|
| 546 |
public function getEnvironment() |
|---|
| 547 |
{ |
|---|
| 548 |
return $this->environment; |
|---|
| 549 |
} |
|---|
| 550 |
|
|---|
| 551 |
|
|---|
| 552 |
* Returns true if this configuration has debug enabled. |
|---|
| 553 |
* |
|---|
| 554 |
* @return Boolean true if the configuration has debug enabled, false otherwise |
|---|
| 555 |
*/ |
|---|
| 556 |
public function isDebug() |
|---|
| 557 |
{ |
|---|
| 558 |
return $this->debug; |
|---|
| 559 |
} |
|---|
| 560 |
} |
|---|
| 561 |
|
|---|