Created
May 28, 2011 19:51
-
-
Save naderman/997157 to your computer and use it in GitHub Desktop.
Joomla! Symfony Integration Proof of Concept
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 | |
namespace phpBB\JoomlaIntegration; | |
use Symfony\Component\HttpFoundation\SessionStorage\SessionStorageInterface; | |
class JoomlaSessionStorage implements SessionStorageInterface | |
{ | |
protected $jSession; | |
public function __construct($jSession) | |
{ | |
$this->jSession = $jSession; | |
} | |
public function read($key, $default = null) | |
{ | |
$this->jSession->get($key, $default, 'symfony'); | |
} | |
public function regenerate($destroy = false) | |
{ | |
return $this->jSession->restart(); | |
} | |
public function remove($key) | |
{ | |
$this->jSession->clear($key, 'symfony'); | |
} | |
public function start() | |
{ | |
// already happened | |
} | |
public function getId() | |
{ | |
return $this->jSession->getId(); | |
} | |
public function write($key, $data) | |
{ | |
$this->jSession->set($key, $data, 'symfony'); | |
} | |
} |
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 | |
require_once __DIR__.'/../../../../symfony-sandbox/app/bootstrap.php'; | |
require_once __DIR__.'/../../../../symfony-sandbox/app/AppKernel.php'; | |
use Symfony\Component\HttpFoundation\Request; | |
use Symfony\Component\HttpFoundation\Session; | |
use phpBB\JoomlaIntegration\JoomlaSessionStorage; | |
$request = new Request( | |
JRequest::get('get'), | |
JRequest::get('post'), | |
array(), | |
JRequest::get('cookie'), | |
JRequest::get('files'), | |
JRequest::get('server')); | |
$jSession = JSession::getInstance(null, null); | |
$sessionStorage = new JoomlaSessionStorage($jSession); | |
$session = new Session($sessionStorage); | |
$kernel = new AppKernel('dev', true); | |
$kernel->boot(); | |
$kernel->getContainer()->set('session.storage', $sessionStorage); | |
$response = $kernel->handle($request); | |
$response->send(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment