public function setUp() { parent::setUp(); parent::setUpBeforeClass(); $this->saveFactoryState(); SHFactory::$config = null; }
public function setUp() { // Clear the static config from factory SHFactory::$config = null; // Create some files fwrite(fopen(static::ENCRYPTION_KEY_FILE, 'w'), 'ym0ZBkTbDbYrQzjMM7COYnLYuArlq31UIfDyBj11gpeeVLlXeGYPQ7Qf71TPDlN8dVWQfsFbf5SteVXoNzQeiH3EHMFjQtyvmtDNv6kAqUa0Bc7r8QdN5H7VQXtARk1uYCwBqi4sYm1rRaUOJqDCRL64bj4ykeqyouPw8CscmK0hnikpQWSL9MKtJjNyathdSx3rVWE4YiIrgij8ELGjELwl7JQrztCSLAbRfQJafAQ6xGXUDRslRK4T4w2vtBMb'); TestsHelper::createPlatformConfigFile(1, static::PLATFORM_CONFIG_FILE); TestsHelper::createLdapConfigFile(214, static::LDAP_CONFIG_FILE); }
public function setUp() { // Clear the static config from factory SHFactory::$config = null; SHFactory::$ldap = null; // Create some files TestsHelper::createPlatformConfigFile(1, static::PLATFORM_CONFIG_FILE); TestsHelper::createLdapConfigFile(214, static::LDAP_CONFIG_FILE); parent::setUp(); }
/** * Restores the Factory pointers * * @return void */ protected function restoreFactoryState() { JFactory::$application = $this->savedFactoryState['application']; JFactory::$config = $this->savedFactoryState['config']; JFactory::$session = $this->savedFactoryState['session']; JFactory::$language = $this->savedFactoryState['language']; JFactory::$document = $this->savedFactoryState['document']; JFactory::$acl = $this->savedFactoryState['acl']; JFactory::$database = $this->savedFactoryState['database']; JFactory::$mailer = $this->savedFactoryState['mailer']; SHFactory::$config = $this->savedFactoryState['shconfig']; SHFactory::$dispatcher = $this->savedFactoryState['shdispatcher']; }
/** * Gets the configuration options for the platform. * * @param string $type The type of configuration (i.e. sql, file). * @param array $options An array of options (handler=>[Database Object], * table=>[Database Table], file=>[path to file], namespace=>[Namespace of Class]). * * @return JRegistry Registry of the configuration options. * * @since 2.0 */ public static function getConfig($type = 'sql', $options = array()) { if (!isset(self::$config)) { if ($type === 'sql') { $options['handler'] = isset($options['handler']) ? $options['handler'] : null; if (!isset($options['table'])) { // Uses the default table name $options['table'] = '#__sh_config'; } // Retrieve the platform config via cached SQL $cache = JFactory::getCache('shplatform', 'callback'); self::$config = $cache->get(array(__CLASS__, 'createDBConfig'), array($options['handler'], $options['table']), null); } elseif ($type === 'file') { if (!isset($options['file'])) { // Attempt to use a default file $options['file'] = JPATH_ROOT . '/sh_configuration.php'; } if (!isset($options['namespace'])) { // Attempt to use a default file $options['namespace'] = null; } // Retrieve the platform config via PHP file self::$config = self::createFileConfig($options['file'], $options['namespace']); } } return self::$config; }
/** * Gets the configuration options for the platform. * * @param string $type The type of configuration (i.e. sql, file). * @param array $options An array of options (handler=>[Database Object], * table=>[Database Table], file=>[path to file], namespace=>[Namespace of Class]). * * @return JRegistry Registry of the configuration options. * * @since 2.0 */ public static function getConfig($type = 'sql', $options = array()) { if (!isset(self::$config)) { if ($type === 'sql') { if (!isset($options['handler'])) { // Uses the default Joomla database object $options['handler'] = JFactory::getDbo(); } if (!isset($options['table'])) { // Uses the default table name $options['table'] = '#__sh_config'; } // Retrieve the platform config via SQL self::$config = self::createDBConfig($options['handler'], $options['table']); } elseif ($type === 'file') { if (!isset($options['file'])) { // Attempt to use a default file $options['file'] = JPATH_ROOT . '/sh_configuration.php'; } if (!isset($options['namespace'])) { // Attempt to use a default file $options['namespace'] = null; } // Retrieve the platform config via PHP file self::$config = self::createFileConfig($options['file'], $options['namespace']); } } return self::$config; }