function index_action() { $this->questions = Question::findAll($this->cid); if (Request::isXhr()) { $this->render_json(array_map(function ($q) { return $q->toJSON(); }, $this->questions)); } else { $this->setupStudipNavigation(); $this->short_url = $this->generateShortURL(); # now render template implicitly } }