Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- use Nette\Application\AppForm;
- use Nette\Application\Control;
- use Nette\Environment;
- class Questions extends Control
- {
- const YES = 'yes';
- const NO = 'no';
- /** @var array */
- private $questions;
- public function setQuestions(array $questions)
- {
- $this->questions = $questions;
- }
- public function render()
- {
- $template = $this->getTemplate();
- $template->setFile(__DIR__ . '/questions.latte');
- $template->questions = $this->questions;
- $template->answered = Environment::getSession('questions');
- $template->render();
- }
- public function handleAnswer($question, $response)
- {
- $storage = Environment::getSession('questions');
- $storage->$question = $response ? self::YES : self::NO;
- $this->invalidateControl('questions');
- }
- public function handleRefresh()
- {
- Environment::getSession('questions')->remove();
- $this->invalidateControl('questions');
- }
- }
Add Comment
Please, Sign In to add comment