本文整理匯總了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;
}