From 73c4c1837109f70535c21ea0748d2628866e7f46 Mon Sep 17 00:00:00 2001 From: aB0t Date: Wed, 19 Jul 2023 12:32:39 +0200 Subject: [PATCH] update 2023-07-19 12:32:39 --- README.md | 1 + .../README.md | 51 +++++++++++ .../code.php | 87 +++++++++++++++++++ .../code.power | 59 +++++++++++++ .../settings.json | 23 +++++ .../README.md | 8 ++ .../code.php | 17 ++++ .../code.power | 16 ++++ .../settings.json | 4 + super-powers.json | 11 +++ 10 files changed, 277 insertions(+) create mode 100644 src/84e84cd1-c938-4559-8414-d5692db4118e/README.md create mode 100644 src/84e84cd1-c938-4559-8414-d5692db4118e/code.php create mode 100644 src/84e84cd1-c938-4559-8414-d5692db4118e/code.power create mode 100644 src/84e84cd1-c938-4559-8414-d5692db4118e/settings.json diff --git a/README.md b/README.md index 76bc13f..c0bb40a 100644 --- a/README.md +++ b/README.md @@ -82,6 +82,7 @@ This repository contains an index (see below) of all the approved powers within - **final class Http** | [Details](src/b8c66089-735e-4081-825c-8fe36b28e4a6) | [Code](src/b8c66089-735e-4081-825c-8fe36b28e4a6/code.php) | [Settings](src/b8c66089-735e-4081-825c-8fe36b28e4a6/settings.json) | Super__b8c66089_735e_4081_825c_8fe36b28e4a6__Power - **final class Response** | [Details](src/c99e85a0-d120-4f25-bcbf-0940dd7b773b) | [Code](src/c99e85a0-d120-4f25-bcbf-0940dd7b773b/code.php) | [Settings](src/c99e85a0-d120-4f25-bcbf-0940dd7b773b/settings.json) | Super__c99e85a0_d120_4f25_bcbf_0940dd7b773b__Power + - **final class SessionHelper** | [Details](src/84e84cd1-c938-4559-8414-d5692db4118e) | [Code](src/84e84cd1-c938-4559-8414-d5692db4118e/code.php) | [Settings](src/84e84cd1-c938-4559-8414-d5692db4118e/settings.json) | Super__84e84cd1_c938_4559_8414_d5692db4118e__Power - **final class StringHelper** | [Details](src/a5b32737-207d-4cf6-b8ae-ee815612c3a0) | [Code](src/a5b32737-207d-4cf6-b8ae-ee815612c3a0/code.php) | [Settings](src/a5b32737-207d-4cf6-b8ae-ee815612c3a0/settings.json) | Super__a5b32737_207d_4cf6_b8ae_ee815612c3a0__Power - **final class Uri** | [Details](src/fc9ab6f0-c31b-4077-bb1c-2dcddd36f6bb) | [Code](src/fc9ab6f0-c31b-4077-bb1c-2dcddd36f6bb/code.php) | [Settings](src/fc9ab6f0-c31b-4077-bb1c-2dcddd36f6bb/settings.json) | Super__fc9ab6f0_c31b_4077_bb1c_2dcddd36f6bb__Power diff --git a/src/84e84cd1-c938-4559-8414-d5692db4118e/README.md b/src/84e84cd1-c938-4559-8414-d5692db4118e/README.md new file mode 100644 index 0000000..a2d82d4 --- /dev/null +++ b/src/84e84cd1-c938-4559-8414-d5692db4118e/README.md @@ -0,0 +1,51 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class SessionHelper (Details) +> namespace: **VDM\Joomla\GetBible\Utilities** +```uml +@startuml +class SessionHelper << (F,LightGreen) >> #Green { + # Session $session + + __construct(?Session $session = null) + + getLinker() : string + + setLinker(string $linker) : bool +} + +note right of SessionHelper::__construct + Constructor + + since: 3.2.0 +end note + +note right of SessionHelper::getLinker + Get the Active Linker GUID Value + + return: string +end note + +note right of SessionHelper::setLinker + Set the Active Linker GUID Value + + return: bool +end note + +@enduml +``` + +--- +``` + ██╗ ██████╗██████╗ + ██║██╔════╝██╔══██╗ + ██║██║ ██████╔╝ +██ ██║██║ ██╔══██╗ +╚█████╔╝╚██████╗██████╔╝ + ╚════╝ ╚═════╝╚═════╝ +``` +> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder) + diff --git a/src/84e84cd1-c938-4559-8414-d5692db4118e/code.php b/src/84e84cd1-c938-4559-8414-d5692db4118e/code.php new file mode 100644 index 0000000..4acef2f --- /dev/null +++ b/src/84e84cd1-c938-4559-8414-d5692db4118e/code.php @@ -0,0 +1,87 @@ + + * @git GetBible + * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved. + * @license GNU General Public License version 2 or later; see LICENSE.txt + */ + +namespace VDM\Joomla\GetBible\Utilities; + + +use Joomla\CMS\Factory as JoomlaFactory; +use Joomla\CMS\Session\Session; +use VDM\Joomla\Utilities\GuidHelper; + + +/** + * The GetBible Session Helper + * + * @since 2.0.1 + */ +final class SessionHelper +{ + /** + * The Session + * + * @var Session + * @since 3.2.0 + */ + protected Session $session; + + /** + * Constructor + * + * @param Session|null $session The Joomla session. + * + * @since 3.2.0 + */ + public function __construct(?Session $session = null) + { + $this->session = $session ?: JoomlaFactory::getSession(); + } + + /** + * Get the Active Linker GUID Value + * + * @return string A Valid Linker GUID Value + */ + public function getLinker(): string + { + $linker = $this->session->get('getbible_active_linker_guid', GuidHelper::get()); + + if (GuidHelper::valid($linker)) + { + return $linker; + } + + $linker = GuidHelper::get(); + + $this->session->set('getbible_active_linker_guid', $linker); + + return $linker; + } + + /** + * Set the Active Linker GUID Value + * + * @param string $linker The linker GUID value. + * + * @return bool True on success + */ + public function setLinker($linker): bool + { + if (GuidHelper::valid($linker)) + { + $this->session->set('getbible_active_linker_guid', $linker); + + return true; + } + + return false; + } +} + diff --git a/src/84e84cd1-c938-4559-8414-d5692db4118e/code.power b/src/84e84cd1-c938-4559-8414-d5692db4118e/code.power new file mode 100644 index 0000000..8902089 --- /dev/null +++ b/src/84e84cd1-c938-4559-8414-d5692db4118e/code.power @@ -0,0 +1,59 @@ + /** + * The Session + * + * @var Session + * @since 3.2.0 + */ + protected Session $session; + + /** + * Constructor + * + * @param Session|null $session The Joomla session. + * + * @since 3.2.0 + */ + public function __construct(?Session $session = null) + { + $this->session = $session ?: JoomlaFactory::getSession(); + } + + /** + * Get the Active Linker GUID Value + * + * @return string A Valid Linker GUID Value + */ + public function getLinker(): string + { + $linker = $this->session->get('getbible_active_linker_guid', GuidHelper::get()); + + if (GuidHelper::valid($linker)) + { + return $linker; + } + + $linker = GuidHelper::get(); + + $this->session->set('getbible_active_linker_guid', $linker); + + return $linker; + } + + /** + * Set the Active Linker GUID Value + * + * @param string $linker The linker GUID value. + * + * @return bool True on success + */ + public function setLinker($linker): bool + { + if (GuidHelper::valid($linker)) + { + $this->session->set('getbible_active_linker_guid', $linker); + + return true; + } + + return false; + } \ No newline at end of file diff --git a/src/84e84cd1-c938-4559-8414-d5692db4118e/settings.json b/src/84e84cd1-c938-4559-8414-d5692db4118e/settings.json new file mode 100644 index 0000000..57acd8e --- /dev/null +++ b/src/84e84cd1-c938-4559-8414-d5692db4118e/settings.json @@ -0,0 +1,23 @@ +{ + "add_head": "1", + "add_licensing_template": "2", + "extends": "0", + "guid": "84e84cd1-c938-4559-8414-d5692db4118e", + "implements": null, + "load_selection": null, + "name": "SessionHelper", + "power_version": "1.0.0", + "system_name": "Joomla.GetBible.Utilities.SessionHelper", + "type": "final class", + "use_selection": { + "use_selection0": { + "use": "9c513baf-b279-43fd-ae29-a585c8cbc4f0", + "as": "default" + } + }, + "namespace": "VDM\\Joomla\\GetBible\\Utilities.SessionHelper", + "description": "The GetBible Session Helper\r\n\r\n@since 2.0.1", + "licensing_template": "\/**\r\n * @package GetBible\r\n *\r\n * @created 30th May, 2023\r\n * @author Llewellyn van der Merwe \r\n * @git GetBible \r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n", + "head": "use Joomla\\CMS\\Factory as JoomlaFactory;\r\nuse Joomla\\CMS\\Session\\Session;", + "composer": "" +} \ No newline at end of file diff --git a/src/b89d74ef-c71c-4a58-8455-5dbdfe94027a/README.md b/src/b89d74ef-c71c-4a58-8455-5dbdfe94027a/README.md index 51d547d..267095e 100644 --- a/src/b89d74ef-c71c-4a58-8455-5dbdfe94027a/README.md +++ b/src/b89d74ef-c71c-4a58-8455-5dbdfe94027a/README.md @@ -16,6 +16,7 @@ class Utilities #Gold { + getResponse(Container $container) : Response + getHttp(Container $container) : Http + getString(Container $container) : StringHelper + + getSession(Container $container) : SessionHelper } note right of Utilities::register @@ -52,6 +53,13 @@ note right of Utilities::getString since: 3.2.0 return: StringHelper end note + +note right of Utilities::getSession + Get the Session Helper class + + since: 3.2.0 + return: SessionHelper +end note @enduml ``` diff --git a/src/b89d74ef-c71c-4a58-8455-5dbdfe94027a/code.php b/src/b89d74ef-c71c-4a58-8455-5dbdfe94027a/code.php index b437644..74a87e2 100644 --- a/src/b89d74ef-c71c-4a58-8455-5dbdfe94027a/code.php +++ b/src/b89d74ef-c71c-4a58-8455-5dbdfe94027a/code.php @@ -18,6 +18,7 @@ use VDM\Joomla\GetBible\Utilities\Uri; use VDM\Joomla\GetBible\Utilities\Response; use VDM\Joomla\GetBible\Utilities\Http; use VDM\Joomla\GetBible\Utilities\StringHelper; +use VDM\Joomla\GetBible\Utilities\SessionHelper; /** @@ -48,6 +49,9 @@ class Utilities implements ServiceProviderInterface $container->alias(StringHelper::class, 'GetBible.Utilities.String') ->share('GetBible.Utilities.String', [$this, 'getString'], true); + + $container->alias(SessionHelper::class, 'GetBible.Utilities.Session') + ->share('GetBible.Utilities.Session', [$this, 'getSession'], true); } /** @@ -102,6 +106,19 @@ class Utilities implements ServiceProviderInterface public function getString(Container $container): StringHelper { return new StringHelper(); + } + + /** + * Get the Session Helper class + * + * @param Container $container The DI container. + * + * @return SessionHelper + * @since 3.2.0 + */ + public function getSession(Container $container): SessionHelper + { + return new SessionHelper(); } } diff --git a/src/b89d74ef-c71c-4a58-8455-5dbdfe94027a/code.power b/src/b89d74ef-c71c-4a58-8455-5dbdfe94027a/code.power index 8c86712..772350c 100644 --- a/src/b89d74ef-c71c-4a58-8455-5dbdfe94027a/code.power +++ b/src/b89d74ef-c71c-4a58-8455-5dbdfe94027a/code.power @@ -19,6 +19,9 @@ $container->alias(StringHelper::class, 'GetBible.Utilities.String') ->share('GetBible.Utilities.String', [$this, 'getString'], true); + + $container->alias(SessionHelper::class, 'GetBible.Utilities.Session') + ->share('GetBible.Utilities.Session', [$this, 'getSession'], true); } /** @@ -73,4 +76,17 @@ public function getString(Container $container): StringHelper { return new StringHelper(); + } + + /** + * Get the Session Helper class + * + * @param Container $container The DI container. + * + * @return SessionHelper + * @since 3.2.0 + */ + public function getSession(Container $container): SessionHelper + { + return new SessionHelper(); } \ No newline at end of file diff --git a/src/b89d74ef-c71c-4a58-8455-5dbdfe94027a/settings.json b/src/b89d74ef-c71c-4a58-8455-5dbdfe94027a/settings.json index e38ea28..e4cc2e6 100644 --- a/src/b89d74ef-c71c-4a58-8455-5dbdfe94027a/settings.json +++ b/src/b89d74ef-c71c-4a58-8455-5dbdfe94027a/settings.json @@ -27,6 +27,10 @@ "use_selection3": { "use": "a5b32737-207d-4cf6-b8ae-ee815612c3a0", "as": "default" + }, + "use_selection4": { + "use": "84e84cd1-c938-4559-8414-d5692db4118e", + "as": "default" } }, "namespace": "VDM\\Joomla\\GetBible\\Service.Utilities", diff --git a/super-powers.json b/super-powers.json index 8078c36..6b3282e 100644 --- a/super-powers.json +++ b/super-powers.json @@ -153,6 +153,17 @@ "spk": "Super__8336e3c4_f11b_41bc_a2b1_976f99442a84__Power", "guid": "8336e3c4-f11b-41bc-a2b1-976f99442a84" }, + "84e84cd1-c938-4559-8414-d5692db4118e": { + "name": "SessionHelper", + "type": "final class", + "namespace": "VDM\\Joomla\\GetBible\\Utilities", + "code": "src\/84e84cd1-c938-4559-8414-d5692db4118e\/code.php", + "power": "src\/84e84cd1-c938-4559-8414-d5692db4118e\/code.power", + "settings": "src\/84e84cd1-c938-4559-8414-d5692db4118e\/settings.json", + "path": "src\/84e84cd1-c938-4559-8414-d5692db4118e", + "spk": "Super__84e84cd1_c938_4559_8414_d5692db4118e__Power", + "guid": "84e84cd1-c938-4559-8414-d5692db4118e" + }, "899551ac-943e-4f81-becd-7e15c41f1081": { "name": "Word", "type": "final class",