本文整理汇总了PHP中Translatable::reading_lang方法的典型用法代码示例。如果您正苦于以下问题:PHP Translatable::reading_lang方法的具体用法?PHP Translatable::reading_lang怎么用?PHP Translatable::reading_lang使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Translatable
的用法示例。
在下文中一共展示了Translatable::reading_lang方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1:
/**
* Get a singleton instance of a class in the most convenient language (@see choose_site_lang())
*
* @param string $callerClass The name of the class
* @param string $filter A filter to be inserted into the WHERE clause.
* @param boolean $cache Use caching (default: false)
* @param string $orderby A sort expression to be inserted into the ORDER BY clause.
* @return DataObject
*/
static function get_one($callerClass, $filter = "", $cache = false, $orderby = "")
{
self::$language_decided = true;
self::$reading_lang = self::default_lang();
$record = DataObject::get_one($callerClass, $filter);
if (!$record) {
self::$bypass = true;
$record = DataObject::get_one($callerClass, $filter, $cache, $orderby);
self::$bypass = false;
if ($record) {
self::set_reading_lang($record->Lang);
}
} else {
$langsAvailable = (array) self::get_langs_by_id($callerClass, $record->ID);
$langsAvailable[] = self::default_lang();
$lang = self::choose_site_lang($langsAvailable);
if (isset($lang)) {
$transrecord = self::get_one_by_lang($callerClass, $lang, "`{$callerClass}`.ID = {$record->ID}");
if ($transrecord) {
self::set_reading_lang($lang);
$record = $transrecord;
}
}
}
return $record;
}