/** * Get config */ static function getConfig($var = false) { // check if config is already loaded $app = self::getApp(); if (isset($app->chclient->config)) { return $var ? $app->chclient->config->{$var} : $app->chclient->config; } // default config $config = (object) []; $registry = new Registry(); $config_fields = $registry->loadFile(JPATH_ROOT . '/components/com_chclient/config.yml', 'yaml'); foreach ($config_fields as $field => $properties) { $config->{$field} = $properties->value; } // get site config $site_config = json_decode(JFactory::getDbo()->setQuery('SELECT config FROM #__chclient_config AS a WHERE a.id = 1')->loadResult()); foreach ($config as $field => $p) { if (isset($site_config->{$field})) { $config->{$field} = $site_config->{$field}; } } // datepicker options $config->datepicker_min_date = CHLibDate::getDate()->format(CHLibDate::dateLocale()); $config->datepicker_format = str_replace('Y', 'YYYY', str_replace('m', 'MM', str_replace('d', 'DD', CHLibDate::dateLocale()))); // store config for later use $app->chclient->config = $config; return $var ? $app->chclient->config->{$var} : $app->chclient->config; }
/** * Load config. * * @return Registry Config registry object. */ public function loadConfig() { $file = WINDWALKER . '/config.json'; if (!is_file($file)) { \JFile::copy(WINDWALKER . '/config.dist.json', $file); } $config = new Registry(); return $config->loadFile($file, 'json'); }
/** * getTrackList * * @return Registry */ public function getTrackList() { $track = new Registry(); if (!file_exists($this->file)) { $buffer = file_get_contents($this->global); \JFile::write($this->file, $buffer); } $track->loadFile($this->file, 'yaml'); return $track; }
/** * checkout * * @param $profile * * @return bool * @throws \Exception */ public function checkout($profile) { $listModel = new ProfilesModel(); $profiles = $listModel->getList(); if (!in_array($profile, $profiles)) { throw new \Exception(sprintf('Profile "%s" not exists.', $name)); } $profileConfig = new Registry(); $file = JPATH_ROOT . '/tmp/sqlsync/config.yml'; $profileConfig->loadFile($file); $profileConfig->set('profile', $profile); $content = $profileConfig->toString('yaml'); if (!\JFile::write($file, $content)) { throw new \Exception('Writing profile config fail.'); } return true; }
/** * Test the Joomla\Registry\Registry::loadFile method. * * @return void * * @covers Joomla\Registry\Registry::loadFile * @since 1.0 */ public function testLoadFile() { $registry = new Registry(); // Result is always true, no error checking in method. // JSON. $result = $registry->loadFile(__DIR__ . '/Stubs/jregistry.json'); // Test getting a known value. $this->assertThat($registry->get('foo'), $this->equalTo('bar'), 'Line: ' . __LINE__ . '.'); // INI. $result = $registry->loadFile(__DIR__ . '/Stubs/jregistry.ini', 'ini'); // Test getting a known value. $this->assertThat($registry->get('foo'), $this->equalTo('bar'), 'Line: ' . __LINE__ . '.'); // INI + section. $result = $registry->loadFile(__DIR__ . '/Stubs/jregistry.ini', 'ini', array('processSections' => true)); // Checking result is self that we can chaining $this->assertEquals($result, $registry, '$result should be $registry self that support chaining'); // Test getting a known value. $this->assertThat($registry->get('section.foo'), $this->equalTo('bar'), 'Line: ' . __LINE__ . '.'); // XML and PHP versions do not support stringToObject. }
/** * Load default config */ private function defaultConfig() { $registry = new Registry(); return $registry->loadFile(JPATH_ROOT . '/components/com_chclient/config.yml', 'yaml'); }
/** * load * * @param string $type * * @return Registry */ public function load($type = 'yaml') { $schema = new Registry(); $schema->loadFile($this->getPath($type), $type); return $schema; }