From 57b4c008cb0796fe4add72bc94746d0bba64355f Mon Sep 17 00:00:00 2001 From: Philipp Date: Sat, 23 Oct 2021 11:39:29 +0200 Subject: [PATCH] Restructure Session to follow new paradigm --- src/{ => Core/Session}/Factory/SessionFactory.php | 7 +++---- src/Core/Session/{ => Type}/AbstractSession.php | 2 +- src/Core/Session/{ => Type}/Memory.php | 4 +++- src/Core/Session/{ => Type}/Native.php | 3 ++- static/dependencies.config.php | 2 +- tests/FixtureTest.php | 2 +- tests/src/Core/StorageManagerTest.php | 4 ++-- 7 files changed, 13 insertions(+), 11 deletions(-) rename src/{ => Core/Session}/Factory/SessionFactory.php (94%) rename src/Core/Session/{ => Type}/AbstractSession.php (97%) rename src/Core/Session/{ => Type}/Memory.php (93%) rename src/Core/Session/{ => Type}/Native.php (95%) diff --git a/src/Factory/SessionFactory.php b/src/Core/Session/Factory/SessionFactory.php similarity index 94% rename from src/Factory/SessionFactory.php rename to src/Core/Session/Factory/SessionFactory.php index 82161fb554..510ff08c75 100644 --- a/src/Factory/SessionFactory.php +++ b/src/Core/Session/Factory/SessionFactory.php @@ -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(); diff --git a/src/Core/Session/AbstractSession.php b/src/Core/Session/Type/AbstractSession.php similarity index 97% rename from src/Core/Session/AbstractSession.php rename to src/Core/Session/Type/AbstractSession.php index c185f1bbfa..8126804dba 100644 --- a/src/Core/Session/AbstractSession.php +++ b/src/Core/Session/Type/AbstractSession.php @@ -19,7 +19,7 @@ * */ -namespace Friendica\Core\Session; +namespace Friendica\Core\Session\Type; /** * Contains the base methods for $_SESSION interaction diff --git a/src/Core/Session/Memory.php b/src/Core/Session/Type/Memory.php similarity index 93% rename from src/Core/Session/Memory.php rename to src/Core/Session/Type/Memory.php index 7cf9fd6aef..635d880e7a 100644 --- a/src/Core/Session/Memory.php +++ b/src/Core/Session/Type/Memory.php @@ -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 diff --git a/src/Core/Session/Native.php b/src/Core/Session/Type/Native.php similarity index 95% rename from src/Core/Session/Native.php rename to src/Core/Session/Type/Native.php index 23d02af921..4edd9a962e 100644 --- a/src/Core/Session/Native.php +++ b/src/Core/Session/Type/Native.php @@ -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; diff --git a/static/dependencies.config.php b/static/dependencies.config.php index 48ed997f33..4591f4761c 100644 --- a/static/dependencies.config.php +++ b/static/dependencies.config.php @@ -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], diff --git a/tests/FixtureTest.php b/tests/FixtureTest.php index fdeda1febc..c09f874fa0 100644 --- a/tests/FixtureTest.php +++ b/tests/FixtureTest.php @@ -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 */ diff --git a/tests/src/Core/StorageManagerTest.php b/tests/src/Core/StorageManagerTest.php index acab50ce42..b7e5715edc 100644 --- a/tests/src/Core/StorageManagerTest.php +++ b/tests/src/Core/StorageManagerTest.php @@ -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); -- 2.39.5