0
在我的模型回調函數afterFind後,我試圖找到一種方法從Controller獲取參數,根據該參數,我可以過濾結果並返回我想要的結果。CakePHP模型回調獲取參數傳遞從控制器
public function afterFind($results, $primary = false) {
$lang = $parameter; // I try to get the parameter here
$text_type = "text_eng";
if($lang == 'fra')
$text_type = "text_fra";
foreach ($results as $key => $val) {
$results[$key]['TextResource']['text'] = $val['TextResource'][$text_type];
}
return $results;
}
這可能嗎?請給我一個建議。感謝所有提前。
感謝您的迴應cewi,實際上,我正在使用mongodb,並且我不想更改db結構以支持多語言。你能告訴我怎麼把代碼放在一個地方,然後每當我在這個表格中找到數據時,它可以返回給我正確的語言。 –