Created
January 6, 2012 20:46
-
-
Save COil/1572339 to your computer and use it in GitHub Desktop.
Extending the Symfony2 session: snippet #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// /app/src/COil/QuestBundle/Lib/mySession.php | |
namespace COil\QuestBundle\Lib; | |
use Symfony\Component\HttpFoundation\Session; | |
/** | |
* mySession object. | |
*/ | |
class mySession extends Session | |
{ | |
/** | |
* Add a "UserAnswer" object in session. | |
* | |
* @param type $userAnswer | |
*/ | |
function addAnswer($userAnswer) | |
{ | |
$answers = $this->get('answers', array()); | |
$answers[] = $userAnswer; | |
$this->set('answers', $answers); | |
} | |
/** | |
* Return all the answers of the user. | |
* | |
* @return Array | |
*/ | |
function getAnswers() | |
{ | |
return $this->get('answers', array()); | |
} | |
/** | |
* Set a "notice" flash message. | |
* | |
* @return String | |
*/ | |
function setNotice($message) | |
{ | |
return $this->setFlash('notice', $message); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment