パラメータ
の取り方は
$test = $this->params['test'];
みたいな形で取れるんだけど,これ配列から取ってるから,もしもこのパラメータがなかったらNoticeエラーが出る.
Notice: Undefined index: test in /www/projects/akelos/app/controllers/test_controller.php on line 14
これですね.
なので,基本的に存在チェックが必要.
$test = (isset($this->params['test']) ? $this->params['test'] : null;
これを毎回書くのはめんどくさいということで,application_controller.phpに
function get_param($key=null) { if (isset($key) && isset($this->params[$key])) { return $this->params[$key]; } }
みたいなメソッドを追加してみた.