Restructure Session to follow new paradigm

This commit is contained in:
Philipp 2021-10-23 11:39:29 +02:00
parent ff1a812e1a
commit 57b4c008cb
No known key found for this signature in database
GPG Key ID: 24A7501396EB5432
7 changed files with 13 additions and 11 deletions

View File

@ -19,14 +19,13 @@
*
*/
namespace Friendica\Factory;
namespace Friendica\Core\Session\Factory;
use Friendica\App;
use Friendica\Core\Cache\ICache;
use Friendica\Core\Cache\Enum\Type;
use Friendica\Core\Config\IConfig;
use Friendica\Core\Session;
use Friendica\Core\System;
use Friendica\Database\Database;
use Friendica\Util\Profiler;
use Psr\Log\LoggerInterface;
@ -63,7 +62,7 @@ class SessionFactory
try {
if ($mode->isInstall() || $mode->isBackend()) {
$session = new Session\Memory();
$session = new Session\Type\Memory();
} else {
$session_handler = $config->get('system', 'session_handler', self::HANDLER_DEFAULT);
$handler = null;
@ -82,7 +81,7 @@ class SessionFactory
break;
}
$session = new Session\Native($baseURL, $handler);
$session = new Session\Type\Native($baseURL, $handler);
}
} finally {
$profiler->stopRecording();

View File

@ -19,7 +19,7 @@
*
*/
namespace Friendica\Core\Session;
namespace Friendica\Core\Session\Type;
/**
* Contains the base methods for $_SESSION interaction

View File

@ -19,7 +19,9 @@
*
*/
namespace Friendica\Core\Session;
namespace Friendica\Core\Session\Type;
use Friendica\Core\Session\ISession;
/**
* Usable for backend processes (daemon/worker) and testing

View File

@ -19,9 +19,10 @@
*
*/
namespace Friendica\Core\Session;
namespace Friendica\Core\Session\Type;
use Friendica\App;
use Friendica\Core\Session\ISession;
use Friendica\Model\User\Cookie;
use SessionHandlerInterface;

View File

@ -207,7 +207,7 @@ return [
],
],
ISession::class => [
'instanceOf' => Factory\SessionFactory::class,
'instanceOf' => \Friendica\Core\Session\Factory\SessionFactory::class,
'call' => [
['createSession', [$_SERVER], Dice::CHAIN_CALL],
['start', [], Dice::CHAIN_CALL],

View File

@ -33,7 +33,7 @@ abstract class FixtureTest extends DatabaseTest
$this->dice = (new Dice())
->addRules(include __DIR__ . '/../static/dependencies.config.php')
->addRule(Database::class, ['instanceOf' => StaticDatabase::class, 'shared' => true])
->addRule(ISession::class, ['instanceOf' => Session\Memory::class, 'shared' => true, 'call' => null]);
->addRule(ISession::class, ['instanceOf' => Session\Type\Memory::class, 'shared' => true, 'call' => null]);
DI::init($this->dice);
/** @var IConfig $config */

View File

@ -253,7 +253,7 @@ class StorageManagerTest extends DatabaseTest
$dice = (new Dice())
->addRules(include __DIR__ . '/../../../static/dependencies.config.php')
->addRule(Database::class, ['instanceOf' => StaticDatabase::class, 'shared' => true])
->addRule(ISession::class, ['instanceOf' => Session\Memory::class, 'shared' => true, 'call' => null]);
->addRule(ISession::class, ['instanceOf' => Session\Type\Memory::class, 'shared' => true, 'call' => null]);
DI::init($dice);
$storageManager = new StorageManager($this->dba, $this->config, $this->logger, $this->l10n);
@ -281,7 +281,7 @@ class StorageManagerTest extends DatabaseTest
$dice = (new Dice())
->addRules(include __DIR__ . '/../../../static/dependencies.config.php')
->addRule(Database::class, ['instanceOf' => StaticDatabase::class, 'shared' => true])
->addRule(ISession::class, ['instanceOf' => Session\Memory::class, 'shared' => true, 'call' => null]);
->addRule(ISession::class, ['instanceOf' => Session\Type\Memory::class, 'shared' => true, 'call' => null]);
DI::init($dice);
$storageManager = new StorageManager($this->dba, $this->config, $this->logger, $this->l10n);