Skip to content

Instantly share code, notes, and snippets.

@naderman
Created May 28, 2011 19:51
Show Gist options
  • Save naderman/997157 to your computer and use it in GitHub Desktop.
Save naderman/997157 to your computer and use it in GitHub Desktop.
Joomla! Symfony Integration Proof of Concept
<?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');
}
}
<?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