Update 2024-10-09 01:20:31

This commit is contained in:
Robot 2024-10-09 01:20:20 +02:00
parent 43edf4dee7
commit 7ce368db75
Signed by: Robot
GPG Key ID: 14DECD44E7E1BB95
6 changed files with 250 additions and 0 deletions

View File

@ -128,6 +128,7 @@ This repository contains an index (see below) of all the approved powers within
- **final class SchemaChecker** | [Details](src/709d7294-9a43-46e2-b64e-d16a16f0eab1) | [Code](src/709d7294-9a43-46e2-b64e-d16a16f0eab1/code.php) | [Settings](src/709d7294-9a43-46e2-b64e-d16a16f0eab1/settings.json) | SPK: `Super---709d7294_9a43_46e2_b64e_d16a16f0eab1---Power` - **final class SchemaChecker** | [Details](src/709d7294-9a43-46e2-b64e-d16a16f0eab1) | [Code](src/709d7294-9a43-46e2-b64e-d16a16f0eab1/code.php) | [Settings](src/709d7294-9a43-46e2-b64e-d16a16f0eab1/settings.json) | SPK: `Super---709d7294_9a43_46e2_b64e_d16a16f0eab1---Power`
- **Namespace**: [VDM\Joomla\Componentbuilder\Utilities](#vdm-joomla-componentbuilder-utilities) - **Namespace**: [VDM\Joomla\Componentbuilder\Utilities](#vdm-joomla-componentbuilder-utilities)
- **abstract class SessionHelper** | [Details](src/47a63728-cd5d-4d53-99cf-2409bd1c744c) | [Code](src/47a63728-cd5d-4d53-99cf-2409bd1c744c/code.php) | [Settings](src/47a63728-cd5d-4d53-99cf-2409bd1c744c/settings.json) | SPK: `Super---47a63728_cd5d_4d53_99cf_2409bd1c744c---Power`
- **abstract class UserHelper** | [Details](src/7832a726-87b6-4e95-887e-7b725d3fab8f) | [Code](src/7832a726-87b6-4e95-887e-7b725d3fab8f/code.php) | [Settings](src/7832a726-87b6-4e95-887e-7b725d3fab8f/settings.json) | SPK: `Super---7832a726_87b6_4e95_887e_7b725d3fab8f---Power` - **abstract class UserHelper** | [Details](src/7832a726-87b6-4e95-887e-7b725d3fab8f) | [Code](src/7832a726-87b6-4e95-887e-7b725d3fab8f/code.php) | [Settings](src/7832a726-87b6-4e95-887e-7b725d3fab8f/settings.json) | SPK: `Super---7832a726_87b6_4e95_887e_7b725d3fab8f---Power`
- **Namespace**: [VDM\Joomla\Data\Action](#vdm-joomla-data-action) - **Namespace**: [VDM\Joomla\Data\Action](#vdm-joomla-data-action)

View File

@ -0,0 +1,68 @@
```
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# abstract class SessionHelper (Details)
> namespace: **VDM\Joomla\Componentbuilder\Utilities**
```uml
@startuml
abstract SessionHelper #Orange {
+ {static} session() : Session
+ {static} get(string $name, mixed $default = null) : mixed
+ {static} set(string $name, mixed $value = null) : mixed
}
note right of SessionHelper::session
Get the active session
since: 5.0.2
return: Session
end note
note right of SessionHelper::get
Get data from the session store
since: 5.0.2
return: mixed
end note
note right of SessionHelper::set
Set data into the session store
since: 5.0.2
return: mixed
end note
@enduml
```
The Power feature in JCB allows you to write PHP classes and their implementations, making it easy to include them in your Joomla project. JCB handles linking, autoloading, namespacing, and folder structure creation for you.
By using the SPK (Super Power Key) in your custom code (replacing the class name in your code with the SPK), JCB will automatically pull the power from the repository into your project. This makes it available in your JCB instance, allowing you to edit it and include the class in your generated Joomla component.
JCB uses placeholders like [[[`NamespacePrefix`]]] and [[[`ComponentNamespace`]]] in namespacing to prevent collisions and improve reusability across different JCB systems. You can also set the **JCB powers path** globally or per component under the **Dynamic Integration** tab, providing flexibility and easy maintainability.
To add this specific Power to your project in JCB:
> simply use this SPK
```
Super---47a63728_cd5d_4d53_99cf_2409bd1c744c---Power
```
> remember to replace the `---` with `___` to activate this Power in your code
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)

View File

@ -0,0 +1,89 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2020
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @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\Componentbuilder\Utilities;
use Joomla\CMS\Factory;
use Joomla\CMS\Session\Session;
/**
* Simple Session
*
* @since 5.0.2
*/
abstract class SessionHelper
{
/**
* The active session
*
* @var Session|null
* @since 5.0.2
*/
private static ?Session $session = null;
/**
* Get the active session
*
* @return Session
* @throws \RuntimeException if the session cannot be loaded
* @since 5.0.2
*/
public static function session(): Session
{
if (static::$session === null)
{
try {
static::$session = Factory::getApplication()->getSession();
} catch (\Exception $e) {
// Rethrow the exception as a RuntimeException to propagate it downstream
throw new \RuntimeException('Unable to load the session.', 0, $e);
}
}
return static::$session;
}
/**
* Get data from the session store
*
* @param string $name Name of a variable
* @param mixed $default Default value of a variable if not set
*
* @return mixed Value of the variable from the session
* @since 5.0.2
*/
public static function get(string $name, $default = null)
{
$value = static::session()->get($name, $default);
// Ensure the value is set in the session even if it was default
static::set($name, $value);
return $value;
}
/**
* Set data into the session store
*
* @param string $name Name of a variable
* @param mixed $value Value of a variable
*
* @return mixed Old value of the variable
* @since 5.0.2
*/
public static function set(string $name, $value = null)
{
return static::session()->set($name, $value);
}
}

View File

@ -0,0 +1,62 @@
/**
* The active session
*
* @var Session|null
* @since 5.0.2
*/
private static ?Session $session = null;
/**
* Get the active session
*
* @return Session
* @throws \RuntimeException if the session cannot be loaded
* @since 5.0.2
*/
public static function session(): Session
{
if (static::$session === null)
{
try {
static::$session = Factory::getApplication()->getSession();
} catch (\Exception $e) {
// Rethrow the exception as a RuntimeException to propagate it downstream
throw new \RuntimeException('Unable to load the session.', 0, $e);
}
}
return static::$session;
}
/**
* Get data from the session store
*
* @param string $name Name of a variable
* @param mixed $default Default value of a variable if not set
*
* @return mixed Value of the variable from the session
* @since 5.0.2
*/
public static function get(string $name, $default = null)
{
$value = static::session()->get($name, $default);
// Ensure the value is set in the session even if it was default
static::set($name, $value);
return $value;
}
/**
* Set data into the session store
*
* @param string $name Name of a variable
* @param mixed $value Value of a variable
*
* @return mixed Old value of the variable
* @since 5.0.2
*/
public static function set(string $name, $value = null)
{
return static::session()->set($name, $value);
}

View File

@ -0,0 +1,19 @@
{
"add_head": "1",
"add_licensing_template": "2",
"extends": "",
"guid": "47a63728-cd5d-4d53-99cf-2409bd1c744c",
"implements": null,
"load_selection": null,
"name": "SessionHelper",
"power_version": "1.0.0",
"system_name": "Joomla.Utilities.SessionHelper",
"type": "abstract class",
"use_selection": null,
"extendsinterfaces": null,
"namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Utilities.SessionHelper",
"description": "Simple Session\r\n\r\n@since 5.0.2",
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2020\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/joomla\/Component-Builder>\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;\r\nuse Joomla\\CMS\\Session\\Session;",
"composer": ""
}

View File

@ -329,6 +329,17 @@
"spk": "Super---46b98346_ec98_42b3_a393_96c7d1282b1c---Power", "spk": "Super---46b98346_ec98_42b3_a393_96c7d1282b1c---Power",
"guid": "46b98346-ec98-42b3-a393-96c7d1282b1c" "guid": "46b98346-ec98-42b3-a393-96c7d1282b1c"
}, },
"47a63728-cd5d-4d53-99cf-2409bd1c744c": {
"name": "SessionHelper",
"type": "abstract class",
"namespace": "VDM\\Joomla\\Componentbuilder\\Utilities",
"code": "src\/47a63728-cd5d-4d53-99cf-2409bd1c744c\/code.php",
"power": "src\/47a63728-cd5d-4d53-99cf-2409bd1c744c\/code.power",
"settings": "src\/47a63728-cd5d-4d53-99cf-2409bd1c744c\/settings.json",
"path": "src\/47a63728-cd5d-4d53-99cf-2409bd1c744c",
"spk": "Super---47a63728_cd5d_4d53_99cf_2409bd1c744c---Power",
"guid": "47a63728-cd5d-4d53-99cf-2409bd1c744c"
},
"4815e1c7-a433-443d-a112-d1e03d7df84b": { "4815e1c7-a433-443d-a112-d1e03d7df84b": {
"name": "Database", "name": "Database",
"type": "class", "type": "class",