if ($config->log) { /** * @see Conjoon_Log */ require_once 'Conjoon/Log.php'; // load Zend/Log for log constants so we don't have to // require this later on /** * @see Zend_Log */ require_once 'Zend/Log.php'; if (!Conjoon_Log::isConfigured()) { // we might have already configured the logger when // processing the configuration fle $cf = $config->toArray(); Conjoon_Log::init($cf['log']); } } // set as default adapter for all db operations Conjoon_Db_Table::setDefaultAdapter(Zend_Db::factory($config->database->adapter, array('host' => $config->database->params->host, 'username' => $config->database->params->username, 'password' => $config->database->params->password, 'dbname' => $config->database->params->dbname, 'port' => $config->database->params->port, 'driver_options' => array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES UTF8')))); // set tbl prefix Conjoon_Db_Table::setTablePrefix($config->database->table->prefix); // +------------------------------------------------------------------------ // | DOCTRINE // +------------------------------------------------------------------------ /** * @see Doctrine\ORM\Tools\Setup */ require_once 'Doctrine/ORM/Tools/Setup.php'; \Doctrine\ORM\Tools\Setup::registerAutoloadDirectory($LIBRARY_PATH_BOOTSTRAP . '/vendor/doctrine/'); /**
/** * @ticket CN-849 */ public function testIsConfigured() { $this->assertFalse(Conjoon_Log::isConfigured()); Conjoon_Log::init(array('enabled' => false)); $this->assertTrue(Conjoon_Log::isConfigured()); }
/** * Parses the configuration file and sets the include path if found in the * configuration file. * */ function conjoon_parseConfig() { // config failed to init, so we assume we have to load the config and parse it $initialConfig = parse_ini_file('./config.ini.php', true); // check if the library_path is set, and adjust the include_path if necessary if (($incPath = $initialConfig['environment']['include_path']) != null) { set_include_path(get_include_path() . PATH_SEPARATOR . $incPath); } // check whether we need the logging options if (isset($initialConfig['log']) && !$initialConfig['log']['enabled']) { unset($initialConfig['log']); } else { if (isset($initialConfig['log'])) { /** * @see Conjoon_Log */ include_once 'Conjoon/Log.php'; // load Zend/Log for log constants so we don't have to // require this later on /** * @see Zend_Log */ include_once 'Zend/Log.php'; Conjoon_Log::init($initialConfig['log']); } } /*@REMOVE@*/ // check whether we need the application.connection options if (isset($initialConfig['application']) && !$initialConfig['application']['connection_check.enabled']) { unset($initialConfig['application']['connection_check.ip']); unset($initialConfig['application']['connection_check.timeout']); unset($initialConfig['application']['connection_check.port']); } /*@REMOVE@*/ // take care of doctrine cache settings. make sure we void // caching if apc, memcache or memcached are selected, // but extensions are not loaded if (isset($initialConfig['application']) && isset($initialConfig['application']['doctrine.cache.enabled']) && $initialConfig['application']['doctrine.cache.enabled']) { $doctrineApp =& $initialConfig['application']; $doctrineTypes = array('metadata_cache', 'query_cache'); $disableDoctrineCache = true; foreach ($doctrineTypes as $doctrineCacheType) { $doctrineEnabledKey = 'doctrine.cache.' . $doctrineCacheType . '.enabled'; $doctrineCacheTypeKey = 'doctrine.cache.' . $doctrineCacheType . '.type'; if ($doctrineApp[$doctrineEnabledKey] && $doctrineApp[$doctrineCacheTypeKey] != 'file') { if (!extension_loaded($doctrineApp[$doctrineCacheTypeKey])) { $doctrineApp[$doctrineEnabledKey] = false; if ($initialConfig['log'] && $initialConfig['log']['enabled']) { Conjoon_Log::log("\"" . $doctrineApp[$doctrineCacheTypeKey] . "\" for " . "Doctrine Cache {$doctrineCacheType} selected, but " . "extension is not available", Zend_Log::WARN); } } else { // dont disable cache is extension was loaded $disableDoctrineCache = false; } } else { // dont disable cache if cache type is file $disableDoctrineCache = false; } } // disable doctrine cache if loading extensions for each setting failed $initialConfig['application']['doctrine.cache.enabled'] = $disableDoctrineCache ? 0 : 1; } // take care of default cache if (isset($initialConfig['cache'])) { if (!$initialConfig['cache']['default.caching']) { unset($initialConfig['cache']); } else { $defaults = array(); // extract defaults foreach ($initialConfig['cache'] as $key => $value) { if (strpos($key, 'default.') === 0) { $defaults[substr($key, 8)] = $initialConfig['cache'][$key]; unset($initialConfig['cache'][$key]); } } // get the cache namespaces $cacheBlocks =& $initialConfig['cache']; $namespaces = array(); $unsets = array(); foreach ($cacheBlocks as $key => $value) { $ns = explode(".", $key, 3); if (array_key_exists($ns[0] . '.' . $ns[1], $unsets)) { continue; } if ($ns[2] == 'caching' && !$value) { $unsets[$ns[0] . '.' . $ns[1]] = true; } else { $namespaces[$ns[0] . '.' . $ns[1]] = true; } } // first off, unset all cache blocks that have caching set to 0 foreach ($unsets as $key => $value) { foreach ($cacheBlocks as $ckey => $cvalue) { if (strpos($ckey, $key) === 0) { unset($cacheBlocks[$ckey]); } } } foreach ($namespaces as $key => $value) { foreach ($defaults as $defaultKey => $defaultValue) { $m = $key . '.' . $defaultKey; if (!array_key_exists($m, $cacheBlocks)) { $cacheBlocks[$m] = $defaultValue; } } // compute cache_dir backend HERE! // check whether the cache-dir for the backend options is relative or // absolute. This is a very simple check and may be error-prone, // but its okay for now $ck = $key . '.backend.cache_dir'; if (array_key_exists($ck, $cacheBlocks)) { $cacheDir = $cacheBlocks[$ck]; if (strpos($cacheDir, '/') !== 0 && strpos($cacheDir, ':') !== 1) { $cacheBlocks[$ck] = $initialConfig['environment']['application_path'] . DIRECTORY_SEPARATOR . $cacheDir; } } } } } // take care of files if (isset($initialConfig['files'])) { // get the cache namespaces $cacheBlocks =& $initialConfig['files']; $namespaces = array(); foreach ($cacheBlocks as $key => $value) { $ns = explode(".", $key, 4); if (!isset($ns[2])) { continue; } $namespaces[$ns[0] . '.' . $ns[1] . '.' . $ns[2]] = true; } foreach ($namespaces as $key => $value) { $ck = $key . '.dir'; if (array_key_exists($ck, $cacheBlocks)) { $cacheDir = $cacheBlocks[$ck]; if ($cacheDir && strpos($cacheDir, '/') !== 0 && strpos($cacheDir, ':') !== 1) { $cacheBlocks[$ck] = $initialConfig['environment']['application_path'] . DIRECTORY_SEPARATOR . $cacheDir; } } } } return $initialConfig; }