本文整理汇总了PHP中Joomla\Registry\Registry::loadFile方法的典型用法代码示例。如果您正苦于以下问题:PHP Registry::loadFile方法的具体用法?PHP Registry::loadFile怎么用?PHP Registry::loadFile使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Joomla\Registry\Registry
的用法示例。
在下文中一共展示了Registry::loadFile方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getConfig
/**
* 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;
}
示例2: loadConfig
/**
* 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');
}
示例3: getTrackList
/**
* 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;
}
示例4: checkout
/**
* 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;
}
示例5: testLoadFile
/**
* 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.
}
示例6: defaultConfig
/**
* Load default config
*/
private function defaultConfig()
{
$registry = new Registry();
return $registry->loadFile(JPATH_ROOT . '/components/com_chclient/config.yml', 'yaml');
}
示例7: load
/**
* load
*
* @param string $type
*
* @return Registry
*/
public function load($type = 'yaml')
{
$schema = new Registry();
$schema->loadFile($this->getPath($type), $type);
return $schema;
}