private function midgard2Connect() { $filepath = ini_get('midgard.configuration_file'); $config = new \midgard_config(); $config->read_file_at_path($filepath); $mgd = \midgard_connection::get_instance(); if (!$mgd->open_config($config)) { throw new \PHPCR\RepositoryException($mgd->get_error_string()); } return $mgd; }
public function __construct() { if (ini_get('midgard.http') == 1) { throw new LogicException("midgard.http should be set to 'Off', while running via AiP"); } // opening connection $filepath = get_cfg_var("midgard.configuration_file"); $config = new midgard_config(); $config->read_file_at_path($filepath); $this->mgd = midgard_connection::get_instance(); $this->mgd->open_config($config); // starting mvc $application_config = get_cfg_var('midgardmvc.application_config'); if (!$application_config) { $application_config = MIDGARDMVC_ROOT . '/application.yml'; } $mvc = midgardmvc_core::get_instance($application_config); }
protected function _load_config() { if (getenv('MIDCOM_MIDGARD_CONFIG_FILE')) { $config_file = getenv('MIDCOM_MIDGARD_CONFIG_FILE'); } else { $config_file = $this->_get_basedir() . "/config/midgard2.ini"; } if (file_exists($config_file)) { $this->_io->write('Using config file found at <info>' . $config_file . '</info>'); $config = new \midgard_config(); if (!$config->read_file_at_path($config_file)) { throw new \Exception('Could not read config file ' . $config_file); } } else { $config = $this->_create_config($config_file); } return $config; }
/** * Setup file for running unit tests * * Usage: phpunit --no-globals-backup ./ */ $mgd_defaults = array('argv' => array(), 'user' => 0, 'admin' => false, 'root' => false, 'auth' => false, 'cookieauth' => false, 'page' => 0, 'debug' => false, 'self' => '/', 'prefix' => '', 'host' => 0, 'style' => 0, 'author' => 0, 'config' => array('prefix' => '', 'quota' => false, 'unique_host_name' => 'openpsa', 'auth_cookie_id' => 1), 'schema' => array('types' => array())); $GLOBALS['midcom_config_local'] = array(); // Check that the environment is a working one if (extension_loaded('midgard2')) { $GLOBALS['midcom_config_local']['person_class'] = 'openpsa_person'; // Open connection $midgard = midgard_connection::get_instance(); // Workaround for https://github.com/midgardproject/midgard-php5/issues/49 if (!$midgard->is_connected() && ($path = ini_get('midgard.configuration_file'))) { $config = new midgard_config(); $config->read_file_at_path($path); $midgard->open_config($config); } // if we still can't connect to a DB, we'll create a new one if (!$midgard->is_connected()) { $config = new midgard_config(); $config->dbtype = 'SQLite'; $config->database = 'openpsa_test'; $config->blobdir = OPENPSA_TEST_ROOT . '__output/blobs'; $config->logfilename = OPENPSA_TEST_ROOT . '__output/midgard2.log'; $config->tablecreate = true; $config->tableupdate = true; $config->loglevel = 'warn'; if (!$midgard->open_config($config)) { throw new Exception('Could not open Midgard connection to test database: ' . $midgard->get_error_string()); }
<?php $GLOBALS['midcom_config_local'] = array(); // Check that the environment is a working one if (extension_loaded('midgard2')) { if (!class_exists('midgard_topic')) { throw new Exception('You need to install OpenPSA MgdSchemas from the "schemas" directory to the Midgard2 schema directory'); } // Initialize the $_MIDGARD superglobal $_MIDGARD = array('argv' => array(), 'user' => 0, 'admin' => false, 'root' => false, 'auth' => false, 'cookieauth' => false, 'page' => 0, 'debug' => false, 'host' => 0, 'style' => 0, 'author' => 0, 'config' => array('prefix' => '', 'quota' => false, 'unique_host_name' => 'openpsa', 'auth_cookie_id' => 1), 'schema' => array()); $GLOBALS['midcom_config_local']['person_class'] = 'openpsa_person'; $midgard = midgard_connection::get_instance(); // Workaround for https://github.com/midgardproject/midgard-php5/issues/49 if (!$midgard->is_connected()) { $config = new midgard_config(); $config->read_file_at_path(ini_get('midgard.configuration_file')); $midgard->open_config($config); } if (method_exists($midgard, 'enable_workspace')) { $midgard->enable_workspace(false); } // workaround for segfaults that might have something to do with https://bugs.php.net/bug.php?id=51091 // see also https://github.com/midgardproject/midgard-php5/issues/50 if (function_exists('gc_enabled') && gc_enabled()) { gc_disable(); } } else { if (!extension_loaded('midgard')) { throw new Exception("OpenPSA requires Midgard PHP extension to run"); } }