Skip to content

Moved session handler to a separate package #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jan 23, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@
"require": {
"php": "^5.5|^7",
"symfony/framework-bundle": "^2.7|^3.0",
"cache/taggable-cache": "^0.3"
"cache/taggable-cache": "^0.3",
"cache/session-handler": "^0.1"
},
"require-dev": {
"phpunit/phpunit": "^5.1|^4.0",
Expand Down
125 changes: 0 additions & 125 deletions src/Bridge/SessionHandlerBridge.php

This file was deleted.

4 changes: 2 additions & 2 deletions src/DependencyInjection/CacheExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@
namespace Cache\CacheBundle\DependencyInjection;

use Cache\Bridge\DoctrineCacheBridge;
use Cache\CacheBundle\Bridge\SessionHandlerBridge;
use Cache\CacheBundle\Bridge\SymfonyValidatorBridge;
use Cache\CacheBundle\Factory\DoctrineBridgeFactory;
use Cache\CacheBundle\Factory\SessionHandlerFactory;
use Cache\CacheBundle\Factory\ValidationFactory;
use Cache\CacheBundle\Routing\CachingRouter;
use Cache\SessionHandler\Psr6SessionHandler;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader;
Expand Down Expand Up @@ -79,7 +79,7 @@ public function load(array $configs, ContainerBuilder $container)
}

if ($config['session']['enabled']) {
$container->register('cache.service.session', SessionHandlerBridge::class)
$container->register('cache.service.session', Psr6SessionHandler::class)
->setFactory([SessionHandlerFactory::class, 'get'])
->addArgument(new Reference($config['session']['service_id']))
->addArgument($config['session']);
Expand Down
7 changes: 3 additions & 4 deletions src/Factory/SessionHandlerFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@

namespace Cache\CacheBundle\Factory;

use Cache\Bridge\DoctrineCacheBridge;
use Cache\CacheBundle\Bridge\SessionHandlerBridge;
use Cache\CacheBundle\Cache\FixedTaggingCachePool;
use Cache\SessionHandler\Psr6SessionHandler;
use Psr\Cache\CacheItemPoolInterface;

/**
Expand All @@ -25,14 +24,14 @@ class SessionHandlerFactory
* @param CacheItemPoolInterface $pool
* @param array $config
*
* @return DoctrineCacheBridge
* @return Psr6SessionHandler
*/
public static function get(CacheItemPoolInterface $pool, $config)
{
if ($config['use_tagging']) {
$pool = new FixedTaggingCachePool($pool, ['session']);
}

return new SessionHandlerBridge($pool, $config);
return new Psr6SessionHandler($pool, $config);
}
}
3 changes: 1 addition & 2 deletions src/Factory/ValidationFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace Cache\CacheBundle\Factory;

use Cache\Bridge\DoctrineCacheBridge;
use Cache\CacheBundle\Bridge\SymfonyValidatorBridge;
use Cache\CacheBundle\Cache\FixedTaggingCachePool;
use Psr\Cache\CacheItemPoolInterface;
Expand All @@ -25,7 +24,7 @@ class ValidationFactory
* @param CacheItemPoolInterface $pool
* @param array $config
*
* @return DoctrineCacheBridge
* @return SymfonyValidatorBridge
*/
public static function get(CacheItemPoolInterface $pool, $config)
{
Expand Down
4 changes: 2 additions & 2 deletions src/Routing/CachingRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ private function getCacheItemMatch($pathinfo)
{
/** @type RequestContext $c */
$c = $this->getContext();
$key = sprintf('routing:%s:%s:%s:%s', $c->getMethod(), $c->getHost(), $pathinfo, $c->getQueryString());
$key = sprintf('%s__%s__%s__%s', $c->getMethod(), $c->getHost(), $pathinfo, $c->getQueryString());

return $this->getCacheItemFromKey($key, 'match');
}
Expand All @@ -142,7 +142,7 @@ private function getCacheItemMatch($pathinfo)
private function getCacheItemGenerate($name, array $parameters, $referenceType)
{
sort($parameters);
$key = sprintf('generate:%s:%s:%s', $name, json_encode($parameters), $referenceType ? 'true' : 'false');
$key = sprintf('%s.%s.%s', $name, $referenceType ? 'true' : 'false', json_encode($parameters));

return $this->getCacheItemFromKey($key, 'generate');
}
Expand Down