Пример #1
0
 /**
  * Sets the session or session value
  * @param string|\Nimbles\Http\Sesison $key
  * @param scalar $value
  * @return \Nimbles\Http\Response
  */
 public function setSession($key, $value = null)
 {
     if ($key instanceof Session) {
         $this->_session = $key;
         return $this;
     }
     $this->_session->write($key, $value);
     return $this;
 }
Пример #2
0
 /**
  * Gets the array of implements for this mixin
  * @var array
  */
 protected static function _getImplements()
 {
     return array_merge_recursive(parent::_getImplements(), array('Nimbles\\Core\\Delegates\\Delegatable' => array('delegates' => array('getCookieRaw' => function () {
         return $_COOKIE;
     }, 'getQueryRaw' => function () {
         return $_GET;
     }, 'getPostRaw' => function () {
         return $_POST;
     }, 'getFilesRaw' => function () {
         return $_FILES;
     }, 'createSession' => function () {
         $session = new Session();
         $session->setDelegate('writeValue', function () {
         });
         // do nothing, make read only
         $session->setDelegate('clearValues', function () {
         });
         // do nothing, make read only
     }, 'getInput' => array('\\Nimbles\\Http\\Request', 'getRequestInput')))));
 }
Пример #3
0
 /**
  * Gets a session variable by key
  * @param string|null $key
  * @return \Nimbles\Http\Session|scalar
  */
 public function getSession($key = null)
 {
     if (null === $this->_session) {
         $this->_session = $this->createSession();
         if (!$this->_session->isStarted()) {
             $this->_session->start();
         }
     }
     if (null === $key) {
         return $this->_session;
     }
     return $this->_session->read($key);
 }