本文整理汇总了PHP中XLite::getDefaultLanguage方法的典型用法代码示例。如果您正苦于以下问题:PHP XLite::getDefaultLanguage方法的具体用法?PHP XLite::getDefaultLanguage怎么用?PHP XLite::getDefaultLanguage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XLite
的用法示例。
在下文中一共展示了XLite::getDefaultLanguage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: addSortByTranslation
/**
* Add 'sort by name' builder structures
*
* @param \Doctrine\ORM\QueryBuilder $queryBuilder Query builder to prepare
* @param string $sort Sort field
* @param string $order Sort direction
*
* @return void
*/
protected function addSortByTranslation(\Doctrine\ORM\QueryBuilder $queryBuilder, $sort, $order)
{
// Main alias
$alias = $this->getMainAlias($queryBuilder);
// The language code of current user session
$currentCode = $this->getTranslationCode();
// Default store language code
$defaultCode = \XLite::getDefaultLanguage();
// Add additional join to translations with current language code
parent::addTranslationJoins($queryBuilder, $alias, 'st', $currentCode);
if ($currentCode != $defaultCode) {
// Add additional join to translations with default language code
$this->addTranslationJoins($queryBuilder, $alias, 'st2', $defaultCode);
// Add calculated field to the fields list to use this for sorting out
$queryBuilder->addSelect('IFNULL(st.name,IFNULL(st2.name,translations.name)) calculatedName');
} else {
// Add calculated field to the fields list to use this for sorting out
$queryBuilder->addSelect('IFNULL(st.name,translations.name) calculatedName');
}
}