本文整理汇总了PHP中SiteConfig::hasExtension方法的典型用法代码示例。如果您正苦于以下问题:PHP SiteConfig::hasExtension方法的具体用法?PHP SiteConfig::hasExtension怎么用?PHP SiteConfig::hasExtension使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SiteConfig
的用法示例。
在下文中一共展示了SiteConfig::hasExtension方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: SiteConfig
/**
* Create SiteConfig with defaults from language file.
* if Translatable is enabled on SiteConfig, see if one already exist
* and use those values for the translated defaults.
*
* @param string $locale
* @return SiteConfig
*/
static function make_site_config($locale = null)
{
if (!$locale) {
$locale = Translatable::get_current_locale();
}
$siteConfig = new SiteConfig();
$siteConfig->Title = _t('SiteConfig.SITENAMEDEFAULT', "Your Site Name");
$siteConfig->Tagline = _t('SiteConfig.TAGLINEDEFAULT', "your tagline here");
if ($siteConfig->hasExtension('Translatable')) {
$defaultConfig = DataObject::get_one('SiteConfig');
if ($defaultConfig) {
$siteConfig->Title = $defaultConfig->Title;
$siteConfig->Tagline = $defaultConfig->Tagline;
}
// TODO Copy view/edit group settings
// set the correct Locale
$siteConfig->Locale = $locale;
}
$siteConfig->write();
return $siteConfig;
}
示例2: SiteConfig
/**
* Create SiteConfig with defaults from language file.
* if Translatable is enabled on SiteConfig, see if one already exist
* and use those values for the translated defaults.
*
* @param string $locale
* @return SiteConfig
*/
static function make_site_config($locale = null)
{
if (class_exists('Translatable') && !$locale) {
$locale = Translatable::get_current_locale();
}
$siteConfig = new SiteConfig();
$siteConfig->Title = _t('SiteConfig.SITENAMEDEFAULT', "Your Site Name");
$siteConfig->Tagline = _t('SiteConfig.TAGLINEDEFAULT', "your tagline here");
if (class_exists('Translatable') && $siteConfig->hasExtension('Translatable')) {
Translatable::disable_locale_filter();
$defaultConfig = SiteConfig::get()->first();
Translatable::enable_locale_filter();
if ($defaultConfig) {
return $defaultConfig->createTranslation($locale);
}
// TODO Copy view/edit group settings
// set the correct Locale
$siteConfig->Locale = $locale;
}
$siteConfig->write();
return $siteConfig;
}