public function actionIndex() { // redirect to poll list $this->redirect($this->url('poll.index')); return; $html = Application::getTemplateEngine()->render('home/index.html', array('link' => $this->url('poll.index'))); echo $html; }
public function actionIndex() { // message for modelless controller if (empty($this->_modelName)) { echo get_class($this) . '->actionIndex(): controller without model'; return; } // get models list $app = Application::getInstance(); $items = Application::getEntityManager()->findAll(); // render model view (if it exists) or default view $html = Application::getTemplateEngine()->render(strtolower($this->_modelName) . '/index.html', array('items' => $items)); if ($html === null) { // fall to default index view $html = $app['templateEngine']->render('default/index.html', array('items' => $items, 'model' => $this->_modelName)); } echo $html; }
public function actionStat($id) { $poll = Poll::findById($id); // update statistic for all variants foreach ($poll->questions as $question) { foreach ($question->variants as $variant) { $variant->updateStat(); } } $pollObj = $poll->formStdObject(); $html = Application::getTemplateEngine()->render('poll/stat.html', array('poll' => $pollObj, 'indexUrl' => $this->url('poll.index'), 'showUrl' => $this->url('poll.show', array('id' => $poll->id)))); echo $html; }