Update 2024-12-16 18:30:48
This commit is contained in:
parent
44d1649eb0
commit
77f23fb8c2
@ -26,10 +26,10 @@ This repository contains an index (see below) of all the approved powers within
|
|||||||
- **Namespace**: [VDM\Joomla\Abstraction](#vdm-joomla-abstraction)
|
- **Namespace**: [VDM\Joomla\Abstraction](#vdm-joomla-abstraction)
|
||||||
|
|
||||||
- **abstract class ActiveRegistry** | [Details](src/43134867-5cb8-4280-9be8-309fd2fd135f) | [Code](src/43134867-5cb8-4280-9be8-309fd2fd135f/code.php) | [Settings](src/43134867-5cb8-4280-9be8-309fd2fd135f/settings.json) | SPK: `Super---43134867_5cb8_4280_9be8_309fd2fd135f---Power`
|
- **abstract class ActiveRegistry** | [Details](src/43134867-5cb8-4280-9be8-309fd2fd135f) | [Code](src/43134867-5cb8-4280-9be8-309fd2fd135f/code.php) | [Settings](src/43134867-5cb8-4280-9be8-309fd2fd135f/settings.json) | SPK: `Super---43134867_5cb8_4280_9be8_309fd2fd135f---Power`
|
||||||
- **abstract class BaseConfig** | [Details](src/ffbd4e1f-a342-4080-ab7d-1de3741bf319) | [Code](src/ffbd4e1f-a342-4080-ab7d-1de3741bf319/code.php) | [Settings](src/ffbd4e1f-a342-4080-ab7d-1de3741bf319/settings.json) | SPK: `Super---ffbd4e1f_a342_4080_ab7d_1de3741bf319---Power`
|
|
||||||
- **abstract class BaseTable** | [Details](src/e0f6ddbe-2a35-4537-942c-faff2ebd04f6) | [Code](src/e0f6ddbe-2a35-4537-942c-faff2ebd04f6/code.php) | [Settings](src/e0f6ddbe-2a35-4537-942c-faff2ebd04f6/settings.json) | SPK: `Super---e0f6ddbe_2a35_4537_942c_faff2ebd04f6---Power`
|
- **abstract class BaseTable** | [Details](src/e0f6ddbe-2a35-4537-942c-faff2ebd04f6) | [Code](src/e0f6ddbe-2a35-4537-942c-faff2ebd04f6/code.php) | [Settings](src/e0f6ddbe-2a35-4537-942c-faff2ebd04f6/settings.json) | SPK: `Super---e0f6ddbe_2a35_4537_942c_faff2ebd04f6---Power`
|
||||||
- **abstract class Database** | [Details](src/6cbef8f8-4813-48e3-b05a-65e1aea95171) | [Code](src/6cbef8f8-4813-48e3-b05a-65e1aea95171/code.php) | [Settings](src/6cbef8f8-4813-48e3-b05a-65e1aea95171/settings.json) | SPK: `Super---6cbef8f8_4813_48e3_b05a_65e1aea95171---Power`
|
- **abstract class Database** | [Details](src/6cbef8f8-4813-48e3-b05a-65e1aea95171) | [Code](src/6cbef8f8-4813-48e3-b05a-65e1aea95171/code.php) | [Settings](src/6cbef8f8-4813-48e3-b05a-65e1aea95171/settings.json) | SPK: `Super---6cbef8f8_4813_48e3_b05a_65e1aea95171---Power`
|
||||||
- **abstract class Factory** | [Details](src/2e5bf608-de5c-4b00-a20d-47c26aa350d9) | [Code](src/2e5bf608-de5c-4b00-a20d-47c26aa350d9/code.php) | [Settings](src/2e5bf608-de5c-4b00-a20d-47c26aa350d9/settings.json) | SPK: `Super---2e5bf608_de5c_4b00_a20d_47c26aa350d9---Power`
|
- **abstract class Factory** | [Details](src/2e5bf608-de5c-4b00-a20d-47c26aa350d9) | [Code](src/2e5bf608-de5c-4b00-a20d-47c26aa350d9/code.php) | [Settings](src/2e5bf608-de5c-4b00-a20d-47c26aa350d9/settings.json) | SPK: `Super---2e5bf608_de5c_4b00_a20d_47c26aa350d9---Power`
|
||||||
|
- **abstract class FunctionRegistry** | [Details](src/ffbd4e1f-a342-4080-ab7d-1de3741bf319) | [Code](src/ffbd4e1f-a342-4080-ab7d-1de3741bf319/code.php) | [Settings](src/ffbd4e1f-a342-4080-ab7d-1de3741bf319/settings.json) | SPK: `Super---ffbd4e1f_a342_4080_ab7d_1de3741bf319---Power`
|
||||||
- **abstract class Grep** | [Details](src/1401a167-0ce4-4f4a-afee-2d8b02ed339b) | [Code](src/1401a167-0ce4-4f4a-afee-2d8b02ed339b/code.php) | [Settings](src/1401a167-0ce4-4f4a-afee-2d8b02ed339b/settings.json) | SPK: `Super---1401a167_0ce4_4f4a_afee_2d8b02ed339b---Power`
|
- **abstract class Grep** | [Details](src/1401a167-0ce4-4f4a-afee-2d8b02ed339b) | [Code](src/1401a167-0ce4-4f4a-afee-2d8b02ed339b/code.php) | [Settings](src/1401a167-0ce4-4f4a-afee-2d8b02ed339b/settings.json) | SPK: `Super---1401a167_0ce4_4f4a_afee_2d8b02ed339b---Power`
|
||||||
- **abstract class Model** | [Details](src/584747d1-3a86-453d-b7a3-a2219de8d777) | [Code](src/584747d1-3a86-453d-b7a3-a2219de8d777/code.php) | [Settings](src/584747d1-3a86-453d-b7a3-a2219de8d777/settings.json) | SPK: `Super---584747d1_3a86_453d_b7a3_a2219de8d777---Power`
|
- **abstract class Model** | [Details](src/584747d1-3a86-453d-b7a3-a2219de8d777) | [Code](src/584747d1-3a86-453d-b7a3-a2219de8d777/code.php) | [Settings](src/584747d1-3a86-453d-b7a3-a2219de8d777/settings.json) | SPK: `Super---584747d1_3a86_453d_b7a3_a2219de8d777---Power`
|
||||||
- **abstract class PHPConfigurationChecker** | [Details](src/900456a2-feb5-48b9-9f05-c5a032a32c59) | [Code](src/900456a2-feb5-48b9-9f05-c5a032a32c59/code.php) | [Settings](src/900456a2-feb5-48b9-9f05-c5a032a32c59/settings.json) | SPK: `Super---900456a2_feb5_48b9_9f05_c5a032a32c59---Power`
|
- **abstract class PHPConfigurationChecker** | [Details](src/900456a2-feb5-48b9-9f05-c5a032a32c59) | [Code](src/900456a2-feb5-48b9-9f05-c5a032a32c59/code.php) | [Settings](src/900456a2-feb5-48b9-9f05-c5a032a32c59/settings.json) | SPK: `Super---900456a2_feb5_48b9_9f05_c5a032a32c59---Power`
|
||||||
@ -109,6 +109,7 @@ This repository contains an index (see below) of all the approved powers within
|
|||||||
- **Namespace**: [VDM\Joomla\Componentbuilder\Abstraction](#vdm-joomla-componentbuilder-abstraction)
|
- **Namespace**: [VDM\Joomla\Componentbuilder\Abstraction](#vdm-joomla-componentbuilder-abstraction)
|
||||||
|
|
||||||
- **abstract class BaseRegistry** | [Details](src/b84e947d-2a13-44f7-ac0f-3902ae55ae0c) | [Code](src/b84e947d-2a13-44f7-ac0f-3902ae55ae0c/code.php) | [Settings](src/b84e947d-2a13-44f7-ac0f-3902ae55ae0c/settings.json) | SPK: `Super---b84e947d_2a13_44f7_ac0f_3902ae55ae0c---Power`
|
- **abstract class BaseRegistry** | [Details](src/b84e947d-2a13-44f7-ac0f-3902ae55ae0c) | [Code](src/b84e947d-2a13-44f7-ac0f-3902ae55ae0c/code.php) | [Settings](src/b84e947d-2a13-44f7-ac0f-3902ae55ae0c/settings.json) | SPK: `Super---b84e947d_2a13_44f7_ac0f_3902ae55ae0c---Power`
|
||||||
|
- **abstract class ComponentConfig** | [Details](src/9769f3b2-17bf-4f20-b54b-3a4ebe572b36) | [Code](src/9769f3b2-17bf-4f20-b54b-3a4ebe572b36/code.php) | [Settings](src/9769f3b2-17bf-4f20-b54b-3a4ebe572b36/settings.json) | SPK: `Super---9769f3b2_17bf_4f20_b54b_3a4ebe572b36---Power`
|
||||||
- **Namespace**: [VDM\Joomla\Componentbuilder\File](#vdm-joomla-componentbuilder-file)
|
- **Namespace**: [VDM\Joomla\Componentbuilder\File](#vdm-joomla-componentbuilder-file)
|
||||||
|
|
||||||
- **abstract class Factory** | [Details](src/884eca78-281f-4eab-b962-d97e355af16d) | [Code](src/884eca78-281f-4eab-b962-d97e355af16d/code.php) | [Settings](src/884eca78-281f-4eab-b962-d97e355af16d/settings.json) | SPK: `Super---884eca78_281f_4eab_b962_d97e355af16d---Power`
|
- **abstract class Factory** | [Details](src/884eca78-281f-4eab-b962-d97e355af16d) | [Code](src/884eca78-281f-4eab-b962-d97e355af16d/code.php) | [Settings](src/884eca78-281f-4eab-b962-d97e355af16d/settings.json) | SPK: `Super---884eca78_281f_4eab_b962_d97e355af16d---Power`
|
||||||
@ -193,12 +194,12 @@ This repository contains an index (see below) of all the approved powers within
|
|||||||
- **abstract class TypeHelper** | [Details](src/a8935cbe-7701-40dc-bfd5-675f2d600954) | [Code](src/a8935cbe-7701-40dc-bfd5-675f2d600954/code.php) | [Settings](src/a8935cbe-7701-40dc-bfd5-675f2d600954/settings.json) | SPK: `Super---a8935cbe_7701_40dc_bfd5_675f2d600954---Power`
|
- **abstract class TypeHelper** | [Details](src/a8935cbe-7701-40dc-bfd5-675f2d600954) | [Code](src/a8935cbe-7701-40dc-bfd5-675f2d600954/code.php) | [Settings](src/a8935cbe-7701-40dc-bfd5-675f2d600954/settings.json) | SPK: `Super---a8935cbe_7701_40dc_bfd5_675f2d600954---Power`
|
||||||
- **Namespace**: [VDM\Joomla\Abstraction\Registry\Traits](#vdm-joomla-abstraction-registry-traits)
|
- **Namespace**: [VDM\Joomla\Abstraction\Registry\Traits](#vdm-joomla-abstraction-registry-traits)
|
||||||
|
|
||||||
- **trait Count** | [Details](src/11572d9b-e3d5-4b29-904c-9618d8f2bfd8) | [Code](src/11572d9b-e3d5-4b29-904c-9618d8f2bfd8/code.php) | [Settings](src/11572d9b-e3d5-4b29-904c-9618d8f2bfd8/settings.json) | SPK: `Super---11572d9b_e3d5_4b29_904c_9618d8f2bfd8---Power`
|
|
||||||
- **trait GetString** | [Details](src/59b1a2ea-d77e-4040-ac8c-e65cd8743e9b) | [Code](src/59b1a2ea-d77e-4040-ac8c-e65cd8743e9b/code.php) | [Settings](src/59b1a2ea-d77e-4040-ac8c-e65cd8743e9b/settings.json) | SPK: `Super---59b1a2ea_d77e_4040_ac8c_e65cd8743e9b---Power`
|
- **trait GetString** | [Details](src/59b1a2ea-d77e-4040-ac8c-e65cd8743e9b) | [Code](src/59b1a2ea-d77e-4040-ac8c-e65cd8743e9b/code.php) | [Settings](src/59b1a2ea-d77e-4040-ac8c-e65cd8743e9b/settings.json) | SPK: `Super---59b1a2ea_d77e_4040_ac8c_e65cd8743e9b---Power`
|
||||||
- **trait InArray** | [Details](src/215b35ac-1b26-4838-bbcf-d1fdbbd9353f) | [Code](src/215b35ac-1b26-4838-bbcf-d1fdbbd9353f/code.php) | [Settings](src/215b35ac-1b26-4838-bbcf-d1fdbbd9353f/settings.json) | SPK: `Super---215b35ac_1b26_4838_bbcf_d1fdbbd9353f---Power`
|
- **trait InArray** | [Details](src/215b35ac-1b26-4838-bbcf-d1fdbbd9353f) | [Code](src/215b35ac-1b26-4838-bbcf-d1fdbbd9353f/code.php) | [Settings](src/215b35ac-1b26-4838-bbcf-d1fdbbd9353f/settings.json) | SPK: `Super---215b35ac_1b26_4838_bbcf_d1fdbbd9353f---Power`
|
||||||
- **trait IsArray** | [Details](src/c09e8968-c767-4175-bb3d-8432f206a2c7) | [Code](src/c09e8968-c767-4175-bb3d-8432f206a2c7/code.php) | [Settings](src/c09e8968-c767-4175-bb3d-8432f206a2c7/settings.json) | SPK: `Super---c09e8968_c767_4175_bb3d_8432f206a2c7---Power`
|
- **trait IsArray** | [Details](src/c09e8968-c767-4175-bb3d-8432f206a2c7) | [Code](src/c09e8968-c767-4175-bb3d-8432f206a2c7/code.php) | [Settings](src/c09e8968-c767-4175-bb3d-8432f206a2c7/settings.json) | SPK: `Super---c09e8968_c767_4175_bb3d_8432f206a2c7---Power`
|
||||||
- **trait IsString** | [Details](src/ff7d0111-8f79-42aa-ac14-b53ba2c49369) | [Code](src/ff7d0111-8f79-42aa-ac14-b53ba2c49369/code.php) | [Settings](src/ff7d0111-8f79-42aa-ac14-b53ba2c49369/settings.json) | SPK: `Super---ff7d0111_8f79_42aa_ac14_b53ba2c49369---Power`
|
- **trait IsString** | [Details](src/ff7d0111-8f79-42aa-ac14-b53ba2c49369) | [Code](src/ff7d0111-8f79-42aa-ac14-b53ba2c49369/code.php) | [Settings](src/ff7d0111-8f79-42aa-ac14-b53ba2c49369/settings.json) | SPK: `Super---ff7d0111_8f79_42aa_ac14_b53ba2c49369---Power`
|
||||||
- **trait ToString** | [Details](src/7d494d91-ab60-43cd-aecf-d50e07f7f30e) | [Code](src/7d494d91-ab60-43cd-aecf-d50e07f7f30e/code.php) | [Settings](src/7d494d91-ab60-43cd-aecf-d50e07f7f30e/settings.json) | SPK: `Super---7d494d91_ab60_43cd_aecf_d50e07f7f30e---Power`
|
- **trait PathCount** | [Details](src/11572d9b-e3d5-4b29-904c-9618d8f2bfd8) | [Code](src/11572d9b-e3d5-4b29-904c-9618d8f2bfd8/code.php) | [Settings](src/11572d9b-e3d5-4b29-904c-9618d8f2bfd8/settings.json) | SPK: `Super---11572d9b_e3d5_4b29_904c_9618d8f2bfd8---Power`
|
||||||
|
- **trait PathToString** | [Details](src/7d494d91-ab60-43cd-aecf-d50e07f7f30e) | [Code](src/7d494d91-ab60-43cd-aecf-d50e07f7f30e/code.php) | [Settings](src/7d494d91-ab60-43cd-aecf-d50e07f7f30e/settings.json) | SPK: `Super---7d494d91_ab60_43cd_aecf_d50e07f7f30e---Power`
|
||||||
- **trait VarExport** | [Details](src/52a1d14f-304a-431c-8fa4-411179942db5) | [Code](src/52a1d14f-304a-431c-8fa4-411179942db5/code.php) | [Settings](src/52a1d14f-304a-431c-8fa4-411179942db5/settings.json) | SPK: `Super---52a1d14f_304a_431c_8fa4_411179942db5---Power`
|
- **trait VarExport** | [Details](src/52a1d14f-304a-431c-8fa4-411179942db5) | [Code](src/52a1d14f-304a-431c-8fa4-411179942db5/code.php) | [Settings](src/52a1d14f-304a-431c-8fa4-411179942db5/settings.json) | SPK: `Super---52a1d14f_304a_431c_8fa4_411179942db5---Power`
|
||||||
- **Namespace**: [VDM\Joomla\Componentbuilder\File\Service](#vdm-joomla-componentbuilder-file-service)
|
- **Namespace**: [VDM\Joomla\Componentbuilder\File\Service](#vdm-joomla-componentbuilder-file-service)
|
||||||
|
|
||||||
|
@ -6,16 +6,16 @@
|
|||||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||||
```
|
```
|
||||||
# trait Count (Details)
|
# trait PathCount (Details)
|
||||||
> namespace: **VDM\Joomla\Abstraction\Registry\Traits**
|
> namespace: **VDM\Joomla\Abstraction\Registry\Traits**
|
||||||
|
|
||||||
```uml
|
```uml
|
||||||
@startuml
|
@startuml
|
||||||
class Count << (T,Orange) >> #Turquoise {
|
class PathCount << (T,Orange) >> #Turquoise {
|
||||||
+ count(string $path) : int
|
+ pathCount(string $path) : int
|
||||||
}
|
}
|
||||||
|
|
||||||
note right of Count::count
|
note right of PathCount::pathCount
|
||||||
Retrieves number of values (or sub-array) from the storage using multiple keys.
|
Retrieves number of values (or sub-array) from the storage using multiple keys.
|
||||||
|
|
||||||
since: 3.2.0
|
since: 3.2.0
|
||||||
|
@ -13,11 +13,12 @@ namespace VDM\Joomla\Abstraction\Registry\Traits;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Count Values
|
* Count Values in a Path
|
||||||
*
|
*
|
||||||
* @since 3.2.0
|
* @since 3.2.0
|
||||||
|
* @since 5.0.2 name changed to PathCount to avoid collusion in core registry class
|
||||||
*/
|
*/
|
||||||
trait Count
|
trait PathCount
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Retrieves number of values (or sub-array) from the storage using multiple keys.
|
* Retrieves number of values (or sub-array) from the storage using multiple keys.
|
||||||
@ -28,7 +29,7 @@ trait Count
|
|||||||
* @return int The number of values
|
* @return int The number of values
|
||||||
* @since 3.2.0
|
* @since 3.2.0
|
||||||
*/
|
*/
|
||||||
public function count(string $path): int
|
public function pathCount(string $path): int
|
||||||
{
|
{
|
||||||
if (($values = $this->get($path)) === null)
|
if (($values = $this->get($path)) === null)
|
||||||
{
|
{
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* @return int The number of values
|
* @return int The number of values
|
||||||
* @since 3.2.0
|
* @since 3.2.0
|
||||||
*/
|
*/
|
||||||
public function count(string $path): int
|
public function pathCount(string $path): int
|
||||||
{
|
{
|
||||||
if (($values = $this->get($path)) === null)
|
if (($values = $this->get($path)) === null)
|
||||||
{
|
{
|
||||||
|
@ -5,14 +5,14 @@
|
|||||||
"guid": "11572d9b-e3d5-4b29-904c-9618d8f2bfd8",
|
"guid": "11572d9b-e3d5-4b29-904c-9618d8f2bfd8",
|
||||||
"implements": null,
|
"implements": null,
|
||||||
"load_selection": null,
|
"load_selection": null,
|
||||||
"name": "Count",
|
"name": "PathCount",
|
||||||
"power_version": "1.0.0",
|
"power_version": "1.0.0",
|
||||||
"system_name": "VDM.Abstraction.Registry.Traits.Count",
|
"system_name": "VDM.Abstraction.Registry.Traits.PathCount",
|
||||||
"type": "trait",
|
"type": "trait",
|
||||||
"use_selection": null,
|
"use_selection": null,
|
||||||
"extendsinterfaces": null,
|
"extendsinterfaces": null,
|
||||||
"namespace": "[[[NamespacePrefix]]]\\Joomla\\Abstraction.Registry.Traits.Count",
|
"namespace": "[[[NamespacePrefix]]]\\Joomla\\Abstraction.Registry.Traits.PathCount",
|
||||||
"description": "Count Values\r\n\r\n@since 3.2.0",
|
"description": "Count Values in a Path\r\n\r\n@since 3.2.0\r\n@since 5.0.2 name changed to PathCount to avoid collusion in core registry class",
|
||||||
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\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",
|
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\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": "",
|
"head": "",
|
||||||
"composer": ""
|
"composer": ""
|
||||||
|
@ -14,10 +14,12 @@
|
|||||||
abstract Grep #Orange {
|
abstract Grep #Orange {
|
||||||
+ ?string $path
|
+ ?string $path
|
||||||
+ ?array $paths
|
+ ?array $paths
|
||||||
|
# ?string $target
|
||||||
# array $order
|
# array $order
|
||||||
# Contents $contents
|
# Contents $contents
|
||||||
|
# Resolve $resolve
|
||||||
# CMSApplication $app
|
# CMSApplication $app
|
||||||
+ __construct(Contents $contents, array $paths, ...)
|
+ __construct(Contents $contents, Resolve $resolve, ...)
|
||||||
+ get(string $guid, ?array $order = null, ...) : ?object
|
+ get(string $guid, ?array $order = null, ...) : ?object
|
||||||
+ exists(string $guid, ?object $repo = null, ...) : bool
|
+ exists(string $guid, ?object $repo = null, ...) : bool
|
||||||
+ getRemoteGuid() : ?array
|
+ getRemoteGuid() : ?array
|
||||||
@ -25,6 +27,7 @@ abstract Grep #Orange {
|
|||||||
+ setBranchDefaultName(?string $name) : void
|
+ setBranchDefaultName(?string $name) : void
|
||||||
+ setIndexPath(string $indexPath) : void
|
+ setIndexPath(string $indexPath) : void
|
||||||
+ getRemoteIndex(string $guid) : ?object
|
+ getRemoteIndex(string $guid) : ?object
|
||||||
|
+ loadApi(Api $api, ?string $base, ...) : void
|
||||||
# {abstract} setRemoteIndexMessage(string $message, string $path, ...) : void
|
# {abstract} setRemoteIndexMessage(string $message, string $path, ...) : void
|
||||||
# getFunctionName(string $name, string $type = 'search') : ?string
|
# getFunctionName(string $name, string $type = 'search') : ?string
|
||||||
# searchSingleRepo(string $guid, array $order, ...) : ?object
|
# searchSingleRepo(string $guid, array $order, ...) : ?object
|
||||||
@ -53,6 +56,7 @@ note right of Grep::__construct
|
|||||||
|
|
||||||
arguments:
|
arguments:
|
||||||
Contents $contents
|
Contents $contents
|
||||||
|
Resolve $resolve
|
||||||
array $paths
|
array $paths
|
||||||
?string $path = null
|
?string $path = null
|
||||||
?CMSApplication $app = null
|
?CMSApplication $app = null
|
||||||
@ -117,7 +121,22 @@ note left of Grep::getRemoteIndex
|
|||||||
return: ?object
|
return: ?object
|
||||||
end note
|
end note
|
||||||
|
|
||||||
note right of Grep::setRemoteIndexMessage
|
note right of Grep::loadApi
|
||||||
|
Loads API config using the provided base URL and token.
|
||||||
|
This method checks if the base URL contains 'https://git.vdm.dev/'.
|
||||||
|
If it does, it uses the token as is (which may be null).
|
||||||
|
If not, it ensures the token is not null by defaulting to an empty string.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: void
|
||||||
|
|
||||||
|
arguments:
|
||||||
|
Api $api
|
||||||
|
?string $base
|
||||||
|
?string $token
|
||||||
|
end note
|
||||||
|
|
||||||
|
note left of Grep::setRemoteIndexMessage
|
||||||
Set repository messages and errors based on given conditions.
|
Set repository messages and errors based on given conditions.
|
||||||
|
|
||||||
since: 3.2.0
|
since: 3.2.0
|
||||||
@ -131,14 +150,14 @@ note right of Grep::setRemoteIndexMessage
|
|||||||
?string $base
|
?string $base
|
||||||
end note
|
end note
|
||||||
|
|
||||||
note left of Grep::getFunctionName
|
note right of Grep::getFunctionName
|
||||||
Get function name
|
Get function name
|
||||||
|
|
||||||
since: 3.2.0
|
since: 3.2.0
|
||||||
return: ?string
|
return: ?string
|
||||||
end note
|
end note
|
||||||
|
|
||||||
note right of Grep::searchSingleRepo
|
note left of Grep::searchSingleRepo
|
||||||
Search a single repository for an item
|
Search a single repository for an item
|
||||||
|
|
||||||
since: 3.2.2
|
since: 3.2.2
|
||||||
@ -150,14 +169,14 @@ note right of Grep::searchSingleRepo
|
|||||||
object $repo
|
object $repo
|
||||||
end note
|
end note
|
||||||
|
|
||||||
note left of Grep::searchAllRepos
|
note right of Grep::searchAllRepos
|
||||||
Search all repositories for an item
|
Search all repositories for an item
|
||||||
|
|
||||||
since: 3.2.2
|
since: 3.2.2
|
||||||
return: ?object
|
return: ?object
|
||||||
end note
|
end note
|
||||||
|
|
||||||
note right of Grep::itemExistsInRepo
|
note left of Grep::itemExistsInRepo
|
||||||
Check if an item exists in a specific repository.
|
Check if an item exists in a specific repository.
|
||||||
|
|
||||||
since: 3.2.2
|
since: 3.2.2
|
||||||
@ -169,42 +188,42 @@ note right of Grep::itemExistsInRepo
|
|||||||
array $order
|
array $order
|
||||||
end note
|
end note
|
||||||
|
|
||||||
note left of Grep::itemExistsInAllRepos
|
note right of Grep::itemExistsInAllRepos
|
||||||
Check if an item exists in any of the repositories.
|
Check if an item exists in any of the repositories.
|
||||||
|
|
||||||
since: 3.2.2
|
since: 3.2.2
|
||||||
return: bool
|
return: bool
|
||||||
end note
|
end note
|
||||||
|
|
||||||
note right of Grep::getBranchField
|
note left of Grep::getBranchField
|
||||||
Get the branch field
|
Get the branch field
|
||||||
|
|
||||||
since: 3.2.2
|
since: 3.2.2
|
||||||
return: string
|
return: string
|
||||||
end note
|
end note
|
||||||
|
|
||||||
note left of Grep::getBranchDefaultName
|
note right of Grep::getBranchDefaultName
|
||||||
Get the branch default name
|
Get the branch default name
|
||||||
|
|
||||||
since: 3.2.2
|
since: 3.2.2
|
||||||
return: ?string
|
return: ?string
|
||||||
end note
|
end note
|
||||||
|
|
||||||
note right of Grep::getBranchName
|
note left of Grep::getBranchName
|
||||||
Get the branch name
|
Get the branch name
|
||||||
|
|
||||||
since: 3.2.2
|
since: 3.2.2
|
||||||
return: ?string
|
return: ?string
|
||||||
end note
|
end note
|
||||||
|
|
||||||
note left of Grep::getIndexPath
|
note right of Grep::getIndexPath
|
||||||
Get the index path
|
Get the index path
|
||||||
|
|
||||||
since: 3.2.2
|
since: 3.2.2
|
||||||
return: string
|
return: string
|
||||||
end note
|
end note
|
||||||
|
|
||||||
note right of Grep::itemExists
|
note left of Grep::itemExists
|
||||||
Check if an item exists in a specific repo and target.
|
Check if an item exists in a specific repo and target.
|
||||||
|
|
||||||
since: 3.2.2
|
since: 3.2.2
|
||||||
@ -216,56 +235,56 @@ note right of Grep::itemExists
|
|||||||
string $target
|
string $target
|
||||||
end note
|
end note
|
||||||
|
|
||||||
note left of Grep::existsLocally
|
note right of Grep::existsLocally
|
||||||
Check if item exists locally
|
Check if item exists locally
|
||||||
|
|
||||||
since: 3.2.2
|
since: 3.2.2
|
||||||
return: ?object
|
return: ?object
|
||||||
end note
|
end note
|
||||||
|
|
||||||
note right of Grep::existsRemotely
|
note left of Grep::existsRemotely
|
||||||
Check if item exists remotely
|
Check if item exists remotely
|
||||||
|
|
||||||
since: 3.2.2
|
since: 3.2.2
|
||||||
return: ?object
|
return: ?object
|
||||||
end note
|
end note
|
||||||
|
|
||||||
note left of Grep::existsLocal
|
note right of Grep::existsLocal
|
||||||
Check if item exists locally
|
Check if item exists locally
|
||||||
|
|
||||||
since: 3.2.2
|
since: 3.2.2
|
||||||
return: bool
|
return: bool
|
||||||
end note
|
end note
|
||||||
|
|
||||||
note right of Grep::existsRemote
|
note left of Grep::existsRemote
|
||||||
Check if item exists remotely
|
Check if item exists remotely
|
||||||
|
|
||||||
since: 3.2.2
|
since: 3.2.2
|
||||||
return: bool
|
return: bool
|
||||||
end note
|
end note
|
||||||
|
|
||||||
note left of Grep::indexRemote
|
note right of Grep::indexRemote
|
||||||
Load the remote repository index of powers
|
Load the remote repository index of powers
|
||||||
|
|
||||||
since: 3.2.0
|
since: 3.2.0
|
||||||
return: void
|
return: void
|
||||||
end note
|
end note
|
||||||
|
|
||||||
note right of Grep::indexLocal
|
note left of Grep::indexLocal
|
||||||
Load the local repository index of powers
|
Load the local repository index of powers
|
||||||
|
|
||||||
since: 3.2.0
|
since: 3.2.0
|
||||||
return: void
|
return: void
|
||||||
end note
|
end note
|
||||||
|
|
||||||
note left of Grep::initializeInstances
|
note right of Grep::initializeInstances
|
||||||
Set path details
|
Set path details
|
||||||
|
|
||||||
since: 3.2.0
|
since: 3.2.0
|
||||||
return: void
|
return: void
|
||||||
end note
|
end note
|
||||||
|
|
||||||
note right of Grep::loadRemoteFile
|
note left of Grep::loadRemoteFile
|
||||||
Load the remote file
|
Load the remote file
|
||||||
|
|
||||||
since: 3.2.0
|
since: 3.2.0
|
||||||
|
@ -17,6 +17,8 @@ use Joomla\CMS\Language\Text;
|
|||||||
use Joomla\CMS\Filesystem\Folder;
|
use Joomla\CMS\Filesystem\Folder;
|
||||||
use Joomla\CMS\Application\CMSApplication;
|
use Joomla\CMS\Application\CMSApplication;
|
||||||
use VDM\Joomla\Gitea\Repository\Contents;
|
use VDM\Joomla\Gitea\Repository\Contents;
|
||||||
|
use VDM\Joomla\Interfaces\Git\ApiInterface as Api;
|
||||||
|
use VDM\Joomla\Componentbuilder\Network\Resolve;
|
||||||
use VDM\Joomla\Utilities\FileHelper;
|
use VDM\Joomla\Utilities\FileHelper;
|
||||||
use VDM\Joomla\Utilities\JsonHelper;
|
use VDM\Joomla\Utilities\JsonHelper;
|
||||||
use VDM\Joomla\Interfaces\GrepInterface;
|
use VDM\Joomla\Interfaces\GrepInterface;
|
||||||
@ -50,6 +52,14 @@ abstract class Grep implements GrepInterface
|
|||||||
**/
|
**/
|
||||||
public ?array $paths;
|
public ?array $paths;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Grep target [network]
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 5.0.4
|
||||||
|
**/
|
||||||
|
protected ?string $target = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Order of global search
|
* Order of global search
|
||||||
*
|
*
|
||||||
@ -82,6 +92,14 @@ abstract class Grep implements GrepInterface
|
|||||||
*/
|
*/
|
||||||
protected string $index_path = 'index.json';
|
protected string $index_path = 'index.json';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The VDM global API base
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 5.0.4
|
||||||
|
**/
|
||||||
|
protected string $api_base = '//git.vdm.dev/';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gitea Repository Contents
|
* Gitea Repository Contents
|
||||||
*
|
*
|
||||||
@ -90,6 +108,14 @@ abstract class Grep implements GrepInterface
|
|||||||
**/
|
**/
|
||||||
protected Contents $contents;
|
protected Contents $contents;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Resolve Class.
|
||||||
|
*
|
||||||
|
* @var Resolve
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
protected Resolve $resolve;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Joomla Application object
|
* Joomla Application object
|
||||||
*
|
*
|
||||||
@ -102,6 +128,7 @@ abstract class Grep implements GrepInterface
|
|||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param Contents $contents The Gitea Repository Contents object.
|
* @param Contents $contents The Gitea Repository Contents object.
|
||||||
|
* @param Resolve $resolve The Resolve Class.
|
||||||
* @param array $paths The approved paths
|
* @param array $paths The approved paths
|
||||||
* @param string|null $path The local path
|
* @param string|null $path The local path
|
||||||
* @param CMSApplication|null $app The CMS Application object.
|
* @param CMSApplication|null $app The CMS Application object.
|
||||||
@ -109,9 +136,13 @@ abstract class Grep implements GrepInterface
|
|||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
* @since 3.2.0
|
* @since 3.2.0
|
||||||
*/
|
*/
|
||||||
public function __construct(Contents $contents, array $paths, ?string $path = null, ?CMSApplication $app = null)
|
public function __construct(
|
||||||
|
Contents $contents, Resolve $resolve,
|
||||||
|
array $paths, ?string $path = null,
|
||||||
|
?CMSApplication $app = null)
|
||||||
{
|
{
|
||||||
$this->contents = $contents;
|
$this->contents = $contents;
|
||||||
|
$this->resolve = $resolve;
|
||||||
$this->paths = $paths;
|
$this->paths = $paths;
|
||||||
$this->path = $path;
|
$this->path = $path;
|
||||||
$this->app = $app ?: Factory::getApplication();
|
$this->app = $app ?: Factory::getApplication();
|
||||||
@ -264,6 +295,38 @@ abstract class Grep implements GrepInterface
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads API config using the provided base URL and token.
|
||||||
|
*
|
||||||
|
* This method checks if the base URL contains 'https://git.vdm.dev/'.
|
||||||
|
* If it does, it uses the token as is (which may be null).
|
||||||
|
* If not, it ensures the token is not null by defaulting to an empty string.
|
||||||
|
*
|
||||||
|
* @param Api $api The api object with a load_ method.
|
||||||
|
* @param string|null $base The base URL path.
|
||||||
|
* @param string|null $token The token for authentication (can be null).
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function loadApi(Api $api, ?string $base, ?string $token): void
|
||||||
|
{
|
||||||
|
// Determine the token to use based on the base URL
|
||||||
|
if ($base && strpos($base, $this->api_base) !== false)
|
||||||
|
{
|
||||||
|
// If base contains $this->api_base = https://git.vdm.dev/, use the token as is
|
||||||
|
$tokenToUse = $token;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Otherwise, ensure the token is not null (use empty string if null)
|
||||||
|
$tokenToUse = $token ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load the content with the determined base and token
|
||||||
|
$api->load_($base, $tokenToUse);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set repository messages and errors based on given conditions.
|
* Set repository messages and errors based on given conditions.
|
||||||
*
|
*
|
||||||
@ -584,7 +647,7 @@ abstract class Grep implements GrepInterface
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// load the base and token if set
|
// load the base and token if set
|
||||||
$this->contents->load_($path->base ?? null, $path->token ?? null);
|
$this->loadApi($this->contents, $path->base ?? null, $path->token ?? null);
|
||||||
$path->index = $this->contents->get($path->organisation, $path->repository, $this->getIndexPath(), $this->getBranchName($path));
|
$path->index = $this->contents->get($path->organisation, $path->repository, $this->getIndexPath(), $this->getBranchName($path));
|
||||||
}
|
}
|
||||||
catch (\Exception $e)
|
catch (\Exception $e)
|
||||||
@ -640,6 +703,12 @@ abstract class Grep implements GrepInterface
|
|||||||
if (isset($path->organisation) && strlen($path->organisation) > 1 &&
|
if (isset($path->organisation) && strlen($path->organisation) > 1 &&
|
||||||
isset($path->repository) && strlen($path->repository) > 1)
|
isset($path->repository) && strlen($path->repository) > 1)
|
||||||
{
|
{
|
||||||
|
// resolve API if needed
|
||||||
|
if (!empty($path->base))
|
||||||
|
{
|
||||||
|
$this->resolve->api($this->target ?? $path->repository, $path->base, $path->organisation, $path->repository);
|
||||||
|
}
|
||||||
|
|
||||||
// build the path
|
// build the path
|
||||||
$path->path = trim($path->organisation) . '/' . trim($path->repository);
|
$path->path = trim($path->organisation) . '/' . trim($path->repository);
|
||||||
|
|
||||||
|
@ -14,6 +14,14 @@
|
|||||||
**/
|
**/
|
||||||
public ?array $paths;
|
public ?array $paths;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Grep target [network]
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 5.0.4
|
||||||
|
**/
|
||||||
|
protected ?string $target = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Order of global search
|
* Order of global search
|
||||||
*
|
*
|
||||||
@ -46,6 +54,14 @@
|
|||||||
*/
|
*/
|
||||||
protected string $index_path = 'index.json';
|
protected string $index_path = 'index.json';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The VDM global API base
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 5.0.4
|
||||||
|
**/
|
||||||
|
protected string $api_base = '//git.vdm.dev/';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gitea Repository Contents
|
* Gitea Repository Contents
|
||||||
*
|
*
|
||||||
@ -54,6 +70,14 @@
|
|||||||
**/
|
**/
|
||||||
protected Contents $contents;
|
protected Contents $contents;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Resolve Class.
|
||||||
|
*
|
||||||
|
* @var Resolve
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
protected Resolve $resolve;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Joomla Application object
|
* Joomla Application object
|
||||||
*
|
*
|
||||||
@ -66,6 +90,7 @@
|
|||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param Contents $contents The Gitea Repository Contents object.
|
* @param Contents $contents The Gitea Repository Contents object.
|
||||||
|
* @param Resolve $resolve The Resolve Class.
|
||||||
* @param array $paths The approved paths
|
* @param array $paths The approved paths
|
||||||
* @param string|null $path The local path
|
* @param string|null $path The local path
|
||||||
* @param CMSApplication|null $app The CMS Application object.
|
* @param CMSApplication|null $app The CMS Application object.
|
||||||
@ -73,9 +98,13 @@
|
|||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
* @since 3.2.0
|
* @since 3.2.0
|
||||||
*/
|
*/
|
||||||
public function __construct(Contents $contents, array $paths, ?string $path = null, ?CMSApplication $app = null)
|
public function __construct(
|
||||||
|
Contents $contents, Resolve $resolve,
|
||||||
|
array $paths, ?string $path = null,
|
||||||
|
?CMSApplication $app = null)
|
||||||
{
|
{
|
||||||
$this->contents = $contents;
|
$this->contents = $contents;
|
||||||
|
$this->resolve = $resolve;
|
||||||
$this->paths = $paths;
|
$this->paths = $paths;
|
||||||
$this->path = $path;
|
$this->path = $path;
|
||||||
$this->app = $app ?: Factory::getApplication();
|
$this->app = $app ?: Factory::getApplication();
|
||||||
@ -228,6 +257,38 @@
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads API config using the provided base URL and token.
|
||||||
|
*
|
||||||
|
* This method checks if the base URL contains 'https://git.vdm.dev/'.
|
||||||
|
* If it does, it uses the token as is (which may be null).
|
||||||
|
* If not, it ensures the token is not null by defaulting to an empty string.
|
||||||
|
*
|
||||||
|
* @param Api $api The api object with a load_ method.
|
||||||
|
* @param string|null $base The base URL path.
|
||||||
|
* @param string|null $token The token for authentication (can be null).
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function loadApi(Api $api, ?string $base, ?string $token): void
|
||||||
|
{
|
||||||
|
// Determine the token to use based on the base URL
|
||||||
|
if ($base && strpos($base, $this->api_base) !== false)
|
||||||
|
{
|
||||||
|
// If base contains $this->api_base = https://git.vdm.dev/, use the token as is
|
||||||
|
$tokenToUse = $token;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Otherwise, ensure the token is not null (use empty string if null)
|
||||||
|
$tokenToUse = $token ?? '';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Load the content with the determined base and token
|
||||||
|
$api->load_($base, $tokenToUse);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set repository messages and errors based on given conditions.
|
* Set repository messages and errors based on given conditions.
|
||||||
*
|
*
|
||||||
@ -548,7 +609,7 @@
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// load the base and token if set
|
// load the base and token if set
|
||||||
$this->contents->load_($path->base ?? null, $path->token ?? null);
|
$this->loadApi($this->contents, $path->base ?? null, $path->token ?? null);
|
||||||
$path->index = $this->contents->get($path->organisation, $path->repository, $this->getIndexPath(), $this->getBranchName($path));
|
$path->index = $this->contents->get($path->organisation, $path->repository, $this->getIndexPath(), $this->getBranchName($path));
|
||||||
}
|
}
|
||||||
catch (\Exception $e)
|
catch (\Exception $e)
|
||||||
@ -604,6 +665,12 @@
|
|||||||
if (isset($path->organisation) && strlen($path->organisation) > 1 &&
|
if (isset($path->organisation) && strlen($path->organisation) > 1 &&
|
||||||
isset($path->repository) && strlen($path->repository) > 1)
|
isset($path->repository) && strlen($path->repository) > 1)
|
||||||
{
|
{
|
||||||
|
// resolve API if needed
|
||||||
|
if (!empty($path->base))
|
||||||
|
{
|
||||||
|
$this->resolve->api($this->target ?? $path->repository, $path->base, $path->organisation, $path->repository);
|
||||||
|
}
|
||||||
|
|
||||||
// build the path
|
// build the path
|
||||||
$path->path = trim($path->organisation) . '/' . trim($path->repository);
|
$path->path = trim($path->organisation) . '/' . trim($path->repository);
|
||||||
|
|
||||||
|
@ -17,10 +17,18 @@
|
|||||||
"as": "default"
|
"as": "default"
|
||||||
},
|
},
|
||||||
"use_selection1": {
|
"use_selection1": {
|
||||||
|
"use": "17ed2fec-49d6-4731-92c3-f9cd78fb6273",
|
||||||
|
"as": "Api"
|
||||||
|
},
|
||||||
|
"use_selection2": {
|
||||||
|
"use": "a0c143af-3d7d-4c19-91c4-f72060b4c361",
|
||||||
|
"as": "default"
|
||||||
|
},
|
||||||
|
"use_selection3": {
|
||||||
"use": "a223b31e-ea1d-4cdf-92ae-5f9becffaff0",
|
"use": "a223b31e-ea1d-4cdf-92ae-5f9becffaff0",
|
||||||
"as": "default"
|
"as": "default"
|
||||||
},
|
},
|
||||||
"use_selection2": {
|
"use_selection4": {
|
||||||
"use": "4b225c51-d293-48e4-b3f6-5136cf5c3f18",
|
"use": "4b225c51-d293-48e4-b3f6-5136cf5c3f18",
|
||||||
"as": "default"
|
"as": "default"
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace VDM\Joomla\Componentbuilder\Import;
|
namespace VDM\Joomla\Componentbuilder\Import;
|
||||||
|
|
||||||
|
|
||||||
|
use Joomla\CMS\Language\Text;
|
||||||
use VDM\Joomla\Componentbuilder\Import\Data;
|
use VDM\Joomla\Componentbuilder\Import\Data;
|
||||||
use VDM\Joomla\Componentbuilder\Interfaces\ImportStatusInterface as Status;
|
use VDM\Joomla\Componentbuilder\Interfaces\ImportStatusInterface as Status;
|
||||||
use VDM\Joomla\Componentbuilder\Interfaces\ImportMessageInterface as Message;
|
use VDM\Joomla\Componentbuilder\Interfaces\ImportMessageInterface as Message;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"add_head": "0",
|
"add_head": "1",
|
||||||
"add_licensing_template": "2",
|
"add_licensing_template": "2",
|
||||||
"extends": "",
|
"extends": "",
|
||||||
"guid": "19a66b48-620c-439b-ab8a-3c0d43e040c3",
|
"guid": "19a66b48-620c-439b-ab8a-3c0d43e040c3",
|
||||||
@ -29,6 +29,6 @@
|
|||||||
"namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Import.Assessor",
|
"namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Import.Assessor",
|
||||||
"description": "Import Assessor Class\r\n\r\n@since 4.0.3",
|
"description": "Import Assessor Class\r\n\r\n@since 4.0.3",
|
||||||
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\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",
|
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\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": "",
|
"head": "use Joomla\\CMS\\Language\\Text;",
|
||||||
"composer": ""
|
"composer": ""
|
||||||
}
|
}
|
@ -67,7 +67,7 @@ end note
|
|||||||
|
|
||||||
note left of Model::values
|
note left of Model::values
|
||||||
Model a value of multiple items
|
Model a value of multiple items
|
||||||
Example: $this->items(Array, 'value_key', 'table_name');
|
Example: $this->values(Array, 'value_key', 'table_name');
|
||||||
|
|
||||||
since: 3.2.2
|
since: 3.2.2
|
||||||
return: ?array
|
return: ?array
|
||||||
|
@ -109,7 +109,7 @@ abstract class Model implements ModelInterface
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Model a value of multiple items
|
* Model a value of multiple items
|
||||||
* Example: $this->items(Array, 'value_key', 'table_name');
|
* Example: $this->values(Array, 'value_key', 'table_name');
|
||||||
*
|
*
|
||||||
* @param array|null $items The array of values
|
* @param array|null $items The array of values
|
||||||
* @param string $field The field key
|
* @param string $field The field key
|
||||||
|
@ -82,7 +82,7 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Model a value of multiple items
|
* Model a value of multiple items
|
||||||
* Example: $this->items(Array, 'value_key', 'table_name');
|
* Example: $this->values(Array, 'value_key', 'table_name');
|
||||||
*
|
*
|
||||||
* @param array|null $items The array of values
|
* @param array|null $items The array of values
|
||||||
* @param string $field The field key
|
* @param string $field The field key
|
||||||
|
@ -13,14 +13,125 @@
|
|||||||
```uml
|
```uml
|
||||||
@startuml
|
@startuml
|
||||||
interface Registryinterface #Lavender {
|
interface Registryinterface #Lavender {
|
||||||
|
+ __get(string $name) : mixed
|
||||||
|
+ __set(string $name, mixed $value) : void
|
||||||
|
+ __isset(string $name) : bool
|
||||||
|
+ __unset(string $name) : void
|
||||||
|
+ __clone() : void
|
||||||
|
+ __toString() : string
|
||||||
|
+ loadString(string $data, string $format = 'JSON', ...) : self
|
||||||
|
+ loadObject(object $object) : self
|
||||||
|
+ loadArray(array $array) : self
|
||||||
|
+ loadFile(string $path, string $format = 'json') : self
|
||||||
+ set(string $path, mixed $value) : self
|
+ set(string $path, mixed $value) : self
|
||||||
+ add(string $path, mixed $value, ...) : self
|
+ add(string $path, mixed $value, ...) : self
|
||||||
+ get(string $path, mixed $default = null) : mixed
|
+ get(string $path, mixed $default = null) : mixed
|
||||||
+ remove(string $path) : self
|
+ remove(string $path) : self
|
||||||
+ exists(string $path) : bool
|
+ exists(string $path) : bool
|
||||||
|
+ jsonSerialize() : mixed
|
||||||
|
+ count() : int
|
||||||
|
+ offsetExists(mixed $offset) : bool
|
||||||
|
+ offsetGet(mixed $offset) : mixed
|
||||||
|
+ offsetSet(mixed $offset, mixed $value) : void
|
||||||
|
+ offsetUnset(mixed $offset) : void
|
||||||
|
+ getIterator() : \Traversable
|
||||||
|
+ toArray() : array
|
||||||
|
+ toObject() : object
|
||||||
|
+ toString(string $format = 'JSON', array $options = []) : string
|
||||||
|
+ flatten(?string $separator = null, bool $full = false) : array
|
||||||
|
+ def(string $path, mixed $default) : mixed
|
||||||
|
+ merge(Registryinterface $source) : self
|
||||||
|
+ clear() : self
|
||||||
|
+ extract(string $path, mixed $default = null, ...) : self
|
||||||
|
+ append(string $path, mixed $value) : self
|
||||||
|
+ getName() : ?string
|
||||||
|
+ setName(?string $name) : self
|
||||||
+ setSeparator(?string $value) : self
|
+ setSeparator(?string $value) : self
|
||||||
|
+ getSeparator() : ?string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
note right of Registryinterface::__get
|
||||||
|
Magic method to get a value from the registry.
|
||||||
|
Allows for accessing registry data using object property syntax.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: mixed
|
||||||
|
end note
|
||||||
|
|
||||||
|
note left of Registryinterface::__set
|
||||||
|
Magic method to set a value in the registry.
|
||||||
|
Allows for setting registry data using object property syntax.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: void
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Registryinterface::__isset
|
||||||
|
Magic method to check if a property is set in the registry.
|
||||||
|
Allows for using isset() on registry properties.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: bool
|
||||||
|
end note
|
||||||
|
|
||||||
|
note left of Registryinterface::__unset
|
||||||
|
Magic method to unset a property in the registry.
|
||||||
|
Allows for using unset() on registry properties.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: void
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Registryinterface::__clone
|
||||||
|
Magic method to clone the registry.
|
||||||
|
Performs a deep copy of the registry data.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: void
|
||||||
|
end note
|
||||||
|
|
||||||
|
note left of Registryinterface::__toString
|
||||||
|
Magic method to convert the registry to a string.
|
||||||
|
Returns the registry data in JSON format.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: string
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Registryinterface::loadString
|
||||||
|
Loads data into the registry from a string using Joomla's format classes.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: self
|
||||||
|
|
||||||
|
arguments:
|
||||||
|
string $data
|
||||||
|
string $format = 'JSON'
|
||||||
|
array $options = []
|
||||||
|
end note
|
||||||
|
|
||||||
|
note left of Registryinterface::loadObject
|
||||||
|
Loads data into the registry from an object.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: self
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Registryinterface::loadArray
|
||||||
|
Loads data into the registry from an array.
|
||||||
|
The loaded data will be merged into the registry's existing data.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: self
|
||||||
|
end note
|
||||||
|
|
||||||
|
note left of Registryinterface::loadFile
|
||||||
|
Loads data into the registry from a file.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: self
|
||||||
|
end note
|
||||||
|
|
||||||
note right of Registryinterface::set
|
note right of Registryinterface::set
|
||||||
Sets a value into the registry using multiple keys.
|
Sets a value into the registry using multiple keys.
|
||||||
|
|
||||||
@ -28,7 +139,7 @@ note right of Registryinterface::set
|
|||||||
return: self
|
return: self
|
||||||
end note
|
end note
|
||||||
|
|
||||||
note right of Registryinterface::add
|
note left of Registryinterface::add
|
||||||
Adds content into the registry. If a key exists,
|
Adds content into the registry. If a key exists,
|
||||||
it either appends or concatenates based on $asArray switch.
|
it either appends or concatenates based on $asArray switch.
|
||||||
Default is $addAsArray = false (if null) in base class.
|
Default is $addAsArray = false (if null) in base class.
|
||||||
@ -50,7 +161,7 @@ note right of Registryinterface::get
|
|||||||
return: mixed
|
return: mixed
|
||||||
end note
|
end note
|
||||||
|
|
||||||
note right of Registryinterface::remove
|
note left of Registryinterface::remove
|
||||||
Removes a value (or sub-array) from the registry using multiple keys.
|
Removes a value (or sub-array) from the registry using multiple keys.
|
||||||
|
|
||||||
since: 3.2.0
|
since: 3.2.0
|
||||||
@ -64,13 +175,155 @@ note right of Registryinterface::exists
|
|||||||
return: bool
|
return: bool
|
||||||
end note
|
end note
|
||||||
|
|
||||||
note right of Registryinterface::setSeparator
|
note left of Registryinterface::jsonSerialize
|
||||||
|
Specify data which should be serialized to JSON.
|
||||||
|
which is a value of any type other than a resource.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: mixed
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Registryinterface::count
|
||||||
|
Count elements of the registry.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: int
|
||||||
|
end note
|
||||||
|
|
||||||
|
note left of Registryinterface::offsetExists
|
||||||
|
Whether a given offset exists in the registry.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: bool
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Registryinterface::offsetGet
|
||||||
|
Retrieve the value at a given offset.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: mixed
|
||||||
|
end note
|
||||||
|
|
||||||
|
note left of Registryinterface::offsetSet
|
||||||
|
Set the value at a given offset.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: void
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Registryinterface::offsetUnset
|
||||||
|
Unset the value at a given offset.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: void
|
||||||
|
end note
|
||||||
|
|
||||||
|
note left of Registryinterface::getIterator
|
||||||
|
Retrieve an external iterator for the registry.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: \Traversable
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Registryinterface::toArray
|
||||||
|
Get the registry data as an associative array.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: array
|
||||||
|
end note
|
||||||
|
|
||||||
|
note left of Registryinterface::toObject
|
||||||
|
Get the registry data as an object.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: object
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Registryinterface::toString
|
||||||
|
Converts the registry data to a string in the specified format.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: string
|
||||||
|
end note
|
||||||
|
|
||||||
|
note left of Registryinterface::flatten
|
||||||
|
Flattens the registry data into a one-dimensional array.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: array
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Registryinterface::def
|
||||||
|
Sets a default value if not already set.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: mixed
|
||||||
|
end note
|
||||||
|
|
||||||
|
note left of Registryinterface::merge
|
||||||
|
Merges another registry into this one.
|
||||||
|
The data from the source registry will be merged into this registry,
|
||||||
|
overwriting any existing values with the same keys.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: self
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Registryinterface::clear
|
||||||
|
Clears all data from the registry.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: self
|
||||||
|
end note
|
||||||
|
|
||||||
|
note left of Registryinterface::extract
|
||||||
|
Extracts a subset of the registry data based on a given path.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: self
|
||||||
|
|
||||||
|
arguments:
|
||||||
|
string $path
|
||||||
|
mixed $default = null
|
||||||
|
?string $separator = null
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Registryinterface::append
|
||||||
|
Appends content into the registry.
|
||||||
|
If a key exists, the value will be appended to the existing value.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: self
|
||||||
|
end note
|
||||||
|
|
||||||
|
note left of Registryinterface::getName
|
||||||
|
Gets the name of the registry.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: ?string
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Registryinterface::setName
|
||||||
|
Sets the name of the registry.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: self
|
||||||
|
end note
|
||||||
|
|
||||||
|
note left of Registryinterface::setSeparator
|
||||||
Sets a separator value
|
Sets a separator value
|
||||||
|
|
||||||
since: 3.2.0
|
since: 3.2.0
|
||||||
return: self
|
return: self
|
||||||
end note
|
end note
|
||||||
|
|
||||||
|
note right of Registryinterface::getSeparator
|
||||||
|
Gets the current path separator used in registry paths.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: ?string
|
||||||
|
end note
|
||||||
|
|
||||||
@enduml
|
@enduml
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -19,9 +19,127 @@ use VDM\Joomla\Interfaces\Activeregistryinterface;
|
|||||||
* The Registry Interface
|
* The Registry Interface
|
||||||
*
|
*
|
||||||
* @since 3.2.0
|
* @since 3.2.0
|
||||||
|
* @since 5.0.4 Joomla Registry Compatible
|
||||||
*/
|
*/
|
||||||
interface Registryinterface extends Activeregistryinterface
|
interface Registryinterface extends Activeregistryinterface
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* Magic method to get a value from the registry.
|
||||||
|
*
|
||||||
|
* Allows for accessing registry data using object property syntax.
|
||||||
|
*
|
||||||
|
* @param string $name The name of the property to get.
|
||||||
|
*
|
||||||
|
* @return mixed The value of the property, or null if not found.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function __get($name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Magic method to set a value in the registry.
|
||||||
|
*
|
||||||
|
* Allows for setting registry data using object property syntax.
|
||||||
|
*
|
||||||
|
* @param string $name The name of the property to set.
|
||||||
|
* @param mixed $value The value to set.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function __set($name, $value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Magic method to check if a property is set in the registry.
|
||||||
|
*
|
||||||
|
* Allows for using isset() on registry properties.
|
||||||
|
*
|
||||||
|
* @param string $name The name of the property to check.
|
||||||
|
*
|
||||||
|
* @return bool True if the property is set, false otherwise.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function __isset($name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Magic method to unset a property in the registry.
|
||||||
|
*
|
||||||
|
* Allows for using unset() on registry properties.
|
||||||
|
*
|
||||||
|
* @param string $name The name of the property to unset.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function __unset($name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Magic method to clone the registry.
|
||||||
|
*
|
||||||
|
* Performs a deep copy of the registry data.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function __clone();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Magic method to convert the registry to a string.
|
||||||
|
*
|
||||||
|
* Returns the registry data in JSON format.
|
||||||
|
*
|
||||||
|
* @return string The registry data in JSON format.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function __toString();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads data into the registry from a string using Joomla's format classes.
|
||||||
|
*
|
||||||
|
* @param string $data The data string to load.
|
||||||
|
* @param string $format The format of the data string. Supported formats: 'json', 'ini', 'xml', 'php'.
|
||||||
|
* @param array $options Options used by the formatter
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
* @throws \InvalidArgumentException If the format is not supported.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function loadString(string $data, string $format = 'JSON', array $options = []): self;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads data into the registry from an object.
|
||||||
|
*
|
||||||
|
* @param object $object The data object to load.
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function loadObject(object $object): self;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads data into the registry from an array.
|
||||||
|
*
|
||||||
|
* The loaded data will be merged into the registry's existing data.
|
||||||
|
*
|
||||||
|
* @param array $array The array of data to load into the registry.
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function loadArray(array $array): self;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads data into the registry from a file.
|
||||||
|
*
|
||||||
|
* @param string $path The path to the file to load.
|
||||||
|
* @param string $format The format of the file. Supported formats: 'json', 'ini', 'xml', 'php'.
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
* @throws \InvalidArgumentException If the file does not exist or is not readable.
|
||||||
|
* @throws \RuntimeException If the file cannot be read.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function loadFile(string $path, string $format = 'json'): self;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a value into the registry using multiple keys.
|
* Sets a value into the registry using multiple keys.
|
||||||
*
|
*
|
||||||
@ -60,7 +178,7 @@ interface Registryinterface extends Activeregistryinterface
|
|||||||
* @return mixed The value or sub-array from the storage. Null if the location doesn't exist.
|
* @return mixed The value or sub-array from the storage. Null if the location doesn't exist.
|
||||||
* @since 3.2.0
|
* @since 3.2.0
|
||||||
*/
|
*/
|
||||||
public function get(string $path, $default = null);
|
public function get(string $path, $default = null): mixed;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a value (or sub-array) from the registry using multiple keys.
|
* Removes a value (or sub-array) from the registry using multiple keys.
|
||||||
@ -84,6 +202,187 @@ interface Registryinterface extends Activeregistryinterface
|
|||||||
*/
|
*/
|
||||||
public function exists(string $path): bool;
|
public function exists(string $path): bool;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specify data which should be serialized to JSON.
|
||||||
|
*
|
||||||
|
* @return mixed Data which can be serialized by json_encode(),
|
||||||
|
* which is a value of any type other than a resource.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function jsonSerialize(): mixed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Count elements of the registry.
|
||||||
|
*
|
||||||
|
* @return int The number of elements in the registry.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function count(): int;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether a given offset exists in the registry.
|
||||||
|
*
|
||||||
|
* @param mixed $offset An offset to check for.
|
||||||
|
*
|
||||||
|
* @return bool True if the offset exists, false otherwise.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function offsetExists(mixed $offset): bool;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the value at a given offset.
|
||||||
|
*
|
||||||
|
* @param mixed $offset The offset to retrieve.
|
||||||
|
*
|
||||||
|
* @return mixed The value at the specified offset.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function offsetGet(mixed $offset): mixed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the value at a given offset.
|
||||||
|
*
|
||||||
|
* @param mixed $offset The offset to assign the value to.
|
||||||
|
* @param mixed $value The value to set.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function offsetSet(mixed $offset, mixed $value): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unset the value at a given offset.
|
||||||
|
*
|
||||||
|
* @param mixed $offset The offset to unset.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function offsetUnset(mixed $offset): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve an external iterator for the registry.
|
||||||
|
*
|
||||||
|
* @return \Traversable An instance of an object implementing Iterator or Traversable.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function getIterator(): \Traversable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the registry data as an associative array.
|
||||||
|
*
|
||||||
|
* @return array The registry data.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function toArray(): array;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the registry data as an object.
|
||||||
|
*
|
||||||
|
* @return object The registry data converted to an object.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function toObject();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts the registry data to a string in the specified format.
|
||||||
|
*
|
||||||
|
* @param string $format The format to output the string in. Supported formats: 'json', 'ini', 'xml', 'php'.
|
||||||
|
* @param array $options Options used by the formatter.
|
||||||
|
*
|
||||||
|
* @return string The registry data in the specified format.
|
||||||
|
*
|
||||||
|
* @throws \InvalidArgumentException If the format is not supported.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function toString(string $format = 'JSON', array $options = []): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flattens the registry data into a one-dimensional array.
|
||||||
|
*
|
||||||
|
* @param string|null $separator The separator for the key names.
|
||||||
|
* @param bool $full True to include the full path as keys.
|
||||||
|
*
|
||||||
|
* @return array The flattened data array.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function flatten(?string $separator = null, bool $full = false): array;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a default value if not already set.
|
||||||
|
*
|
||||||
|
* @param string $path The registry path (e.g., 'vdm.content.builder').
|
||||||
|
* @param mixed $default The default value to set if the path does not exist.
|
||||||
|
*
|
||||||
|
* @return mixed The value of the path after the method call.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function def(string $path, $default);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Merges another registry into this one.
|
||||||
|
*
|
||||||
|
* The data from the source registry will be merged into this registry,
|
||||||
|
* overwriting any existing values with the same keys.
|
||||||
|
*
|
||||||
|
* @param Registryinterface $source The registry to merge with this one.
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function merge(Registryinterface $source): self;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears all data from the registry.
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function clear(): self;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extracts a subset of the registry data based on a given path.
|
||||||
|
*
|
||||||
|
* @param string $path The registry path to extract.
|
||||||
|
* @param mixed $default Optional default value, returned if the path does not exist.
|
||||||
|
* @param string|null $separator The path separator.
|
||||||
|
*
|
||||||
|
* @return self A new Registry instance with the extracted data.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function extract(string $path, $default = null, ?string $separator = null): self;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Appends content into the registry.
|
||||||
|
*
|
||||||
|
* If a key exists, the value will be appended to the existing value.
|
||||||
|
*
|
||||||
|
* @param string $path The registry path (e.g., 'vdm.content.builder').
|
||||||
|
* @param mixed $value The value to append.
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function append(string $path, $value): self;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the name of the registry.
|
||||||
|
*
|
||||||
|
* @return string|null The name of the registry.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function getName(): ?string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the name of the registry.
|
||||||
|
*
|
||||||
|
* @param string|null $name The name to set.
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function setName(?string $name): self;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a separator value
|
* Sets a separator value
|
||||||
*
|
*
|
||||||
@ -93,5 +392,13 @@ interface Registryinterface extends Activeregistryinterface
|
|||||||
* @since 3.2.0
|
* @since 3.2.0
|
||||||
*/
|
*/
|
||||||
public function setSeparator(?string $value): self;
|
public function setSeparator(?string $value): self;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current path separator used in registry paths.
|
||||||
|
*
|
||||||
|
* @return string|null The path separator.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function getSeparator(): ?string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,3 +1,120 @@
|
|||||||
|
/**
|
||||||
|
* Magic method to get a value from the registry.
|
||||||
|
*
|
||||||
|
* Allows for accessing registry data using object property syntax.
|
||||||
|
*
|
||||||
|
* @param string $name The name of the property to get.
|
||||||
|
*
|
||||||
|
* @return mixed The value of the property, or null if not found.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function __get($name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Magic method to set a value in the registry.
|
||||||
|
*
|
||||||
|
* Allows for setting registry data using object property syntax.
|
||||||
|
*
|
||||||
|
* @param string $name The name of the property to set.
|
||||||
|
* @param mixed $value The value to set.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function __set($name, $value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Magic method to check if a property is set in the registry.
|
||||||
|
*
|
||||||
|
* Allows for using isset() on registry properties.
|
||||||
|
*
|
||||||
|
* @param string $name The name of the property to check.
|
||||||
|
*
|
||||||
|
* @return bool True if the property is set, false otherwise.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function __isset($name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Magic method to unset a property in the registry.
|
||||||
|
*
|
||||||
|
* Allows for using unset() on registry properties.
|
||||||
|
*
|
||||||
|
* @param string $name The name of the property to unset.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function __unset($name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Magic method to clone the registry.
|
||||||
|
*
|
||||||
|
* Performs a deep copy of the registry data.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function __clone();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Magic method to convert the registry to a string.
|
||||||
|
*
|
||||||
|
* Returns the registry data in JSON format.
|
||||||
|
*
|
||||||
|
* @return string The registry data in JSON format.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function __toString();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads data into the registry from a string using Joomla's format classes.
|
||||||
|
*
|
||||||
|
* @param string $data The data string to load.
|
||||||
|
* @param string $format The format of the data string. Supported formats: 'json', 'ini', 'xml', 'php'.
|
||||||
|
* @param array $options Options used by the formatter
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
* @throws \InvalidArgumentException If the format is not supported.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function loadString(string $data, string $format = 'JSON', array $options = []): self;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads data into the registry from an object.
|
||||||
|
*
|
||||||
|
* @param object $object The data object to load.
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function loadObject(object $object): self;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads data into the registry from an array.
|
||||||
|
*
|
||||||
|
* The loaded data will be merged into the registry's existing data.
|
||||||
|
*
|
||||||
|
* @param array $array The array of data to load into the registry.
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function loadArray(array $array): self;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads data into the registry from a file.
|
||||||
|
*
|
||||||
|
* @param string $path The path to the file to load.
|
||||||
|
* @param string $format The format of the file. Supported formats: 'json', 'ini', 'xml', 'php'.
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
* @throws \InvalidArgumentException If the file does not exist or is not readable.
|
||||||
|
* @throws \RuntimeException If the file cannot be read.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function loadFile(string $path, string $format = 'json'): self;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a value into the registry using multiple keys.
|
* Sets a value into the registry using multiple keys.
|
||||||
*
|
*
|
||||||
@ -36,7 +153,7 @@
|
|||||||
* @return mixed The value or sub-array from the storage. Null if the location doesn't exist.
|
* @return mixed The value or sub-array from the storage. Null if the location doesn't exist.
|
||||||
* @since 3.2.0
|
* @since 3.2.0
|
||||||
*/
|
*/
|
||||||
public function get(string $path, $default = null);
|
public function get(string $path, $default = null): mixed;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Removes a value (or sub-array) from the registry using multiple keys.
|
* Removes a value (or sub-array) from the registry using multiple keys.
|
||||||
@ -60,6 +177,187 @@
|
|||||||
*/
|
*/
|
||||||
public function exists(string $path): bool;
|
public function exists(string $path): bool;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specify data which should be serialized to JSON.
|
||||||
|
*
|
||||||
|
* @return mixed Data which can be serialized by json_encode(),
|
||||||
|
* which is a value of any type other than a resource.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function jsonSerialize(): mixed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Count elements of the registry.
|
||||||
|
*
|
||||||
|
* @return int The number of elements in the registry.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function count(): int;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether a given offset exists in the registry.
|
||||||
|
*
|
||||||
|
* @param mixed $offset An offset to check for.
|
||||||
|
*
|
||||||
|
* @return bool True if the offset exists, false otherwise.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function offsetExists(mixed $offset): bool;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the value at a given offset.
|
||||||
|
*
|
||||||
|
* @param mixed $offset The offset to retrieve.
|
||||||
|
*
|
||||||
|
* @return mixed The value at the specified offset.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function offsetGet(mixed $offset): mixed;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the value at a given offset.
|
||||||
|
*
|
||||||
|
* @param mixed $offset The offset to assign the value to.
|
||||||
|
* @param mixed $value The value to set.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function offsetSet(mixed $offset, mixed $value): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unset the value at a given offset.
|
||||||
|
*
|
||||||
|
* @param mixed $offset The offset to unset.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function offsetUnset(mixed $offset): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve an external iterator for the registry.
|
||||||
|
*
|
||||||
|
* @return \Traversable An instance of an object implementing Iterator or Traversable.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function getIterator(): \Traversable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the registry data as an associative array.
|
||||||
|
*
|
||||||
|
* @return array The registry data.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function toArray(): array;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the registry data as an object.
|
||||||
|
*
|
||||||
|
* @return object The registry data converted to an object.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function toObject();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts the registry data to a string in the specified format.
|
||||||
|
*
|
||||||
|
* @param string $format The format to output the string in. Supported formats: 'json', 'ini', 'xml', 'php'.
|
||||||
|
* @param array $options Options used by the formatter.
|
||||||
|
*
|
||||||
|
* @return string The registry data in the specified format.
|
||||||
|
*
|
||||||
|
* @throws \InvalidArgumentException If the format is not supported.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function toString(string $format = 'JSON', array $options = []): string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flattens the registry data into a one-dimensional array.
|
||||||
|
*
|
||||||
|
* @param string|null $separator The separator for the key names.
|
||||||
|
* @param bool $full True to include the full path as keys.
|
||||||
|
*
|
||||||
|
* @return array The flattened data array.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function flatten(?string $separator = null, bool $full = false): array;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a default value if not already set.
|
||||||
|
*
|
||||||
|
* @param string $path The registry path (e.g., 'vdm.content.builder').
|
||||||
|
* @param mixed $default The default value to set if the path does not exist.
|
||||||
|
*
|
||||||
|
* @return mixed The value of the path after the method call.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function def(string $path, $default);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Merges another registry into this one.
|
||||||
|
*
|
||||||
|
* The data from the source registry will be merged into this registry,
|
||||||
|
* overwriting any existing values with the same keys.
|
||||||
|
*
|
||||||
|
* @param Registryinterface $source The registry to merge with this one.
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function merge(Registryinterface $source): self;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears all data from the registry.
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function clear(): self;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extracts a subset of the registry data based on a given path.
|
||||||
|
*
|
||||||
|
* @param string $path The registry path to extract.
|
||||||
|
* @param mixed $default Optional default value, returned if the path does not exist.
|
||||||
|
* @param string|null $separator The path separator.
|
||||||
|
*
|
||||||
|
* @return self A new Registry instance with the extracted data.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function extract(string $path, $default = null, ?string $separator = null): self;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Appends content into the registry.
|
||||||
|
*
|
||||||
|
* If a key exists, the value will be appended to the existing value.
|
||||||
|
*
|
||||||
|
* @param string $path The registry path (e.g., 'vdm.content.builder').
|
||||||
|
* @param mixed $value The value to append.
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function append(string $path, $value): self;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the name of the registry.
|
||||||
|
*
|
||||||
|
* @return string|null The name of the registry.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function getName(): ?string;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the name of the registry.
|
||||||
|
*
|
||||||
|
* @param string|null $name The name to set.
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function setName(?string $name): self;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a separator value
|
* Sets a separator value
|
||||||
*
|
*
|
||||||
@ -69,3 +367,11 @@
|
|||||||
* @since 3.2.0
|
* @since 3.2.0
|
||||||
*/
|
*/
|
||||||
public function setSeparator(?string $value): self;
|
public function setSeparator(?string $value): self;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current path separator used in registry paths.
|
||||||
|
*
|
||||||
|
* @return string|null The path separator.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function getSeparator(): ?string;
|
@ -14,7 +14,7 @@
|
|||||||
"af0eedbe-603b-4671-8e5a-28165d88254b"
|
"af0eedbe-603b-4671-8e5a-28165d88254b"
|
||||||
],
|
],
|
||||||
"namespace": "[[[NamespacePrefix]]]\\Joomla\\Interfaces.Registryinterface",
|
"namespace": "[[[NamespacePrefix]]]\\Joomla\\Interfaces.Registryinterface",
|
||||||
"description": "The Registry Interface\r\n\r\n@since 3.2.0",
|
"description": "The Registry Interface\r\n\r\n@since 3.2.0\r\n@since 5.0.4 Joomla Registry Compatible",
|
||||||
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\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",
|
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\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": "",
|
"head": "",
|
||||||
"composer": ""
|
"composer": ""
|
||||||
|
@ -13,9 +13,9 @@
|
|||||||
@startuml
|
@startuml
|
||||||
class Item << (F,LightGreen) >> #RoyalBlue {
|
class Item << (F,LightGreen) >> #RoyalBlue {
|
||||||
# Validator $validator
|
# Validator $validator
|
||||||
# Item $item
|
# DataItem $item
|
||||||
# Row $row
|
# Row $row
|
||||||
+ __construct(Validator $validator, Item $item, ...)
|
+ __construct(Validator $validator, DataItem $item, ...)
|
||||||
+ get(string $table, array $columns) : ?array
|
+ get(string $table, array $columns) : ?array
|
||||||
- getImportValue(mixed $value, string $field, ...) : mixed
|
- getImportValue(mixed $value, string $field, ...) : mixed
|
||||||
- validImportValue(mixed $value, string $field, ...) : mixed
|
- validImportValue(mixed $value, string $field, ...) : mixed
|
||||||
@ -33,7 +33,7 @@ note right of Item::__construct
|
|||||||
|
|
||||||
arguments:
|
arguments:
|
||||||
Validator $validator
|
Validator $validator
|
||||||
Item $item
|
DataItem $item
|
||||||
Row $row
|
Row $row
|
||||||
end note
|
end note
|
||||||
|
|
||||||
|
@ -13,8 +13,9 @@ namespace VDM\Joomla\Componentbuilder\Import;
|
|||||||
|
|
||||||
|
|
||||||
use VDM\Joomla\Interfaces\TableValidatorInterface as Validator;
|
use VDM\Joomla\Interfaces\TableValidatorInterface as Validator;
|
||||||
use VDM\Joomla\Interfaces\Data\ItemInterface as Item;
|
use VDM\Joomla\Interfaces\Data\ItemInterface as DataItem;
|
||||||
use VDM\Joomla\Componentbuilder\Interfaces\ImportRowInterface as Row;
|
use VDM\Joomla\Componentbuilder\Interfaces\ImportRowInterface as Row;
|
||||||
|
use VDM\Joomla\Utilities\GuidHelper;
|
||||||
use VDM\Joomla\Componentbuilder\Interfaces\ImportItemInterface;
|
use VDM\Joomla\Componentbuilder\Interfaces\ImportItemInterface;
|
||||||
|
|
||||||
|
|
||||||
@ -39,7 +40,7 @@ final class Item implements ImportItemInterface
|
|||||||
* @var Item
|
* @var Item
|
||||||
* @since 4.0.3
|
* @since 4.0.3
|
||||||
*/
|
*/
|
||||||
protected Item $item;
|
protected DataItem $item;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Import Row Class.
|
* The Import Row Class.
|
||||||
@ -53,12 +54,12 @@ final class Item implements ImportItemInterface
|
|||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param Validator $validator The Table ValidatorI Class.
|
* @param Validator $validator The Table ValidatorI Class.
|
||||||
* @param Item $item The Item Class.
|
* @param DataItem $item The Item Class.
|
||||||
* @param Row $row The Import Row Class.
|
* @param Row $row The Import Row Class.
|
||||||
*
|
*
|
||||||
* @since 4.0.3
|
* @since 4.0.3
|
||||||
*/
|
*/
|
||||||
public function __construct(Validator $validator, Item $item, Row $row)
|
public function __construct(Validator $validator, DataItem $item, Row $row)
|
||||||
{
|
{
|
||||||
$this->validator = $validator;
|
$this->validator = $validator;
|
||||||
$this->item = $item;
|
$this->item = $item;
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
* @var Item
|
* @var Item
|
||||||
* @since 4.0.3
|
* @since 4.0.3
|
||||||
*/
|
*/
|
||||||
protected Item $item;
|
protected DataItem $item;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Import Row Class.
|
* The Import Row Class.
|
||||||
@ -26,12 +26,12 @@
|
|||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
* @param Validator $validator The Table ValidatorI Class.
|
* @param Validator $validator The Table ValidatorI Class.
|
||||||
* @param Item $item The Item Class.
|
* @param DataItem $item The Item Class.
|
||||||
* @param Row $row The Import Row Class.
|
* @param Row $row The Import Row Class.
|
||||||
*
|
*
|
||||||
* @since 4.0.3
|
* @since 4.0.3
|
||||||
*/
|
*/
|
||||||
public function __construct(Validator $validator, Item $item, Row $row)
|
public function __construct(Validator $validator, DataItem $item, Row $row)
|
||||||
{
|
{
|
||||||
$this->validator = $validator;
|
$this->validator = $validator;
|
||||||
$this->item = $item;
|
$this->item = $item;
|
||||||
|
@ -18,11 +18,15 @@
|
|||||||
},
|
},
|
||||||
"use_selection1": {
|
"use_selection1": {
|
||||||
"use": "05744dd3-4030-4cf8-8dda-a93ab809b473",
|
"use": "05744dd3-4030-4cf8-8dda-a93ab809b473",
|
||||||
"as": "Item"
|
"as": "DataItem"
|
||||||
},
|
},
|
||||||
"use_selection2": {
|
"use_selection2": {
|
||||||
"use": "3d3ec064-9867-41e6-a48a-964c15d753aa",
|
"use": "3d3ec064-9867-41e6-a48a-964c15d753aa",
|
||||||
"as": "Row"
|
"as": "Row"
|
||||||
|
},
|
||||||
|
"use_selection3": {
|
||||||
|
"use": "9c513baf-b279-43fd-ae29-a585c8cbc4f0",
|
||||||
|
"as": "default"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"extendsinterfaces": null,
|
"extendsinterfaces": null,
|
||||||
|
@ -15,6 +15,7 @@ class Validator << (F,LightGreen) >> #RoyalBlue {
|
|||||||
# Table $table
|
# Table $table
|
||||||
# array $validators
|
# array $validators
|
||||||
# array $defaults
|
# array $defaults
|
||||||
|
# array $datatypes
|
||||||
+ __construct(Table $table)
|
+ __construct(Table $table)
|
||||||
+ getValid(mixed $value, string $field, ...) : mixed
|
+ getValid(mixed $value, string $field, ...) : mixed
|
||||||
- validate(mixed $value, array $dbField) : bool
|
- validate(mixed $value, array $dbField) : bool
|
||||||
|
@ -40,13 +40,21 @@ final class Validator implements TableValidatorInterface
|
|||||||
protected array $validators = [];
|
protected array $validators = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A map of defauts for the respective datatypes.
|
* A map of defaults for the respective datatypes.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @since 5.3.0
|
* @since 5.3.0
|
||||||
*/
|
*/
|
||||||
protected array $defaults = [];
|
protected array $defaults = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cache of the parsed datatype details
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @since 5.3.0
|
||||||
|
*/
|
||||||
|
protected array $datatypes = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
@ -162,14 +170,21 @@ final class Validator implements TableValidatorInterface
|
|||||||
*/
|
*/
|
||||||
private function parseDataType(string $datatype): array
|
private function parseDataType(string $datatype): array
|
||||||
{
|
{
|
||||||
|
if (isset($this->datatypes[$datatype]))
|
||||||
|
{
|
||||||
|
return $this->datatypes[$datatype];
|
||||||
|
}
|
||||||
|
|
||||||
$pattern = '/(?<type>\w+)(\((?<size>\d+)(,\s*(?<precision>\d+))?\))?/i';
|
$pattern = '/(?<type>\w+)(\((?<size>\d+)(,\s*(?<precision>\d+))?\))?/i';
|
||||||
preg_match($pattern, $datatype, $matches);
|
preg_match($pattern, $datatype, $matches);
|
||||||
|
|
||||||
return [
|
$result = [
|
||||||
'type' => isset($matches['type']) ? strtolower($matches['type']) : strtolower($datatype),
|
'type' => isset($matches['type']) ? strtolower($matches['type']) : strtolower($datatype),
|
||||||
'size' => $matches['size'] ?? null,
|
'size' => $matches['size'] ?? null,
|
||||||
'precision' => $matches['precision'] ?? null,
|
'precision' => $matches['precision'] ?? null,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
return $this->datatypes[$datatype] = $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -15,13 +15,21 @@
|
|||||||
protected array $validators = [];
|
protected array $validators = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A map of defauts for the respective datatypes.
|
* A map of defaults for the respective datatypes.
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
* @since 5.3.0
|
* @since 5.3.0
|
||||||
*/
|
*/
|
||||||
protected array $defaults = [];
|
protected array $defaults = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Cache of the parsed datatype details
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @since 5.3.0
|
||||||
|
*/
|
||||||
|
protected array $datatypes = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor.
|
* Constructor.
|
||||||
*
|
*
|
||||||
@ -137,14 +145,21 @@
|
|||||||
*/
|
*/
|
||||||
private function parseDataType(string $datatype): array
|
private function parseDataType(string $datatype): array
|
||||||
{
|
{
|
||||||
|
if (isset($this->datatypes[$datatype]))
|
||||||
|
{
|
||||||
|
return $this->datatypes[$datatype];
|
||||||
|
}
|
||||||
|
|
||||||
$pattern = '/(?<type>\w+)(\((?<size>\d+)(,\s*(?<precision>\d+))?\))?/i';
|
$pattern = '/(?<type>\w+)(\((?<size>\d+)(,\s*(?<precision>\d+))?\))?/i';
|
||||||
preg_match($pattern, $datatype, $matches);
|
preg_match($pattern, $datatype, $matches);
|
||||||
|
|
||||||
return [
|
$result = [
|
||||||
'type' => isset($matches['type']) ? strtolower($matches['type']) : strtolower($datatype),
|
'type' => isset($matches['type']) ? strtolower($matches['type']) : strtolower($datatype),
|
||||||
'size' => $matches['size'] ?? null,
|
'size' => $matches['size'] ?? null,
|
||||||
'precision' => $matches['precision'] ?? null,
|
'precision' => $matches['precision'] ?? null,
|
||||||
];
|
];
|
||||||
|
|
||||||
|
return $this->datatypes[$datatype] = $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -6,16 +6,16 @@
|
|||||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||||
```
|
```
|
||||||
# trait ToString (Details)
|
# trait PathToString (Details)
|
||||||
> namespace: **VDM\Joomla\Abstraction\Registry\Traits**
|
> namespace: **VDM\Joomla\Abstraction\Registry\Traits**
|
||||||
|
|
||||||
```uml
|
```uml
|
||||||
@startuml
|
@startuml
|
||||||
class ToString << (T,Orange) >> #Turquoise {
|
class PathToString << (T,Orange) >> #Turquoise {
|
||||||
+ toString(string $path, string $separator = '') : string
|
+ pathToString(string $path, string $separator = '') : string
|
||||||
}
|
}
|
||||||
|
|
||||||
note right of ToString::toString
|
note right of PathToString::pathToString
|
||||||
Convert an array of values to a string (or return string)
|
Convert an array of values to a string (or return string)
|
||||||
|
|
||||||
since: 3.2.0
|
since: 3.2.0
|
||||||
|
@ -13,11 +13,12 @@ namespace VDM\Joomla\Abstraction\Registry\Traits;
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* To String Values
|
* Path To String Values
|
||||||
*
|
*
|
||||||
* @since 3.2.0
|
* @since 3.2.0
|
||||||
|
* @since 5.0.2 name changed to PathToString to avoid collusion in core registry class
|
||||||
*/
|
*/
|
||||||
trait ToString
|
trait PathToString
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Convert an array of values to a string (or return string)
|
* Convert an array of values to a string (or return string)
|
||||||
@ -28,7 +29,7 @@ trait ToString
|
|||||||
* @return string
|
* @return string
|
||||||
* @since 3.2.0
|
* @since 3.2.0
|
||||||
*/
|
*/
|
||||||
public function toString(string $path, string $separator = ''): string
|
public function pathToString(string $path, string $separator = ''): string
|
||||||
{
|
{
|
||||||
// Return default value if path is empty
|
// Return default value if path is empty
|
||||||
if (empty($path))
|
if (empty($path))
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
* @return string
|
* @return string
|
||||||
* @since 3.2.0
|
* @since 3.2.0
|
||||||
*/
|
*/
|
||||||
public function toString(string $path, string $separator = ''): string
|
public function pathToString(string $path, string $separator = ''): string
|
||||||
{
|
{
|
||||||
// Return default value if path is empty
|
// Return default value if path is empty
|
||||||
if (empty($path))
|
if (empty($path))
|
||||||
|
@ -5,14 +5,14 @@
|
|||||||
"guid": "7d494d91-ab60-43cd-aecf-d50e07f7f30e",
|
"guid": "7d494d91-ab60-43cd-aecf-d50e07f7f30e",
|
||||||
"implements": null,
|
"implements": null,
|
||||||
"load_selection": null,
|
"load_selection": null,
|
||||||
"name": "ToString",
|
"name": "PathToString",
|
||||||
"power_version": "1.0.0",
|
"power_version": "1.0.0",
|
||||||
"system_name": "VDM.Abstraction.Registry.Traits.ToString",
|
"system_name": "VDM.Abstraction.Registry.Traits.PathToString",
|
||||||
"type": "trait",
|
"type": "trait",
|
||||||
"use_selection": null,
|
"use_selection": null,
|
||||||
"extendsinterfaces": null,
|
"extendsinterfaces": null,
|
||||||
"namespace": "[[[NamespacePrefix]]]\\Joomla\\Abstraction.Registry.Traits.ToString",
|
"namespace": "[[[NamespacePrefix]]]\\Joomla\\Abstraction.Registry.Traits.PathToString",
|
||||||
"description": "To String Values\r\n\r\n@since 3.2.0",
|
"description": "Path To String Values\r\n\r\n@since 3.2.0\r\n@since 5.0.2 name changed to PathToString to avoid collusion in core registry class",
|
||||||
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\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",
|
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\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": "",
|
"head": "",
|
||||||
"composer": ""
|
"composer": ""
|
||||||
|
@ -14,16 +14,141 @@
|
|||||||
@startuml
|
@startuml
|
||||||
abstract Registry #Orange {
|
abstract Registry #Orange {
|
||||||
# ?string $separator
|
# ?string $separator
|
||||||
|
# ?string $name
|
||||||
|
+ __construct(mixed $data = null, ?string $separator = null)
|
||||||
|
+ __get(string $name) : mixed
|
||||||
|
+ __set(string $name, mixed $value) : void
|
||||||
|
+ __isset(string $name) : bool
|
||||||
|
+ __unset(string $name) : void
|
||||||
|
+ __clone() : void
|
||||||
|
+ __toString() : string
|
||||||
|
+ loadString(string $data, string $format = 'JSON', ...) : self
|
||||||
|
+ loadObject(object $object) : self
|
||||||
|
+ loadArray(array $array) : self
|
||||||
|
+ loadFile(string $path, string $format = 'json') : self
|
||||||
+ set(string $path, mixed $value) : self
|
+ set(string $path, mixed $value) : self
|
||||||
+ add(string $path, mixed $value, ...) : self
|
+ add(string $path, mixed $value, ...) : self
|
||||||
+ get(string $path, mixed $default = null) : mixed
|
+ get(string $path, mixed $default = null) : mixed
|
||||||
+ remove(string $path) : self
|
+ remove(string $path) : self
|
||||||
+ exists(string $path) : bool
|
+ exists(string $path) : bool
|
||||||
|
+ jsonSerialize() : mixed
|
||||||
|
+ count() : int
|
||||||
|
+ offsetExists(mixed $offset) : bool
|
||||||
|
+ offsetGet(mixed $offset) : mixed
|
||||||
|
+ offsetSet(mixed $offset, mixed $value) : void
|
||||||
|
+ offsetUnset(mixed $offset) : void
|
||||||
|
+ getIterator() : \Traversable
|
||||||
|
+ toArray() : array
|
||||||
|
+ toObject() : object
|
||||||
|
+ toString(string $format = 'JSON', array $options = []) : string
|
||||||
|
+ flatten(?string $separator = null, bool $full = false) : array
|
||||||
|
+ def(string $path, mixed $default) : mixed
|
||||||
|
+ merge(Registryinterface $source) : self
|
||||||
|
+ clear() : self
|
||||||
|
+ extract(string $path, mixed $default = null, ...) : self
|
||||||
|
+ append(string $path, mixed $value) : self
|
||||||
|
+ getName() : ?string
|
||||||
|
+ setName(?string $name) : self
|
||||||
+ setSeparator(?string $value) : self
|
+ setSeparator(?string $value) : self
|
||||||
|
+ getSeparator() : ?string
|
||||||
|
# arrayToObject(mixed $data) : mixed
|
||||||
|
# objectToArray(mixed $data) : mixed
|
||||||
|
# arrayMergeRecursive(array $array1, array $array2) : array
|
||||||
|
# flattenArray(array $array, string $separator, ...) : array
|
||||||
# getActiveKeys(string $path) : ?array
|
# getActiveKeys(string $path) : ?array
|
||||||
}
|
}
|
||||||
|
|
||||||
note right of Registry::set
|
note right of Registry::__construct
|
||||||
|
Constructor.
|
||||||
|
Initializes the Registry object with optional data.
|
||||||
|
Can be an array, string, or object.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
end note
|
||||||
|
|
||||||
|
note left of Registry::__get
|
||||||
|
Magic method to get a value from the registry.
|
||||||
|
Allows for accessing registry data using object property syntax.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: mixed
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Registry::__set
|
||||||
|
Magic method to set a value in the registry.
|
||||||
|
Allows for setting registry data using object property syntax.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: void
|
||||||
|
end note
|
||||||
|
|
||||||
|
note left of Registry::__isset
|
||||||
|
Magic method to check if a property is set in the registry.
|
||||||
|
Allows for using isset() on registry properties.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: bool
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Registry::__unset
|
||||||
|
Magic method to unset a property in the registry.
|
||||||
|
Allows for using unset() on registry properties.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: void
|
||||||
|
end note
|
||||||
|
|
||||||
|
note left of Registry::__clone
|
||||||
|
Magic method to clone the registry.
|
||||||
|
Performs a deep copy of the registry data.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: void
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Registry::__toString
|
||||||
|
Magic method to convert the registry to a string.
|
||||||
|
Returns the registry data in JSON format.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: string
|
||||||
|
end note
|
||||||
|
|
||||||
|
note left of Registry::loadString
|
||||||
|
Loads data into the registry from a string using Joomla's format classes.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: self
|
||||||
|
|
||||||
|
arguments:
|
||||||
|
string $data
|
||||||
|
string $format = 'JSON'
|
||||||
|
array $options = []
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Registry::loadObject
|
||||||
|
Loads data into the registry from an object.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: self
|
||||||
|
end note
|
||||||
|
|
||||||
|
note left of Registry::loadArray
|
||||||
|
Loads data into the registry from an array.
|
||||||
|
The loaded data will be merged into the registry's existing data.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: self
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Registry::loadFile
|
||||||
|
Loads data into the registry from a file.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: self
|
||||||
|
end note
|
||||||
|
|
||||||
|
note left of Registry::set
|
||||||
Sets a value into the registry using multiple keys.
|
Sets a value into the registry using multiple keys.
|
||||||
|
|
||||||
since: 3.2.0
|
since: 3.2.0
|
||||||
@ -45,7 +170,7 @@ Override in child class allowed set class property $addAsArray = true.
|
|||||||
?bool $asArray = null
|
?bool $asArray = null
|
||||||
end note
|
end note
|
||||||
|
|
||||||
note right of Registry::get
|
note left of Registry::get
|
||||||
Retrieves a value (or sub-array) from the registry using multiple keys.
|
Retrieves a value (or sub-array) from the registry using multiple keys.
|
||||||
|
|
||||||
since: 3.2.0
|
since: 3.2.0
|
||||||
@ -59,13 +184,148 @@ note right of Registry::remove
|
|||||||
return: self
|
return: self
|
||||||
end note
|
end note
|
||||||
|
|
||||||
note right of Registry::exists
|
note left of Registry::exists
|
||||||
Checks the existence of a particular location in the registry using multiple keys.
|
Checks the existence of a particular location in the registry using multiple keys.
|
||||||
|
|
||||||
since: 3.2.0
|
since: 3.2.0
|
||||||
return: bool
|
return: bool
|
||||||
end note
|
end note
|
||||||
|
|
||||||
|
note right of Registry::jsonSerialize
|
||||||
|
Specify data which should be serialized to JSON.
|
||||||
|
which is a value of any type other than a resource.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: mixed
|
||||||
|
end note
|
||||||
|
|
||||||
|
note left of Registry::count
|
||||||
|
Count elements of the registry.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: int
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Registry::offsetExists
|
||||||
|
Whether a given offset exists in the registry.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: bool
|
||||||
|
end note
|
||||||
|
|
||||||
|
note left of Registry::offsetGet
|
||||||
|
Retrieve the value at a given offset.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: mixed
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Registry::offsetSet
|
||||||
|
Set the value at a given offset.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: void
|
||||||
|
end note
|
||||||
|
|
||||||
|
note left of Registry::offsetUnset
|
||||||
|
Unset the value at a given offset.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: void
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Registry::getIterator
|
||||||
|
Retrieve an external iterator for the registry.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: \Traversable
|
||||||
|
end note
|
||||||
|
|
||||||
|
note left of Registry::toArray
|
||||||
|
Get the registry data as an associative array.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: array
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Registry::toObject
|
||||||
|
Get the registry data as an object.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: object
|
||||||
|
end note
|
||||||
|
|
||||||
|
note left of Registry::toString
|
||||||
|
Converts the registry data to a string in the specified format.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: string
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Registry::flatten
|
||||||
|
Flattens the registry data into a one-dimensional array.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: array
|
||||||
|
end note
|
||||||
|
|
||||||
|
note left of Registry::def
|
||||||
|
Sets a default value if not already set.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: mixed
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Registry::merge
|
||||||
|
Merges another registry into this one.
|
||||||
|
The data from the source registry will be merged into this registry,
|
||||||
|
overwriting any existing values with the same keys.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: self
|
||||||
|
end note
|
||||||
|
|
||||||
|
note left of Registry::clear
|
||||||
|
Clears all data from the registry.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: self
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Registry::extract
|
||||||
|
Extracts a subset of the registry data based on a given path.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: self
|
||||||
|
|
||||||
|
arguments:
|
||||||
|
string $path
|
||||||
|
mixed $default = null
|
||||||
|
?string $separator = null
|
||||||
|
end note
|
||||||
|
|
||||||
|
note left of Registry::append
|
||||||
|
Appends content into the registry.
|
||||||
|
If a key exists, the value will be appended to the existing value.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: self
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Registry::getName
|
||||||
|
Gets the name of the registry.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: ?string
|
||||||
|
end note
|
||||||
|
|
||||||
|
note left of Registry::setName
|
||||||
|
Sets the name of the registry.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: self
|
||||||
|
end note
|
||||||
|
|
||||||
note right of Registry::setSeparator
|
note right of Registry::setSeparator
|
||||||
Sets a separator value
|
Sets a separator value
|
||||||
|
|
||||||
@ -73,6 +333,54 @@ note right of Registry::setSeparator
|
|||||||
return: self
|
return: self
|
||||||
end note
|
end note
|
||||||
|
|
||||||
|
note left of Registry::getSeparator
|
||||||
|
Gets the current path separator used in registry paths.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: ?string
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Registry::arrayToObject
|
||||||
|
Recursively converts an array to an object.
|
||||||
|
This method is used to convert the internal array data into an object
|
||||||
|
structure suitable for serialization or other operations that require objects.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: mixed
|
||||||
|
end note
|
||||||
|
|
||||||
|
note left of Registry::objectToArray
|
||||||
|
Recursively converts an object to an array.
|
||||||
|
This method is used to convert data loaded from formats that produce objects
|
||||||
|
(e.g., JSON, XML) into an array structure for internal storage.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: mixed
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Registry::arrayMergeRecursive
|
||||||
|
Recursively merges two arrays.
|
||||||
|
This method merges the elements of two arrays together so that the values of one
|
||||||
|
are appended to the end of the previous one. It preserves numeric keys.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: array
|
||||||
|
end note
|
||||||
|
|
||||||
|
note left of Registry::flattenArray
|
||||||
|
Helper function to recursively flatten the array.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: array
|
||||||
|
|
||||||
|
arguments:
|
||||||
|
array $array
|
||||||
|
string $separator
|
||||||
|
bool $full
|
||||||
|
array $flattened = []
|
||||||
|
string $path = ''
|
||||||
|
end note
|
||||||
|
|
||||||
note right of Registry::getActiveKeys
|
note right of Registry::getActiveKeys
|
||||||
Get that the active keys from a path
|
Get that the active keys from a path
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace VDM\Joomla\Abstraction;
|
namespace VDM\Joomla\Abstraction;
|
||||||
|
|
||||||
|
|
||||||
|
use Joomla\Registry\Factory as FormatFactory;
|
||||||
use VDM\Joomla\Interfaces\Registryinterface;
|
use VDM\Joomla\Interfaces\Registryinterface;
|
||||||
use VDM\Joomla\Abstraction\ActiveRegistry;
|
use VDM\Joomla\Abstraction\ActiveRegistry;
|
||||||
|
|
||||||
@ -22,8 +23,9 @@ use VDM\Joomla\Abstraction\ActiveRegistry;
|
|||||||
* Don't use this beyond 10 dimensional depth for best performance.
|
* Don't use this beyond 10 dimensional depth for best performance.
|
||||||
*
|
*
|
||||||
* @since 3.2.0
|
* @since 3.2.0
|
||||||
|
* @since 5.0.4 Joomla Registry Compatible
|
||||||
*/
|
*/
|
||||||
abstract class Registry extends ActiveRegistry implements Registryinterface
|
abstract class Registry extends ActiveRegistry implements Registryinterface, \JsonSerializable, \ArrayAccess, \IteratorAggregate, \Countable
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Path separator
|
* Path separator
|
||||||
@ -33,6 +35,225 @@ abstract class Registry extends ActiveRegistry implements Registryinterface
|
|||||||
*/
|
*/
|
||||||
protected ?string $separator = '.';
|
protected ?string $separator = '.';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the registry.
|
||||||
|
*
|
||||||
|
* @var string|null
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
protected ?string $name = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* Initializes the Registry object with optional data.
|
||||||
|
*
|
||||||
|
* @param mixed $data Optional data to load into the registry.
|
||||||
|
* Can be an array, string, or object.
|
||||||
|
* @param string|null $separator The path separator, and empty string will flatten the registry.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function __construct($data = null, ?string $separator = null)
|
||||||
|
{
|
||||||
|
// we don't allow null on initialization (default is a dot)
|
||||||
|
// so that all class inheritance can override the separator property
|
||||||
|
// use an empty string if you want to flatten the registry
|
||||||
|
if ($separator !== null)
|
||||||
|
{
|
||||||
|
$this->setSeparator($separator);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($data !== null)
|
||||||
|
{
|
||||||
|
if (is_array($data))
|
||||||
|
{
|
||||||
|
$this->loadArray($data);
|
||||||
|
}
|
||||||
|
elseif (is_string($data))
|
||||||
|
{
|
||||||
|
$this->loadString($data);
|
||||||
|
}
|
||||||
|
elseif (is_object($data))
|
||||||
|
{
|
||||||
|
$this->loadObject($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Magic method to get a value from the registry.
|
||||||
|
*
|
||||||
|
* Allows for accessing registry data using object property syntax.
|
||||||
|
*
|
||||||
|
* @param string $name The name of the property to get.
|
||||||
|
*
|
||||||
|
* @return mixed The value of the property, or null if not found.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function __get($name)
|
||||||
|
{
|
||||||
|
return $this->get($name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Magic method to set a value in the registry.
|
||||||
|
*
|
||||||
|
* Allows for setting registry data using object property syntax.
|
||||||
|
*
|
||||||
|
* @param string $name The name of the property to set.
|
||||||
|
* @param mixed $value The value to set.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function __set($name, $value)
|
||||||
|
{
|
||||||
|
$this->set($name, $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Magic method to check if a property is set in the registry.
|
||||||
|
*
|
||||||
|
* Allows for using isset() on registry properties.
|
||||||
|
*
|
||||||
|
* @param string $name The name of the property to check.
|
||||||
|
*
|
||||||
|
* @return bool True if the property is set, false otherwise.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function __isset($name)
|
||||||
|
{
|
||||||
|
return $this->exists($name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Magic method to unset a property in the registry.
|
||||||
|
*
|
||||||
|
* Allows for using unset() on registry properties.
|
||||||
|
*
|
||||||
|
* @param string $name The name of the property to unset.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function __unset($name)
|
||||||
|
{
|
||||||
|
$this->remove($name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Magic method to clone the registry.
|
||||||
|
*
|
||||||
|
* Performs a deep copy of the registry data.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function __clone()
|
||||||
|
{
|
||||||
|
$this->active = unserialize(serialize($this->active));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Magic method to convert the registry to a string.
|
||||||
|
*
|
||||||
|
* Returns the registry data in JSON format.
|
||||||
|
*
|
||||||
|
* @return string The registry data in JSON format.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function __toString()
|
||||||
|
{
|
||||||
|
return $this->toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads data into the registry from a string using Joomla's format classes.
|
||||||
|
*
|
||||||
|
* @param string $data The data string to load.
|
||||||
|
* @param string $format The format of the data string. Supported formats: 'json', 'ini', 'xml', 'php'.
|
||||||
|
* @param array $options Options used by the formatter
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
* @throws \InvalidArgumentException If the format is not supported.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function loadString(string $data, string $format = 'JSON', array $options = []): self
|
||||||
|
{
|
||||||
|
// Load a string into the given namespace [or default namespace if not given]
|
||||||
|
$object = FormatFactory::getFormat($format, $options)->stringToObject($data, $options);
|
||||||
|
|
||||||
|
// Merge the object into the registry
|
||||||
|
$this->loadObject($object);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads data into the registry from an object.
|
||||||
|
*
|
||||||
|
* @param object $object The data object to load.
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function loadObject(object $object): self
|
||||||
|
{
|
||||||
|
// Convert the object to an array
|
||||||
|
$array = $this->objectToArray($object);
|
||||||
|
|
||||||
|
// Merge the array into the registry
|
||||||
|
$this->loadArray($array);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads data into the registry from an array.
|
||||||
|
*
|
||||||
|
* The loaded data will be merged into the registry's existing data.
|
||||||
|
*
|
||||||
|
* @param array $array The array of data to load into the registry.
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function loadArray(array $array): self
|
||||||
|
{
|
||||||
|
$this->active = $this->arrayMergeRecursive($this->active, $array);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads data into the registry from a file.
|
||||||
|
*
|
||||||
|
* @param string $path The path to the file to load.
|
||||||
|
* @param string $format The format of the file. Supported formats: 'json', 'ini', 'xml', 'php'.
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
* @throws \InvalidArgumentException If the file does not exist or is not readable.
|
||||||
|
* @throws \RuntimeException If the file cannot be read.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function loadFile(string $path, string $format = 'json'): self
|
||||||
|
{
|
||||||
|
if (!file_exists($path) || !is_readable($path))
|
||||||
|
{
|
||||||
|
throw new \InvalidArgumentException("File does not exist or is not readable: {$path}");
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = file_get_contents($path);
|
||||||
|
|
||||||
|
if ($data === false)
|
||||||
|
{
|
||||||
|
throw new \RuntimeException("Failed to read file: {$path}");
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->loadString($data, $format);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a value into the registry using multiple keys.
|
* Sets a value into the registry using multiple keys.
|
||||||
*
|
*
|
||||||
@ -91,7 +312,7 @@ abstract class Registry extends ActiveRegistry implements Registryinterface
|
|||||||
* @return mixed The value or sub-array from the storage. Null if the location doesn't exist.
|
* @return mixed The value or sub-array from the storage. Null if the location doesn't exist.
|
||||||
* @since 3.2.0
|
* @since 3.2.0
|
||||||
*/
|
*/
|
||||||
public function get(string $path, $default = null)
|
public function get(string $path, $default = null): mixed
|
||||||
{
|
{
|
||||||
if (($keys = $this->getActiveKeys($path)) === null)
|
if (($keys = $this->getActiveKeys($path)) === null)
|
||||||
{
|
{
|
||||||
@ -141,6 +362,301 @@ abstract class Registry extends ActiveRegistry implements Registryinterface
|
|||||||
return $this->existsActive(...$keys);
|
return $this->existsActive(...$keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specify data which should be serialized to JSON.
|
||||||
|
*
|
||||||
|
* @return mixed Data which can be serialized by json_encode(),
|
||||||
|
* which is a value of any type other than a resource.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function jsonSerialize(): mixed
|
||||||
|
{
|
||||||
|
return $this->active;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Count elements of the registry.
|
||||||
|
*
|
||||||
|
* @return int The number of elements in the registry.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function count(): int
|
||||||
|
{
|
||||||
|
return count($this->active);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether a given offset exists in the registry.
|
||||||
|
*
|
||||||
|
* @param mixed $offset An offset to check for.
|
||||||
|
*
|
||||||
|
* @return bool True if the offset exists, false otherwise.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function offsetExists(mixed $offset): bool
|
||||||
|
{
|
||||||
|
if (!is_string($offset))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return $this->exists($offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the value at a given offset.
|
||||||
|
*
|
||||||
|
* @param mixed $offset The offset to retrieve.
|
||||||
|
*
|
||||||
|
* @return mixed The value at the specified offset.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function offsetGet(mixed $offset): mixed
|
||||||
|
{
|
||||||
|
if (!is_string($offset))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return $this->get($offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the value at a given offset.
|
||||||
|
*
|
||||||
|
* @param mixed $offset The offset to assign the value to.
|
||||||
|
* @param mixed $value The value to set.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function offsetSet(mixed $offset, mixed $value): void
|
||||||
|
{
|
||||||
|
if (!is_string($offset))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$this->set($offset, $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unset the value at a given offset.
|
||||||
|
*
|
||||||
|
* @param mixed $offset The offset to unset.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function offsetUnset(mixed $offset): void
|
||||||
|
{
|
||||||
|
if (!is_string($offset))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$this->remove($offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve an external iterator for the registry.
|
||||||
|
*
|
||||||
|
* @return \Traversable An instance of an object implementing Iterator or Traversable.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function getIterator(): \Traversable
|
||||||
|
{
|
||||||
|
return new \ArrayIterator($this->active);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the registry data as an associative array.
|
||||||
|
*
|
||||||
|
* @return array The registry data.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function toArray(): array
|
||||||
|
{
|
||||||
|
return $this->active;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the registry data as an object.
|
||||||
|
*
|
||||||
|
* @return object The registry data converted to an object.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function toObject()
|
||||||
|
{
|
||||||
|
return $this->arrayToObject($this->active);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts the registry data to a string in the specified format.
|
||||||
|
*
|
||||||
|
* @param string $format The format to output the string in. Supported formats: 'json', 'ini', 'xml', 'php'.
|
||||||
|
* @param array $options Options used by the formatter.
|
||||||
|
*
|
||||||
|
* @return string The registry data in the specified format.
|
||||||
|
*
|
||||||
|
* @throws \InvalidArgumentException If the format is not supported.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function toString(string $format = 'JSON', array $options = []): string
|
||||||
|
{
|
||||||
|
// Convert the internal array to an object
|
||||||
|
$object = $this->arrayToObject($this->active);
|
||||||
|
|
||||||
|
return FormatFactory::getFormat($format, $options)->objectToString($object, $options);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flattens the registry data into a one-dimensional array.
|
||||||
|
*
|
||||||
|
* @param string|null $separator The separator for the key names.
|
||||||
|
* @param bool $full True to include the full path as keys.
|
||||||
|
*
|
||||||
|
* @return array The flattened data array.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function flatten(?string $separator = null, bool $full = false): array
|
||||||
|
{
|
||||||
|
// we use default separator
|
||||||
|
if ($separator === null)
|
||||||
|
{
|
||||||
|
$separator = $this->separator;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->flattenArray($this->active, $separator, $full);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a default value if not already set.
|
||||||
|
*
|
||||||
|
* @param string $path The registry path (e.g., 'vdm.content.builder').
|
||||||
|
* @param mixed $default The default value to set if the path does not exist.
|
||||||
|
*
|
||||||
|
* @return mixed The value of the path after the method call.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function def(string $path, $default)
|
||||||
|
{
|
||||||
|
if (!$this->exists($path))
|
||||||
|
{
|
||||||
|
$this->set($path, $default);
|
||||||
|
return $default;
|
||||||
|
}
|
||||||
|
return $this->get($path);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Merges another registry into this one.
|
||||||
|
*
|
||||||
|
* The data from the source registry will be merged into this registry,
|
||||||
|
* overwriting any existing values with the same keys.
|
||||||
|
*
|
||||||
|
* @param Registryinterface $source The registry to merge with this one.
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function merge(Registryinterface $source): self
|
||||||
|
{
|
||||||
|
$this->active = $this->arrayMergeRecursive($this->active, $source->toArray());
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears all data from the registry.
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function clear(): self
|
||||||
|
{
|
||||||
|
$this->active = [];
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extracts a subset of the registry data based on a given path.
|
||||||
|
*
|
||||||
|
* @param string $path The registry path to extract.
|
||||||
|
* @param mixed $default Optional default value, returned if the path does not exist.
|
||||||
|
* @param string|null $separator The path separator.
|
||||||
|
*
|
||||||
|
* @return self A new Registry instance with the extracted data.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function extract(string $path, $default = null, ?string $separator = null): self
|
||||||
|
{
|
||||||
|
$originalSeparator = $this->getSeparator();
|
||||||
|
if ($separator !== null)
|
||||||
|
{
|
||||||
|
$this->setSeparator($separator);
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = $this->get($path, $default);
|
||||||
|
|
||||||
|
if ($separator !== null)
|
||||||
|
{
|
||||||
|
$this->setSeparator($originalSeparator);
|
||||||
|
}
|
||||||
|
|
||||||
|
$newRegistry = new static();
|
||||||
|
|
||||||
|
if ($data !== $default)
|
||||||
|
{
|
||||||
|
if (is_array($data))
|
||||||
|
{
|
||||||
|
$newRegistry->loadArray($data);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$newRegistry->set('value', $data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $newRegistry;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Appends content into the registry.
|
||||||
|
*
|
||||||
|
* If a key exists, the value will be appended to the existing value.
|
||||||
|
*
|
||||||
|
* @param string $path The registry path (e.g., 'vdm.content.builder').
|
||||||
|
* @param mixed $value The value to append.
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function append(string $path, $value): self
|
||||||
|
{
|
||||||
|
return $this->add($path, $value, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the name of the registry.
|
||||||
|
*
|
||||||
|
* @return string|null The name of the registry.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function getName(): ?string
|
||||||
|
{
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the name of the registry.
|
||||||
|
*
|
||||||
|
* @param string|null $name The name to set.
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function setName(?string $name): self
|
||||||
|
{
|
||||||
|
$this->name = $name;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a separator value
|
* Sets a separator value
|
||||||
*
|
*
|
||||||
@ -156,6 +672,133 @@ abstract class Registry extends ActiveRegistry implements Registryinterface
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current path separator used in registry paths.
|
||||||
|
*
|
||||||
|
* @return string|null The path separator.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function getSeparator(): ?string
|
||||||
|
{
|
||||||
|
return $this->separator;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Recursively converts an array to an object.
|
||||||
|
*
|
||||||
|
* This method is used to convert the internal array data into an object
|
||||||
|
* structure suitable for serialization or other operations that require objects.
|
||||||
|
*
|
||||||
|
* @param mixed $data The data to convert.
|
||||||
|
*
|
||||||
|
* @return mixed The converted object, or the original data if not an array.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
protected function arrayToObject($data)
|
||||||
|
{
|
||||||
|
if (is_array($data))
|
||||||
|
{
|
||||||
|
$object = new \stdClass();
|
||||||
|
foreach ($data as $key => $value)
|
||||||
|
{
|
||||||
|
// Handle numeric keys for object properties
|
||||||
|
if (is_numeric($key))
|
||||||
|
{
|
||||||
|
$key = 'item' . $key;
|
||||||
|
}
|
||||||
|
$object->{$key} = $this->arrayToObject($value);
|
||||||
|
}
|
||||||
|
return $object;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Recursively converts an object to an array.
|
||||||
|
*
|
||||||
|
* This method is used to convert data loaded from formats that produce objects
|
||||||
|
* (e.g., JSON, XML) into an array structure for internal storage.
|
||||||
|
*
|
||||||
|
* @param mixed $data The data to convert.
|
||||||
|
*
|
||||||
|
* @return mixed The converted array, or the original data if not an object.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
protected function objectToArray($data)
|
||||||
|
{
|
||||||
|
return json_decode(json_encode($data), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Recursively merges two arrays.
|
||||||
|
*
|
||||||
|
* This method merges the elements of two arrays together so that the values of one
|
||||||
|
* are appended to the end of the previous one. It preserves numeric keys.
|
||||||
|
*
|
||||||
|
* @param array $array1 The array to merge into.
|
||||||
|
* @param array $array2 The array to merge from.
|
||||||
|
*
|
||||||
|
* @return array The merged array.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
protected function arrayMergeRecursive(array $array1, array $array2): array
|
||||||
|
{
|
||||||
|
foreach ($array2 as $key => $value)
|
||||||
|
{
|
||||||
|
// If the value is an array and the key exists in both arrays, merge recursively
|
||||||
|
if (is_array($value) && isset($array1[$key]) && is_array($array1[$key]))
|
||||||
|
{
|
||||||
|
$array1[$key] = $this->arrayMergeRecursive($array1[$key], $value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Otherwise, replace or set the value
|
||||||
|
$array1[$key] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $array1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function to recursively flatten the array.
|
||||||
|
*
|
||||||
|
* @param array $array The array to flatten.
|
||||||
|
* @param string $separator The separator for the key names.
|
||||||
|
* @param bool $full True to include the full path as keys.
|
||||||
|
* @param array $flattened The flattened array (used internally for recursion).
|
||||||
|
* @param string $path The current path (used internally for recursion).
|
||||||
|
*
|
||||||
|
* @return array The flattened array.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
protected function flattenArray(array $array, string $separator, bool $full, array $flattened = [], string $path = ''): array
|
||||||
|
{
|
||||||
|
foreach ($array as $key => $value)
|
||||||
|
{
|
||||||
|
if ($full)
|
||||||
|
{
|
||||||
|
$newPath = $path === '' ? $key : $path . $separator . $key;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$newPath = $key;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_array($value))
|
||||||
|
{
|
||||||
|
$flattened = $this->flattenArray($value, $separator, $full, $flattened, $newPath);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$flattened[$newPath] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $flattened;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get that the active keys from a path
|
* Get that the active keys from a path
|
||||||
*
|
*
|
||||||
|
@ -6,6 +6,225 @@
|
|||||||
*/
|
*/
|
||||||
protected ?string $separator = '.';
|
protected ?string $separator = '.';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The name of the registry.
|
||||||
|
*
|
||||||
|
* @var string|null
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
protected ?string $name = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* Initializes the Registry object with optional data.
|
||||||
|
*
|
||||||
|
* @param mixed $data Optional data to load into the registry.
|
||||||
|
* Can be an array, string, or object.
|
||||||
|
* @param string|null $separator The path separator, and empty string will flatten the registry.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function __construct($data = null, ?string $separator = null)
|
||||||
|
{
|
||||||
|
// we don't allow null on initialization (default is a dot)
|
||||||
|
// so that all class inheritance can override the separator property
|
||||||
|
// use an empty string if you want to flatten the registry
|
||||||
|
if ($separator !== null)
|
||||||
|
{
|
||||||
|
$this->setSeparator($separator);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($data !== null)
|
||||||
|
{
|
||||||
|
if (is_array($data))
|
||||||
|
{
|
||||||
|
$this->loadArray($data);
|
||||||
|
}
|
||||||
|
elseif (is_string($data))
|
||||||
|
{
|
||||||
|
$this->loadString($data);
|
||||||
|
}
|
||||||
|
elseif (is_object($data))
|
||||||
|
{
|
||||||
|
$this->loadObject($data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Magic method to get a value from the registry.
|
||||||
|
*
|
||||||
|
* Allows for accessing registry data using object property syntax.
|
||||||
|
*
|
||||||
|
* @param string $name The name of the property to get.
|
||||||
|
*
|
||||||
|
* @return mixed The value of the property, or null if not found.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function __get($name)
|
||||||
|
{
|
||||||
|
return $this->get($name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Magic method to set a value in the registry.
|
||||||
|
*
|
||||||
|
* Allows for setting registry data using object property syntax.
|
||||||
|
*
|
||||||
|
* @param string $name The name of the property to set.
|
||||||
|
* @param mixed $value The value to set.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function __set($name, $value)
|
||||||
|
{
|
||||||
|
$this->set($name, $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Magic method to check if a property is set in the registry.
|
||||||
|
*
|
||||||
|
* Allows for using isset() on registry properties.
|
||||||
|
*
|
||||||
|
* @param string $name The name of the property to check.
|
||||||
|
*
|
||||||
|
* @return bool True if the property is set, false otherwise.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function __isset($name)
|
||||||
|
{
|
||||||
|
return $this->exists($name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Magic method to unset a property in the registry.
|
||||||
|
*
|
||||||
|
* Allows for using unset() on registry properties.
|
||||||
|
*
|
||||||
|
* @param string $name The name of the property to unset.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function __unset($name)
|
||||||
|
{
|
||||||
|
$this->remove($name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Magic method to clone the registry.
|
||||||
|
*
|
||||||
|
* Performs a deep copy of the registry data.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function __clone()
|
||||||
|
{
|
||||||
|
$this->active = unserialize(serialize($this->active));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Magic method to convert the registry to a string.
|
||||||
|
*
|
||||||
|
* Returns the registry data in JSON format.
|
||||||
|
*
|
||||||
|
* @return string The registry data in JSON format.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function __toString()
|
||||||
|
{
|
||||||
|
return $this->toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads data into the registry from a string using Joomla's format classes.
|
||||||
|
*
|
||||||
|
* @param string $data The data string to load.
|
||||||
|
* @param string $format The format of the data string. Supported formats: 'json', 'ini', 'xml', 'php'.
|
||||||
|
* @param array $options Options used by the formatter
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
* @throws \InvalidArgumentException If the format is not supported.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function loadString(string $data, string $format = 'JSON', array $options = []): self
|
||||||
|
{
|
||||||
|
// Load a string into the given namespace [or default namespace if not given]
|
||||||
|
$object = FormatFactory::getFormat($format, $options)->stringToObject($data, $options);
|
||||||
|
|
||||||
|
// Merge the object into the registry
|
||||||
|
$this->loadObject($object);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads data into the registry from an object.
|
||||||
|
*
|
||||||
|
* @param object $object The data object to load.
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function loadObject(object $object): self
|
||||||
|
{
|
||||||
|
// Convert the object to an array
|
||||||
|
$array = $this->objectToArray($object);
|
||||||
|
|
||||||
|
// Merge the array into the registry
|
||||||
|
$this->loadArray($array);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads data into the registry from an array.
|
||||||
|
*
|
||||||
|
* The loaded data will be merged into the registry's existing data.
|
||||||
|
*
|
||||||
|
* @param array $array The array of data to load into the registry.
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function loadArray(array $array): self
|
||||||
|
{
|
||||||
|
$this->active = $this->arrayMergeRecursive($this->active, $array);
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads data into the registry from a file.
|
||||||
|
*
|
||||||
|
* @param string $path The path to the file to load.
|
||||||
|
* @param string $format The format of the file. Supported formats: 'json', 'ini', 'xml', 'php'.
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
* @throws \InvalidArgumentException If the file does not exist or is not readable.
|
||||||
|
* @throws \RuntimeException If the file cannot be read.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function loadFile(string $path, string $format = 'json'): self
|
||||||
|
{
|
||||||
|
if (!file_exists($path) || !is_readable($path))
|
||||||
|
{
|
||||||
|
throw new \InvalidArgumentException("File does not exist or is not readable: {$path}");
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = file_get_contents($path);
|
||||||
|
|
||||||
|
if ($data === false)
|
||||||
|
{
|
||||||
|
throw new \RuntimeException("Failed to read file: {$path}");
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->loadString($data, $format);
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a value into the registry using multiple keys.
|
* Sets a value into the registry using multiple keys.
|
||||||
*
|
*
|
||||||
@ -64,7 +283,7 @@
|
|||||||
* @return mixed The value or sub-array from the storage. Null if the location doesn't exist.
|
* @return mixed The value or sub-array from the storage. Null if the location doesn't exist.
|
||||||
* @since 3.2.0
|
* @since 3.2.0
|
||||||
*/
|
*/
|
||||||
public function get(string $path, $default = null)
|
public function get(string $path, $default = null): mixed
|
||||||
{
|
{
|
||||||
if (($keys = $this->getActiveKeys($path)) === null)
|
if (($keys = $this->getActiveKeys($path)) === null)
|
||||||
{
|
{
|
||||||
@ -114,6 +333,301 @@
|
|||||||
return $this->existsActive(...$keys);
|
return $this->existsActive(...$keys);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Specify data which should be serialized to JSON.
|
||||||
|
*
|
||||||
|
* @return mixed Data which can be serialized by json_encode(),
|
||||||
|
* which is a value of any type other than a resource.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function jsonSerialize(): mixed
|
||||||
|
{
|
||||||
|
return $this->active;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Count elements of the registry.
|
||||||
|
*
|
||||||
|
* @return int The number of elements in the registry.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function count(): int
|
||||||
|
{
|
||||||
|
return count($this->active);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Whether a given offset exists in the registry.
|
||||||
|
*
|
||||||
|
* @param mixed $offset An offset to check for.
|
||||||
|
*
|
||||||
|
* @return bool True if the offset exists, false otherwise.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function offsetExists(mixed $offset): bool
|
||||||
|
{
|
||||||
|
if (!is_string($offset))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return $this->exists($offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve the value at a given offset.
|
||||||
|
*
|
||||||
|
* @param mixed $offset The offset to retrieve.
|
||||||
|
*
|
||||||
|
* @return mixed The value at the specified offset.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function offsetGet(mixed $offset): mixed
|
||||||
|
{
|
||||||
|
if (!is_string($offset))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return $this->get($offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the value at a given offset.
|
||||||
|
*
|
||||||
|
* @param mixed $offset The offset to assign the value to.
|
||||||
|
* @param mixed $value The value to set.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function offsetSet(mixed $offset, mixed $value): void
|
||||||
|
{
|
||||||
|
if (!is_string($offset))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$this->set($offset, $value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unset the value at a given offset.
|
||||||
|
*
|
||||||
|
* @param mixed $offset The offset to unset.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function offsetUnset(mixed $offset): void
|
||||||
|
{
|
||||||
|
if (!is_string($offset))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$this->remove($offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Retrieve an external iterator for the registry.
|
||||||
|
*
|
||||||
|
* @return \Traversable An instance of an object implementing Iterator or Traversable.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function getIterator(): \Traversable
|
||||||
|
{
|
||||||
|
return new \ArrayIterator($this->active);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the registry data as an associative array.
|
||||||
|
*
|
||||||
|
* @return array The registry data.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function toArray(): array
|
||||||
|
{
|
||||||
|
return $this->active;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the registry data as an object.
|
||||||
|
*
|
||||||
|
* @return object The registry data converted to an object.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function toObject()
|
||||||
|
{
|
||||||
|
return $this->arrayToObject($this->active);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts the registry data to a string in the specified format.
|
||||||
|
*
|
||||||
|
* @param string $format The format to output the string in. Supported formats: 'json', 'ini', 'xml', 'php'.
|
||||||
|
* @param array $options Options used by the formatter.
|
||||||
|
*
|
||||||
|
* @return string The registry data in the specified format.
|
||||||
|
*
|
||||||
|
* @throws \InvalidArgumentException If the format is not supported.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function toString(string $format = 'JSON', array $options = []): string
|
||||||
|
{
|
||||||
|
// Convert the internal array to an object
|
||||||
|
$object = $this->arrayToObject($this->active);
|
||||||
|
|
||||||
|
return FormatFactory::getFormat($format, $options)->objectToString($object, $options);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Flattens the registry data into a one-dimensional array.
|
||||||
|
*
|
||||||
|
* @param string|null $separator The separator for the key names.
|
||||||
|
* @param bool $full True to include the full path as keys.
|
||||||
|
*
|
||||||
|
* @return array The flattened data array.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function flatten(?string $separator = null, bool $full = false): array
|
||||||
|
{
|
||||||
|
// we use default separator
|
||||||
|
if ($separator === null)
|
||||||
|
{
|
||||||
|
$separator = $this->separator;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->flattenArray($this->active, $separator, $full);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a default value if not already set.
|
||||||
|
*
|
||||||
|
* @param string $path The registry path (e.g., 'vdm.content.builder').
|
||||||
|
* @param mixed $default The default value to set if the path does not exist.
|
||||||
|
*
|
||||||
|
* @return mixed The value of the path after the method call.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function def(string $path, $default)
|
||||||
|
{
|
||||||
|
if (!$this->exists($path))
|
||||||
|
{
|
||||||
|
$this->set($path, $default);
|
||||||
|
return $default;
|
||||||
|
}
|
||||||
|
return $this->get($path);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Merges another registry into this one.
|
||||||
|
*
|
||||||
|
* The data from the source registry will be merged into this registry,
|
||||||
|
* overwriting any existing values with the same keys.
|
||||||
|
*
|
||||||
|
* @param Registryinterface $source The registry to merge with this one.
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function merge(Registryinterface $source): self
|
||||||
|
{
|
||||||
|
$this->active = $this->arrayMergeRecursive($this->active, $source->toArray());
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clears all data from the registry.
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function clear(): self
|
||||||
|
{
|
||||||
|
$this->active = [];
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extracts a subset of the registry data based on a given path.
|
||||||
|
*
|
||||||
|
* @param string $path The registry path to extract.
|
||||||
|
* @param mixed $default Optional default value, returned if the path does not exist.
|
||||||
|
* @param string|null $separator The path separator.
|
||||||
|
*
|
||||||
|
* @return self A new Registry instance with the extracted data.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function extract(string $path, $default = null, ?string $separator = null): self
|
||||||
|
{
|
||||||
|
$originalSeparator = $this->getSeparator();
|
||||||
|
if ($separator !== null)
|
||||||
|
{
|
||||||
|
$this->setSeparator($separator);
|
||||||
|
}
|
||||||
|
|
||||||
|
$data = $this->get($path, $default);
|
||||||
|
|
||||||
|
if ($separator !== null)
|
||||||
|
{
|
||||||
|
$this->setSeparator($originalSeparator);
|
||||||
|
}
|
||||||
|
|
||||||
|
$newRegistry = new static();
|
||||||
|
|
||||||
|
if ($data !== $default)
|
||||||
|
{
|
||||||
|
if (is_array($data))
|
||||||
|
{
|
||||||
|
$newRegistry->loadArray($data);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$newRegistry->set('value', $data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $newRegistry;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Appends content into the registry.
|
||||||
|
*
|
||||||
|
* If a key exists, the value will be appended to the existing value.
|
||||||
|
*
|
||||||
|
* @param string $path The registry path (e.g., 'vdm.content.builder').
|
||||||
|
* @param mixed $value The value to append.
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function append(string $path, $value): self
|
||||||
|
{
|
||||||
|
return $this->add($path, $value, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the name of the registry.
|
||||||
|
*
|
||||||
|
* @return string|null The name of the registry.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function getName(): ?string
|
||||||
|
{
|
||||||
|
return $this->name;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the name of the registry.
|
||||||
|
*
|
||||||
|
* @param string|null $name The name to set.
|
||||||
|
*
|
||||||
|
* @return self
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function setName(?string $name): self
|
||||||
|
{
|
||||||
|
$this->name = $name;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets a separator value
|
* Sets a separator value
|
||||||
*
|
*
|
||||||
@ -129,6 +643,133 @@
|
|||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current path separator used in registry paths.
|
||||||
|
*
|
||||||
|
* @return string|null The path separator.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function getSeparator(): ?string
|
||||||
|
{
|
||||||
|
return $this->separator;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Recursively converts an array to an object.
|
||||||
|
*
|
||||||
|
* This method is used to convert the internal array data into an object
|
||||||
|
* structure suitable for serialization or other operations that require objects.
|
||||||
|
*
|
||||||
|
* @param mixed $data The data to convert.
|
||||||
|
*
|
||||||
|
* @return mixed The converted object, or the original data if not an array.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
protected function arrayToObject($data)
|
||||||
|
{
|
||||||
|
if (is_array($data))
|
||||||
|
{
|
||||||
|
$object = new \stdClass();
|
||||||
|
foreach ($data as $key => $value)
|
||||||
|
{
|
||||||
|
// Handle numeric keys for object properties
|
||||||
|
if (is_numeric($key))
|
||||||
|
{
|
||||||
|
$key = 'item' . $key;
|
||||||
|
}
|
||||||
|
$object->{$key} = $this->arrayToObject($value);
|
||||||
|
}
|
||||||
|
return $object;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return $data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Recursively converts an object to an array.
|
||||||
|
*
|
||||||
|
* This method is used to convert data loaded from formats that produce objects
|
||||||
|
* (e.g., JSON, XML) into an array structure for internal storage.
|
||||||
|
*
|
||||||
|
* @param mixed $data The data to convert.
|
||||||
|
*
|
||||||
|
* @return mixed The converted array, or the original data if not an object.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
protected function objectToArray($data)
|
||||||
|
{
|
||||||
|
return json_decode(json_encode($data), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Recursively merges two arrays.
|
||||||
|
*
|
||||||
|
* This method merges the elements of two arrays together so that the values of one
|
||||||
|
* are appended to the end of the previous one. It preserves numeric keys.
|
||||||
|
*
|
||||||
|
* @param array $array1 The array to merge into.
|
||||||
|
* @param array $array2 The array to merge from.
|
||||||
|
*
|
||||||
|
* @return array The merged array.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
protected function arrayMergeRecursive(array $array1, array $array2): array
|
||||||
|
{
|
||||||
|
foreach ($array2 as $key => $value)
|
||||||
|
{
|
||||||
|
// If the value is an array and the key exists in both arrays, merge recursively
|
||||||
|
if (is_array($value) && isset($array1[$key]) && is_array($array1[$key]))
|
||||||
|
{
|
||||||
|
$array1[$key] = $this->arrayMergeRecursive($array1[$key], $value);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Otherwise, replace or set the value
|
||||||
|
$array1[$key] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $array1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function to recursively flatten the array.
|
||||||
|
*
|
||||||
|
* @param array $array The array to flatten.
|
||||||
|
* @param string $separator The separator for the key names.
|
||||||
|
* @param bool $full True to include the full path as keys.
|
||||||
|
* @param array $flattened The flattened array (used internally for recursion).
|
||||||
|
* @param string $path The current path (used internally for recursion).
|
||||||
|
*
|
||||||
|
* @return array The flattened array.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
protected function flattenArray(array $array, string $separator, bool $full, array $flattened = [], string $path = ''): array
|
||||||
|
{
|
||||||
|
foreach ($array as $key => $value)
|
||||||
|
{
|
||||||
|
if ($full)
|
||||||
|
{
|
||||||
|
$newPath = $path === '' ? $key : $path . $separator . $key;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$newPath = $key;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (is_array($value))
|
||||||
|
{
|
||||||
|
$flattened = $this->flattenArray($value, $separator, $full, $flattened, $newPath);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$flattened[$newPath] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $flattened;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get that the active keys from a path
|
* Get that the active keys from a path
|
||||||
*
|
*
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
{
|
{
|
||||||
"add_head": "0",
|
"add_head": "1",
|
||||||
"add_licensing_template": "2",
|
"add_licensing_template": "2",
|
||||||
"extends": "43134867-5cb8-4280-9be8-309fd2fd135f",
|
"extends": "43134867-5cb8-4280-9be8-309fd2fd135f",
|
||||||
"guid": "7e822c03-1b20-41d1-9427-f5b8d5836af7",
|
"guid": "7e822c03-1b20-41d1-9427-f5b8d5836af7",
|
||||||
"implements": [
|
"implements": [
|
||||||
"64e291c2-11f1-423d-a44d-837cc12cc017"
|
"64e291c2-11f1-423d-a44d-837cc12cc017",
|
||||||
|
"-1"
|
||||||
],
|
],
|
||||||
"load_selection": null,
|
"load_selection": null,
|
||||||
"name": "Registry",
|
"name": "Registry",
|
||||||
@ -14,8 +15,9 @@
|
|||||||
"use_selection": null,
|
"use_selection": null,
|
||||||
"extendsinterfaces": null,
|
"extendsinterfaces": null,
|
||||||
"namespace": "[[[NamespacePrefix]]]\\Joomla\\Abstraction.Registry",
|
"namespace": "[[[NamespacePrefix]]]\\Joomla\\Abstraction.Registry",
|
||||||
"description": "VDM Basic Registry.\r\n\r\nDon't use this beyond 10 dimensional depth for best performance.\r\n\r\n@since 3.2.0",
|
"description": "VDM Basic Registry.\r\n\r\nDon't use this beyond 10 dimensional depth for best performance.\r\n\r\n@since 3.2.0\r\n@since 5.0.4 Joomla Registry Compatible",
|
||||||
|
"implements_custom": " \\JsonSerializable, \\ArrayAccess, \\IteratorAggregate, \\Countable",
|
||||||
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\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",
|
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\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": "",
|
"head": "use Joomla\\Registry\\Factory as FormatFactory;",
|
||||||
"composer": ""
|
"composer": ""
|
||||||
}
|
}
|
54
src/9769f3b2-17bf-4f20-b54b-3a4ebe572b36/README.md
Normal file
54
src/9769f3b2-17bf-4f20-b54b-3a4ebe572b36/README.md
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
```
|
||||||
|
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||||
|
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||||
|
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||||
|
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||||
|
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||||
|
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||||
|
```
|
||||||
|
# abstract class ComponentConfig (Details)
|
||||||
|
> namespace: **VDM\Joomla\Componentbuilder\Abstraction**
|
||||||
|
> extends: **FunctionRegistry**
|
||||||
|
|
||||||
|
```uml
|
||||||
|
@startuml
|
||||||
|
abstract ComponentConfig #Orange {
|
||||||
|
# Input $input
|
||||||
|
# JoomlaRegistry $params
|
||||||
|
+ __construct(?Input $input = null, ?JoomlaRegistry $params = null)
|
||||||
|
}
|
||||||
|
|
||||||
|
note right of ComponentConfig::__construct
|
||||||
|
Constructor
|
||||||
|
|
||||||
|
since: 3.2.0
|
||||||
|
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---9769f3b2_17bf_4f20_b54b_3a4ebe572b36---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)
|
||||||
|
|
61
src/9769f3b2-17bf-4f20-b54b-3a4ebe572b36/code.php
Normal file
61
src/9769f3b2-17bf-4f20-b54b-3a4ebe572b36/code.php
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 4th September, 2022
|
||||||
|
* @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\Abstraction;
|
||||||
|
|
||||||
|
|
||||||
|
use Joomla\Registry\Registry as JoomlaRegistry;
|
||||||
|
use Joomla\CMS\Factory;
|
||||||
|
use Joomla\Input\Input;
|
||||||
|
use VDM\Joomla\Utilities\Component\Helper;
|
||||||
|
use VDM\Joomla\Utilities\String\ClassfunctionHelper;
|
||||||
|
use VDM\Joomla\Abstraction\FunctionRegistry;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Component Configurations
|
||||||
|
*
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
abstract class ComponentConfig extends FunctionRegistry
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Hold a Input object for easier access to the input variables.
|
||||||
|
*
|
||||||
|
* @var Input
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
protected Input $input;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Params
|
||||||
|
*
|
||||||
|
* @var JoomlaRegistry
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
protected JoomlaRegistry $params;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param Input|null $input Input
|
||||||
|
* @param Registry|null $params The component parameters
|
||||||
|
*
|
||||||
|
* @throws \Exception
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
public function __construct(?Input $input = null, ?JoomlaRegistry $params = null)
|
||||||
|
{
|
||||||
|
$this->input = $input ?: Factory::getApplication()->input;
|
||||||
|
$this->params = $params ?: Helper::getParams('com_componentbuilder');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
30
src/9769f3b2-17bf-4f20-b54b-3a4ebe572b36/code.power
Normal file
30
src/9769f3b2-17bf-4f20-b54b-3a4ebe572b36/code.power
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
/**
|
||||||
|
* Hold a Input object for easier access to the input variables.
|
||||||
|
*
|
||||||
|
* @var Input
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
protected Input $input;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Params
|
||||||
|
*
|
||||||
|
* @var JoomlaRegistry
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
protected JoomlaRegistry $params;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param Input|null $input Input
|
||||||
|
* @param Registry|null $params The component parameters
|
||||||
|
*
|
||||||
|
* @throws \Exception
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
public function __construct(?Input $input = null, ?JoomlaRegistry $params = null)
|
||||||
|
{
|
||||||
|
$this->input = $input ?: Factory::getApplication()->input;
|
||||||
|
$this->params = $params ?: Helper::getParams('com_###component###');
|
||||||
|
}
|
28
src/9769f3b2-17bf-4f20-b54b-3a4ebe572b36/settings.json
Normal file
28
src/9769f3b2-17bf-4f20-b54b-3a4ebe572b36/settings.json
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
{
|
||||||
|
"add_head": "1",
|
||||||
|
"add_licensing_template": "2",
|
||||||
|
"extends": "ffbd4e1f-a342-4080-ab7d-1de3741bf319",
|
||||||
|
"guid": "9769f3b2-17bf-4f20-b54b-3a4ebe572b36",
|
||||||
|
"implements": null,
|
||||||
|
"load_selection": null,
|
||||||
|
"name": "ComponentConfig",
|
||||||
|
"power_version": "1.0.0",
|
||||||
|
"system_name": "JCB.Abstraction.ComponentConfig",
|
||||||
|
"type": "abstract class",
|
||||||
|
"use_selection": {
|
||||||
|
"use_selection0": {
|
||||||
|
"use": "640b5352-fb09-425f-a26e-cd44eda03f15",
|
||||||
|
"as": "default"
|
||||||
|
},
|
||||||
|
"use_selection1": {
|
||||||
|
"use": "30c5b4c2-f75f-4d15-869a-f8bfedd87358",
|
||||||
|
"as": "default"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"extendsinterfaces": null,
|
||||||
|
"namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Abstraction.ComponentConfig",
|
||||||
|
"description": "Component Configurations\r\n\r\n@since 3.2.0",
|
||||||
|
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\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\\Registry\\Registry as JoomlaRegistry;\r\nuse Joomla\\CMS\\Factory;\r\nuse Joomla\\Input\\Input;",
|
||||||
|
"composer": ""
|
||||||
|
}
|
@ -109,8 +109,8 @@ final class Table extends BaseTable implements TableInterface
|
|||||||
'tab_name' => 'publishing',
|
'tab_name' => 'publishing',
|
||||||
'db' => [
|
'db' => [
|
||||||
'type' => 'DATETIME',
|
'type' => 'DATETIME',
|
||||||
'default' => '0000-00-00 00:00:00',
|
'default' => 'CURRENT_TIMESTAMP',
|
||||||
'null_switch' => 'NOT NULL',
|
'null_switch' => 'NULL',
|
||||||
'unique_key' => false,
|
'unique_key' => false,
|
||||||
'key' => false,
|
'key' => false,
|
||||||
],
|
],
|
||||||
@ -1626,8 +1626,8 @@ final class Table extends BaseTable implements TableInterface
|
|||||||
'tab_name' => 'publishing',
|
'tab_name' => 'publishing',
|
||||||
'db' => [
|
'db' => [
|
||||||
'type' => 'DATETIME',
|
'type' => 'DATETIME',
|
||||||
'default' => '0000-00-00 00:00:00',
|
'default' => 'EMPTY',
|
||||||
'null_switch' => 'NOT NULL',
|
'null_switch' => 'NULL',
|
||||||
'unique_key' => false,
|
'unique_key' => false,
|
||||||
'key' => false,
|
'key' => false,
|
||||||
],
|
],
|
||||||
|
@ -18,6 +18,7 @@ interface GrepInterface #Lavender {
|
|||||||
+ setBranchDefaultName(?string $name) : void
|
+ setBranchDefaultName(?string $name) : void
|
||||||
+ setIndexPath(string $indexPath) : void
|
+ setIndexPath(string $indexPath) : void
|
||||||
+ getRemoteIndex(string $guid) : ?object
|
+ getRemoteIndex(string $guid) : ?object
|
||||||
|
+ loadApi(Api $api, ?string $base, ...) : void
|
||||||
}
|
}
|
||||||
|
|
||||||
note right of GrepInterface::get
|
note right of GrepInterface::get
|
||||||
@ -67,6 +68,21 @@ note right of GrepInterface::getRemoteIndex
|
|||||||
return: ?object
|
return: ?object
|
||||||
end note
|
end note
|
||||||
|
|
||||||
|
note right of GrepInterface::loadApi
|
||||||
|
Loads API config using the provided base URL and token.
|
||||||
|
This method checks if the base URL contains 'https://git.vdm.dev/'.
|
||||||
|
If it does, it uses the token as is (which may be null).
|
||||||
|
If not, it ensures the token is not null by defaulting to an empty string.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: void
|
||||||
|
|
||||||
|
arguments:
|
||||||
|
Api $api
|
||||||
|
?string $base
|
||||||
|
?string $token
|
||||||
|
end note
|
||||||
|
|
||||||
@enduml
|
@enduml
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -12,6 +12,9 @@
|
|||||||
namespace VDM\Joomla\Interfaces;
|
namespace VDM\Joomla\Interfaces;
|
||||||
|
|
||||||
|
|
||||||
|
use VDM\Joomla\Interfaces\Git\ApiInterface as Api;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Global Resource Empowerment Platform
|
* Global Resource Empowerment Platform
|
||||||
*
|
*
|
||||||
@ -78,5 +81,21 @@ interface GrepInterface
|
|||||||
* @since 3.2.2
|
* @since 3.2.2
|
||||||
*/
|
*/
|
||||||
public function getRemoteIndex(string $guid): ?object;
|
public function getRemoteIndex(string $guid): ?object;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads API config using the provided base URL and token.
|
||||||
|
*
|
||||||
|
* This method checks if the base URL contains 'https://git.vdm.dev/'.
|
||||||
|
* If it does, it uses the token as is (which may be null).
|
||||||
|
* If not, it ensures the token is not null by defaulting to an empty string.
|
||||||
|
*
|
||||||
|
* @param Api $api The api object with a load_ method.
|
||||||
|
* @param string|null $base The base URL path.
|
||||||
|
* @param string|null $token The token for authentication (can be null).
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function loadApi(Api $api, ?string $base, ?string $token): void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,3 +57,19 @@
|
|||||||
* @since 3.2.2
|
* @since 3.2.2
|
||||||
*/
|
*/
|
||||||
public function getRemoteIndex(string $guid): ?object;
|
public function getRemoteIndex(string $guid): ?object;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads API config using the provided base URL and token.
|
||||||
|
*
|
||||||
|
* This method checks if the base URL contains 'https://git.vdm.dev/'.
|
||||||
|
* If it does, it uses the token as is (which may be null).
|
||||||
|
* If not, it ensures the token is not null by defaulting to an empty string.
|
||||||
|
*
|
||||||
|
* @param Api $api The api object with a load_ method.
|
||||||
|
* @param string|null $base The base URL path.
|
||||||
|
* @param string|null $token The token for authentication (can be null).
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
public function loadApi(Api $api, ?string $base, ?string $token): void;
|
@ -9,7 +9,12 @@
|
|||||||
"power_version": "1.0.0",
|
"power_version": "1.0.0",
|
||||||
"system_name": "VDM.Interfaces.GrepInterface",
|
"system_name": "VDM.Interfaces.GrepInterface",
|
||||||
"type": "interface",
|
"type": "interface",
|
||||||
"use_selection": null,
|
"use_selection": {
|
||||||
|
"use_selection0": {
|
||||||
|
"use": "17ed2fec-49d6-4731-92c3-f9cd78fb6273",
|
||||||
|
"as": "Api"
|
||||||
|
}
|
||||||
|
},
|
||||||
"extendsinterfaces": null,
|
"extendsinterfaces": null,
|
||||||
"namespace": "[[[NamespacePrefix]]]\\Joomla\\Interfaces.GrepInterface",
|
"namespace": "[[[NamespacePrefix]]]\\Joomla\\Interfaces.GrepInterface",
|
||||||
"description": "Global Resource Empowerment Platform\r\n\r\n@since 3.2.1",
|
"description": "Global Resource Empowerment Platform\r\n\r\n@since 3.2.1",
|
||||||
|
@ -108,8 +108,7 @@ abstract class BaseTable implements TableInterface
|
|||||||
'store' => NULL,
|
'store' => NULL,
|
||||||
'tab_name' => NULL,
|
'tab_name' => NULL,
|
||||||
'db' => [
|
'db' => [
|
||||||
'type' => 'INT(10) unsigned',
|
'type' => 'INT unsigned',
|
||||||
'default' => '0',
|
|
||||||
'null_switch' => 'NULL',
|
'null_switch' => 'NULL',
|
||||||
'key' => true,
|
'key' => true,
|
||||||
'key_name' => 'modifiedby'
|
'key_name' => 'modifiedby'
|
||||||
@ -125,7 +124,6 @@ abstract class BaseTable implements TableInterface
|
|||||||
'tab_name' => NULL,
|
'tab_name' => NULL,
|
||||||
'db' => [
|
'db' => [
|
||||||
'type' => 'DATETIME',
|
'type' => 'DATETIME',
|
||||||
'default' => '0000-00-00 00:00:00',
|
|
||||||
'null_switch' => 'NULL'
|
'null_switch' => 'NULL'
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
@ -138,7 +136,7 @@ abstract class BaseTable implements TableInterface
|
|||||||
'store' => NULL,
|
'store' => NULL,
|
||||||
'tab_name' => NULL,
|
'tab_name' => NULL,
|
||||||
'db' => [
|
'db' => [
|
||||||
'type' => 'INT(10) unsigned',
|
'type' => 'INT unsigned',
|
||||||
'default' => '0',
|
'default' => '0',
|
||||||
'null_switch' => 'NULL',
|
'null_switch' => 'NULL',
|
||||||
'key' => true,
|
'key' => true,
|
||||||
@ -155,7 +153,7 @@ abstract class BaseTable implements TableInterface
|
|||||||
'tab_name' => NULL,
|
'tab_name' => NULL,
|
||||||
'db' => [
|
'db' => [
|
||||||
'type' => 'DATETIME',
|
'type' => 'DATETIME',
|
||||||
'default' => '0000-00-00 00:00:00',
|
'default' => 'CURRENT_TIMESTAMP',
|
||||||
'null_switch' => 'NULL'
|
'null_switch' => 'NULL'
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
@ -168,8 +166,7 @@ abstract class BaseTable implements TableInterface
|
|||||||
'store' => NULL,
|
'store' => NULL,
|
||||||
'tab_name' => NULL,
|
'tab_name' => NULL,
|
||||||
'db' => [
|
'db' => [
|
||||||
'type' => 'INT(10) unsigned',
|
'type' => 'INT unsigned',
|
||||||
'default' => '0',
|
|
||||||
'null_switch' => 'NULL',
|
'null_switch' => 'NULL',
|
||||||
'key' => true,
|
'key' => true,
|
||||||
'key_name' => 'checkout'
|
'key_name' => 'checkout'
|
||||||
@ -185,7 +182,6 @@ abstract class BaseTable implements TableInterface
|
|||||||
'tab_name' => NULL,
|
'tab_name' => NULL,
|
||||||
'db' => [
|
'db' => [
|
||||||
'type' => 'DATETIME',
|
'type' => 'DATETIME',
|
||||||
'default' => '0000-00-00 00:00:00',
|
|
||||||
'null_switch' => 'NULL'
|
'null_switch' => 'NULL'
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
@ -84,8 +84,7 @@
|
|||||||
'store' => NULL,
|
'store' => NULL,
|
||||||
'tab_name' => NULL,
|
'tab_name' => NULL,
|
||||||
'db' => [
|
'db' => [
|
||||||
'type' => 'INT(10) unsigned',
|
'type' => 'INT unsigned',
|
||||||
'default' => '0',
|
|
||||||
'null_switch' => 'NULL',
|
'null_switch' => 'NULL',
|
||||||
'key' => true,
|
'key' => true,
|
||||||
'key_name' => 'modifiedby'
|
'key_name' => 'modifiedby'
|
||||||
@ -101,7 +100,6 @@
|
|||||||
'tab_name' => NULL,
|
'tab_name' => NULL,
|
||||||
'db' => [
|
'db' => [
|
||||||
'type' => 'DATETIME',
|
'type' => 'DATETIME',
|
||||||
'default' => '0000-00-00 00:00:00',
|
|
||||||
'null_switch' => 'NULL'
|
'null_switch' => 'NULL'
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
@ -114,7 +112,7 @@
|
|||||||
'store' => NULL,
|
'store' => NULL,
|
||||||
'tab_name' => NULL,
|
'tab_name' => NULL,
|
||||||
'db' => [
|
'db' => [
|
||||||
'type' => 'INT(10) unsigned',
|
'type' => 'INT unsigned',
|
||||||
'default' => '0',
|
'default' => '0',
|
||||||
'null_switch' => 'NULL',
|
'null_switch' => 'NULL',
|
||||||
'key' => true,
|
'key' => true,
|
||||||
@ -131,7 +129,7 @@
|
|||||||
'tab_name' => NULL,
|
'tab_name' => NULL,
|
||||||
'db' => [
|
'db' => [
|
||||||
'type' => 'DATETIME',
|
'type' => 'DATETIME',
|
||||||
'default' => '0000-00-00 00:00:00',
|
'default' => 'CURRENT_TIMESTAMP',
|
||||||
'null_switch' => 'NULL'
|
'null_switch' => 'NULL'
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
@ -144,8 +142,7 @@
|
|||||||
'store' => NULL,
|
'store' => NULL,
|
||||||
'tab_name' => NULL,
|
'tab_name' => NULL,
|
||||||
'db' => [
|
'db' => [
|
||||||
'type' => 'INT(10) unsigned',
|
'type' => 'INT unsigned',
|
||||||
'default' => '0',
|
|
||||||
'null_switch' => 'NULL',
|
'null_switch' => 'NULL',
|
||||||
'key' => true,
|
'key' => true,
|
||||||
'key_name' => 'checkout'
|
'key_name' => 'checkout'
|
||||||
@ -161,7 +158,6 @@
|
|||||||
'tab_name' => NULL,
|
'tab_name' => NULL,
|
||||||
'db' => [
|
'db' => [
|
||||||
'type' => 'DATETIME',
|
'type' => 'DATETIME',
|
||||||
'default' => '0000-00-00 00:00:00',
|
|
||||||
'null_switch' => 'NULL'
|
'null_switch' => 'NULL'
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
@ -416,6 +416,8 @@ abstract class Set implements SetInterface
|
|||||||
|
|
||||||
$settings = $this->mergeIndexSettings($repoGuid, $settings);
|
$settings = $this->mergeIndexSettings($repoGuid, $settings);
|
||||||
|
|
||||||
|
$this->grep->loadApi($this->git, $repo->base ?? null, $repo->token ?? null);
|
||||||
|
|
||||||
$this->updateIndexMainFile(
|
$this->updateIndexMainFile(
|
||||||
$repo,
|
$repo,
|
||||||
$this->getIndexSettingsPath(),
|
$this->getIndexSettingsPath(),
|
||||||
@ -429,6 +431,8 @@ abstract class Set implements SetInterface
|
|||||||
$this->mainReadme->get($settings),
|
$this->mainReadme->get($settings),
|
||||||
'Update main readme file'
|
'Update main readme file'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->git->reset_();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -580,7 +584,7 @@ abstract class Set implements SetInterface
|
|||||||
|
|
||||||
$this->setRepoPlaceholders($repo);
|
$this->setRepoPlaceholders($repo);
|
||||||
|
|
||||||
$this->git->load_($repo->base ?? null, $repo->token ?? null);
|
$this->grep->loadApi($this->git, $repo->base ?? null, $repo->token ?? null);
|
||||||
|
|
||||||
if (($existing = $this->grep->get($item->guid, ['remote'], $repo)) !== null)
|
if (($existing = $this->grep->get($item->guid, ['remote'], $repo)) !== null)
|
||||||
{
|
{
|
||||||
|
@ -386,6 +386,8 @@
|
|||||||
|
|
||||||
$settings = $this->mergeIndexSettings($repoGuid, $settings);
|
$settings = $this->mergeIndexSettings($repoGuid, $settings);
|
||||||
|
|
||||||
|
$this->grep->loadApi($this->git, $repo->base ?? null, $repo->token ?? null);
|
||||||
|
|
||||||
$this->updateIndexMainFile(
|
$this->updateIndexMainFile(
|
||||||
$repo,
|
$repo,
|
||||||
$this->getIndexSettingsPath(),
|
$this->getIndexSettingsPath(),
|
||||||
@ -399,6 +401,8 @@
|
|||||||
$this->mainReadme->get($settings),
|
$this->mainReadme->get($settings),
|
||||||
'Update main readme file'
|
'Update main readme file'
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$this->git->reset_();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -550,7 +554,7 @@
|
|||||||
|
|
||||||
$this->setRepoPlaceholders($repo);
|
$this->setRepoPlaceholders($repo);
|
||||||
|
|
||||||
$this->git->load_($repo->base ?? null, $repo->token ?? null);
|
$this->grep->loadApi($this->git, $repo->base ?? null, $repo->token ?? null);
|
||||||
|
|
||||||
if (($existing = $this->grep->get($item->guid, ['remote'], $repo)) !== null)
|
if (($existing = $this->grep->get($item->guid, ['remote'], $repo)) !== null)
|
||||||
{
|
{
|
||||||
|
@ -15,6 +15,7 @@ class Message << (F,LightGreen) >> #RoyalBlue {
|
|||||||
# Update $update
|
# Update $update
|
||||||
# Insert $insert
|
# Insert $insert
|
||||||
- array $success
|
- array $success
|
||||||
|
- array $info
|
||||||
- array $error
|
- array $error
|
||||||
- ?string $guid
|
- ?string $guid
|
||||||
- ?string $entity
|
- ?string $entity
|
||||||
|
@ -49,6 +49,14 @@ final class Message implements ImportMessageInterface
|
|||||||
*/
|
*/
|
||||||
private array $success = [];
|
private array $success = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The info message bus.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @since 5.0.2
|
||||||
|
*/
|
||||||
|
private array $info = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The error message bus.
|
* The error message bus.
|
||||||
*
|
*
|
||||||
@ -117,6 +125,8 @@ final class Message implements ImportMessageInterface
|
|||||||
$this->guid = $guid;
|
$this->guid = $guid;
|
||||||
$this->entity = $entity;
|
$this->entity = $entity;
|
||||||
$this->table = $table;
|
$this->table = $table;
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -22,6 +22,14 @@
|
|||||||
*/
|
*/
|
||||||
private array $success = [];
|
private array $success = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The info message bus.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @since 5.0.2
|
||||||
|
*/
|
||||||
|
private array $info = [];
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The error message bus.
|
* The error message bus.
|
||||||
*
|
*
|
||||||
@ -90,6 +98,8 @@
|
|||||||
$this->guid = $guid;
|
$this->guid = $guid;
|
||||||
$this->entity = $entity;
|
$this->entity = $entity;
|
||||||
$this->table = $table;
|
$this->table = $table;
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace VDM\Joomla\Componentbuilder\Import;
|
namespace VDM\Joomla\Componentbuilder\Import;
|
||||||
|
|
||||||
|
|
||||||
|
use Joomla\DI\Container;
|
||||||
use VDM\Joomla\Service\Table;
|
use VDM\Joomla\Service\Table;
|
||||||
use VDM\Joomla\Service\Database;
|
use VDM\Joomla\Service\Database;
|
||||||
use VDM\Joomla\Service\Model;
|
use VDM\Joomla\Service\Model;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"add_head": "0",
|
"add_head": "1",
|
||||||
"add_licensing_template": "2",
|
"add_licensing_template": "2",
|
||||||
"extends": "2e5bf608-de5c-4b00-a20d-47c26aa350d9",
|
"extends": "2e5bf608-de5c-4b00-a20d-47c26aa350d9",
|
||||||
"guid": "ff8d5fdb-2d1f-4178-bd18-a43b8efd1068",
|
"guid": "ff8d5fdb-2d1f-4178-bd18-a43b8efd1068",
|
||||||
@ -28,15 +28,15 @@
|
|||||||
"use": "a5daf189-3345-4b13-8716-c51f686f545b",
|
"use": "a5daf189-3345-4b13-8716-c51f686f545b",
|
||||||
"as": "default"
|
"as": "default"
|
||||||
},
|
},
|
||||||
"use_selection6": {
|
"use_selection4": {
|
||||||
"use": "21754a8b-2323-4a77-8459-378a74c1ec97",
|
"use": "21754a8b-2323-4a77-8459-378a74c1ec97",
|
||||||
"as": "default"
|
"as": "default"
|
||||||
},
|
},
|
||||||
"use_selection4": {
|
"use_selection5": {
|
||||||
"use": "202ccd9e-dfcf-4cde-a0ce-bde1fd27f088",
|
"use": "202ccd9e-dfcf-4cde-a0ce-bde1fd27f088",
|
||||||
"as": "default"
|
"as": "default"
|
||||||
},
|
},
|
||||||
"use_selection5": {
|
"use_selection6": {
|
||||||
"use": "c4a188de-ad78-4a6d-9d5b-01866846d701",
|
"use": "c4a188de-ad78-4a6d-9d5b-01866846d701",
|
||||||
"as": "default"
|
"as": "default"
|
||||||
}
|
}
|
||||||
@ -45,6 +45,6 @@
|
|||||||
"namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Import.Factory",
|
"namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Import.Factory",
|
||||||
"description": "Import Factory\r\n\r\n@since 3.2.2",
|
"description": "Import Factory\r\n\r\n@since 3.2.2",
|
||||||
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\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",
|
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\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": "",
|
"head": "use Joomla\\DI\\Container;",
|
||||||
"composer": ""
|
"composer": ""
|
||||||
}
|
}
|
@ -6,52 +6,49 @@
|
|||||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||||
```
|
```
|
||||||
# abstract class BaseConfig (Details)
|
# abstract class FunctionRegistry (Details)
|
||||||
> namespace: **VDM\Joomla\Abstraction**
|
> namespace: **VDM\Joomla\Abstraction**
|
||||||
> extends: **JoomlaRegistry**
|
> extends: **Registry**
|
||||||
|
|
||||||
```uml
|
```uml
|
||||||
@startuml
|
@startuml
|
||||||
abstract BaseConfig #Orange {
|
abstract FunctionRegistry #Orange {
|
||||||
+ __construct()
|
|
||||||
+ __set(string $key, mixed $value)
|
|
||||||
+ __get(string $key)
|
+ __get(string $key)
|
||||||
+ get(string $path, mixed $default = null) : mixed
|
+ get(string $path, mixed $default = null) : mixed
|
||||||
+ appendArray(string $path, mixed $value) : mixed
|
+ appendArray(string $path, mixed $value) : mixed
|
||||||
|
# isCallableMethod(string $method) : bool
|
||||||
}
|
}
|
||||||
|
|
||||||
note right of BaseConfig::__construct
|
note right of FunctionRegistry::__get
|
||||||
Constructor
|
|
||||||
|
|
||||||
since: 3.2.0
|
|
||||||
end note
|
|
||||||
|
|
||||||
note right of BaseConfig::__set
|
|
||||||
setting any config value
|
|
||||||
|
|
||||||
since: 3.2.0
|
|
||||||
end note
|
|
||||||
|
|
||||||
note right of BaseConfig::__get
|
|
||||||
getting any valid value
|
getting any valid value
|
||||||
|
|
||||||
since: 3.2.0
|
since: 3.2.0
|
||||||
end note
|
end note
|
||||||
|
|
||||||
note right of BaseConfig::get
|
note right of FunctionRegistry::get
|
||||||
Get a config value.
|
Get a config value.
|
||||||
|
|
||||||
since: 3.2.0
|
since: 3.2.0
|
||||||
return: mixed
|
return: mixed
|
||||||
end note
|
end note
|
||||||
|
|
||||||
note right of BaseConfig::appendArray
|
note right of FunctionRegistry::appendArray
|
||||||
Append value to a path in registry of an array
|
Append value to a path in registry of an array
|
||||||
|
|
||||||
since: 3.2.0
|
since: 3.2.0
|
||||||
return: mixed
|
return: mixed
|
||||||
end note
|
end note
|
||||||
|
|
||||||
|
note right of FunctionRegistry::isCallableMethod
|
||||||
|
Determines if a method is callable on this object, excluding certain methods.
|
||||||
|
This method checks if a method exists on this object and is callable, but excludes
|
||||||
|
certain methods to prevent unintended access or recursion. It helps to safely determine
|
||||||
|
if a dynamic getter method can be invoked without interfering with core methods.
|
||||||
|
|
||||||
|
since: 5.0.4
|
||||||
|
return: bool
|
||||||
|
end note
|
||||||
|
|
||||||
@enduml
|
@enduml
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -12,41 +12,17 @@
|
|||||||
namespace VDM\Joomla\Abstraction;
|
namespace VDM\Joomla\Abstraction;
|
||||||
|
|
||||||
|
|
||||||
use Joomla\Registry\Registry as JoomlaRegistry;
|
|
||||||
use VDM\Joomla\Utilities\String\ClassfunctionHelper;
|
use VDM\Joomla\Utilities\String\ClassfunctionHelper;
|
||||||
|
use VDM\Joomla\Abstraction\Registry;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Config
|
* A Dynamic Function Registry
|
||||||
*
|
*
|
||||||
* @since 3.2.0
|
* @since 5.0.4
|
||||||
*/
|
*/
|
||||||
abstract class BaseConfig extends JoomlaRegistry
|
abstract class FunctionRegistry extends Registry
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*
|
|
||||||
* @since 3.2.0
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
// Instantiate the internal data object.
|
|
||||||
$this->data = new \stdClass();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* setting any config value
|
|
||||||
*
|
|
||||||
* @param string $key The value's key/path name
|
|
||||||
* @param mixed $value Optional default value, returned if the internal value is null.
|
|
||||||
*
|
|
||||||
* @since 3.2.0
|
|
||||||
*/
|
|
||||||
public function __set($key, $value)
|
|
||||||
{
|
|
||||||
$this->set($key, $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getting any valid value
|
* getting any valid value
|
||||||
*
|
*
|
||||||
@ -76,7 +52,7 @@ abstract class BaseConfig extends JoomlaRegistry
|
|||||||
*
|
*
|
||||||
* @since 3.2.0
|
* @since 3.2.0
|
||||||
*/
|
*/
|
||||||
public function get($path, $default = null)
|
public function get(string $path, $default = null): mixed
|
||||||
{
|
{
|
||||||
// function name with no underscores
|
// function name with no underscores
|
||||||
$method = 'get' . ucfirst((string) ClassfunctionHelper::safe(str_replace('_', '', $path)));
|
$method = 'get' . ucfirst((string) ClassfunctionHelper::safe(str_replace('_', '', $path)));
|
||||||
@ -86,7 +62,8 @@ abstract class BaseConfig extends JoomlaRegistry
|
|||||||
{
|
{
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
elseif (method_exists($this, $method))
|
// Use the method if it's callable and not excluded
|
||||||
|
elseif ($this->isCallableMethod($method))
|
||||||
{
|
{
|
||||||
$value = $this->{$method}($default);
|
$value = $this->{$method}($default);
|
||||||
|
|
||||||
@ -104,19 +81,46 @@ abstract class BaseConfig extends JoomlaRegistry
|
|||||||
* @param string $path Parent registry Path (e.g. joomla.content.showauthor)
|
* @param string $path Parent registry Path (e.g. joomla.content.showauthor)
|
||||||
* @param mixed $value Value of entry
|
* @param mixed $value Value of entry
|
||||||
*
|
*
|
||||||
* @return mixed The value of the that has been set.
|
* @return mixed The values of the path that has been set.
|
||||||
*
|
*
|
||||||
* @since 3.2.0
|
* @since 3.2.0
|
||||||
*/
|
*/
|
||||||
public function appendArray(string $path, $value)
|
public function appendArray(string $path, $value)
|
||||||
{
|
{
|
||||||
// check if it does not exist
|
return $this->add($path, $value, true)->get($path);
|
||||||
if (!$this->exists($path))
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determines if a method is callable on this object, excluding certain methods.
|
||||||
|
*
|
||||||
|
* This method checks if a method exists on this object and is callable, but excludes
|
||||||
|
* certain methods to prevent unintended access or recursion. It helps to safely determine
|
||||||
|
* if a dynamic getter method can be invoked without interfering with core methods.
|
||||||
|
*
|
||||||
|
* @param string $method The method name to check.
|
||||||
|
*
|
||||||
|
* @return bool True if the method is callable and not excluded, false otherwise.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
protected function isCallableMethod(string $method): bool
|
||||||
{
|
{
|
||||||
$this->set($path, []);
|
// List of methods to exclude from dynamic access
|
||||||
|
$excludedMethods = [
|
||||||
|
'getActive',
|
||||||
|
'get',
|
||||||
|
'getSeparator',
|
||||||
|
'getIterator',
|
||||||
|
'getName',
|
||||||
|
'getActiveKeys'
|
||||||
|
];
|
||||||
|
|
||||||
|
// Check if the method exists and is not excluded
|
||||||
|
if (method_exists($this, $method) && !in_array($method, $excludedMethods, true))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->append($path, $value);
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,27 +1,3 @@
|
|||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*
|
|
||||||
* @since 3.2.0
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
// Instantiate the internal data object.
|
|
||||||
$this->data = new \stdClass();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* setting any config value
|
|
||||||
*
|
|
||||||
* @param string $key The value's key/path name
|
|
||||||
* @param mixed $value Optional default value, returned if the internal value is null.
|
|
||||||
*
|
|
||||||
* @since 3.2.0
|
|
||||||
*/
|
|
||||||
public function __set($key, $value)
|
|
||||||
{
|
|
||||||
$this->set($key, $value);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getting any valid value
|
* getting any valid value
|
||||||
*
|
*
|
||||||
@ -51,7 +27,7 @@
|
|||||||
*
|
*
|
||||||
* @since 3.2.0
|
* @since 3.2.0
|
||||||
*/
|
*/
|
||||||
public function get($path, $default = null)
|
public function get(string $path, $default = null): mixed
|
||||||
{
|
{
|
||||||
// function name with no underscores
|
// function name with no underscores
|
||||||
$method = 'get' . ucfirst((string) ClassfunctionHelper::safe(str_replace('_', '', $path)));
|
$method = 'get' . ucfirst((string) ClassfunctionHelper::safe(str_replace('_', '', $path)));
|
||||||
@ -61,7 +37,8 @@
|
|||||||
{
|
{
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
elseif (method_exists($this, $method))
|
// Use the method if it's callable and not excluded
|
||||||
|
elseif ($this->isCallableMethod($method))
|
||||||
{
|
{
|
||||||
$value = $this->{$method}($default);
|
$value = $this->{$method}($default);
|
||||||
|
|
||||||
@ -79,17 +56,44 @@
|
|||||||
* @param string $path Parent registry Path (e.g. joomla.content.showauthor)
|
* @param string $path Parent registry Path (e.g. joomla.content.showauthor)
|
||||||
* @param mixed $value Value of entry
|
* @param mixed $value Value of entry
|
||||||
*
|
*
|
||||||
* @return mixed The value of the that has been set.
|
* @return mixed The values of the path that has been set.
|
||||||
*
|
*
|
||||||
* @since 3.2.0
|
* @since 3.2.0
|
||||||
*/
|
*/
|
||||||
public function appendArray(string $path, $value)
|
public function appendArray(string $path, $value)
|
||||||
{
|
{
|
||||||
// check if it does not exist
|
return $this->add($path, $value, true)->get($path);
|
||||||
if (!$this->exists($path))
|
|
||||||
{
|
|
||||||
$this->set($path, []);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->append($path, $value);
|
/**
|
||||||
|
* Determines if a method is callable on this object, excluding certain methods.
|
||||||
|
*
|
||||||
|
* This method checks if a method exists on this object and is callable, but excludes
|
||||||
|
* certain methods to prevent unintended access or recursion. It helps to safely determine
|
||||||
|
* if a dynamic getter method can be invoked without interfering with core methods.
|
||||||
|
*
|
||||||
|
* @param string $method The method name to check.
|
||||||
|
*
|
||||||
|
* @return bool True if the method is callable and not excluded, false otherwise.
|
||||||
|
* @since 5.0.4
|
||||||
|
*/
|
||||||
|
protected function isCallableMethod(string $method): bool
|
||||||
|
{
|
||||||
|
// List of methods to exclude from dynamic access
|
||||||
|
$excludedMethods = [
|
||||||
|
'getActive',
|
||||||
|
'get',
|
||||||
|
'getSeparator',
|
||||||
|
'getIterator',
|
||||||
|
'getName',
|
||||||
|
'getActiveKeys'
|
||||||
|
];
|
||||||
|
|
||||||
|
// Check if the method exists and is not excluded
|
||||||
|
if (method_exists($this, $method) && !in_array($method, $excludedMethods, true))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
@ -1,13 +1,13 @@
|
|||||||
{
|
{
|
||||||
"add_head": "1",
|
"add_head": "0",
|
||||||
"add_licensing_template": "2",
|
"add_licensing_template": "2",
|
||||||
"extends": "-1",
|
"extends": "7e822c03-1b20-41d1-9427-f5b8d5836af7",
|
||||||
"guid": "ffbd4e1f-a342-4080-ab7d-1de3741bf319",
|
"guid": "ffbd4e1f-a342-4080-ab7d-1de3741bf319",
|
||||||
"implements": null,
|
"implements": null,
|
||||||
"load_selection": null,
|
"load_selection": null,
|
||||||
"name": "BaseConfig",
|
"name": "FunctionRegistry",
|
||||||
"power_version": "1.0.0",
|
"power_version": "1.0.0",
|
||||||
"system_name": "VDM.Abstraction.BaseConfig",
|
"system_name": "VDM.Abstraction.FunctionRegistry",
|
||||||
"type": "abstract class",
|
"type": "abstract class",
|
||||||
"use_selection": {
|
"use_selection": {
|
||||||
"use_selection0": {
|
"use_selection0": {
|
||||||
@ -16,10 +16,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"extendsinterfaces": null,
|
"extendsinterfaces": null,
|
||||||
"namespace": "[[[NamespacePrefix]]]\\Joomla\\Abstraction.BaseConfig",
|
"namespace": "[[[NamespacePrefix]]]\\Joomla\\Abstraction.FunctionRegistry",
|
||||||
"description": "Config\r\n\r\n@since 3.2.0",
|
"description": "A Dynamic Function Registry\r\n\r\n@since 5.0.4",
|
||||||
"extends_custom": "JoomlaRegistry",
|
|
||||||
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\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",
|
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\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\\Registry\\Registry as JoomlaRegistry;",
|
"head": "",
|
||||||
"composer": ""
|
"composer": ""
|
||||||
}
|
}
|
@ -88,7 +88,7 @@
|
|||||||
"guid": "0f3f7188-3e0d-4d1a-8dee-7f8026cb65a9"
|
"guid": "0f3f7188-3e0d-4d1a-8dee-7f8026cb65a9"
|
||||||
},
|
},
|
||||||
"11572d9b-e3d5-4b29-904c-9618d8f2bfd8": {
|
"11572d9b-e3d5-4b29-904c-9618d8f2bfd8": {
|
||||||
"name": "Count",
|
"name": "PathCount",
|
||||||
"type": "trait",
|
"type": "trait",
|
||||||
"namespace": "VDM\\Joomla\\Abstraction\\Registry\\Traits",
|
"namespace": "VDM\\Joomla\\Abstraction\\Registry\\Traits",
|
||||||
"code": "src\/11572d9b-e3d5-4b29-904c-9618d8f2bfd8\/code.php",
|
"code": "src\/11572d9b-e3d5-4b29-904c-9618d8f2bfd8\/code.php",
|
||||||
@ -770,7 +770,7 @@
|
|||||||
"guid": "7c1fb50f-8fb1-4627-8705-6fedf7182ca5"
|
"guid": "7c1fb50f-8fb1-4627-8705-6fedf7182ca5"
|
||||||
},
|
},
|
||||||
"7d494d91-ab60-43cd-aecf-d50e07f7f30e": {
|
"7d494d91-ab60-43cd-aecf-d50e07f7f30e": {
|
||||||
"name": "ToString",
|
"name": "PathToString",
|
||||||
"type": "trait",
|
"type": "trait",
|
||||||
"namespace": "VDM\\Joomla\\Abstraction\\Registry\\Traits",
|
"namespace": "VDM\\Joomla\\Abstraction\\Registry\\Traits",
|
||||||
"code": "src\/7d494d91-ab60-43cd-aecf-d50e07f7f30e\/code.php",
|
"code": "src\/7d494d91-ab60-43cd-aecf-d50e07f7f30e\/code.php",
|
||||||
@ -912,6 +912,17 @@
|
|||||||
"spk": "Super---95c02df3_fe0a_405b_b506_b7a5b8605b66---Power",
|
"spk": "Super---95c02df3_fe0a_405b_b506_b7a5b8605b66---Power",
|
||||||
"guid": "95c02df3-fe0a-405b-b506-b7a5b8605b66"
|
"guid": "95c02df3-fe0a-405b-b506-b7a5b8605b66"
|
||||||
},
|
},
|
||||||
|
"9769f3b2-17bf-4f20-b54b-3a4ebe572b36": {
|
||||||
|
"name": "ComponentConfig",
|
||||||
|
"type": "abstract class",
|
||||||
|
"namespace": "VDM\\Joomla\\Componentbuilder\\Abstraction",
|
||||||
|
"code": "src\/9769f3b2-17bf-4f20-b54b-3a4ebe572b36\/code.php",
|
||||||
|
"power": "src\/9769f3b2-17bf-4f20-b54b-3a4ebe572b36\/code.power",
|
||||||
|
"settings": "src\/9769f3b2-17bf-4f20-b54b-3a4ebe572b36\/settings.json",
|
||||||
|
"path": "src\/9769f3b2-17bf-4f20-b54b-3a4ebe572b36",
|
||||||
|
"spk": "Super---9769f3b2_17bf_4f20_b54b_3a4ebe572b36---Power",
|
||||||
|
"guid": "9769f3b2-17bf-4f20-b54b-3a4ebe572b36"
|
||||||
|
},
|
||||||
"993fe913-8e36-4800-a5f7-544aa728ee48": {
|
"993fe913-8e36-4800-a5f7-544aa728ee48": {
|
||||||
"name": "DateHelper",
|
"name": "DateHelper",
|
||||||
"type": "abstract class",
|
"type": "abstract class",
|
||||||
@ -1441,7 +1452,7 @@
|
|||||||
"guid": "ff8d5fdb-2d1f-4178-bd18-a43b8efd1068"
|
"guid": "ff8d5fdb-2d1f-4178-bd18-a43b8efd1068"
|
||||||
},
|
},
|
||||||
"ffbd4e1f-a342-4080-ab7d-1de3741bf319": {
|
"ffbd4e1f-a342-4080-ab7d-1de3741bf319": {
|
||||||
"name": "BaseConfig",
|
"name": "FunctionRegistry",
|
||||||
"type": "abstract class",
|
"type": "abstract class",
|
||||||
"namespace": "VDM\\Joomla\\Abstraction",
|
"namespace": "VDM\\Joomla\\Abstraction",
|
||||||
"code": "src\/ffbd4e1f-a342-4080-ab7d-1de3741bf319\/code.php",
|
"code": "src\/ffbd4e1f-a342-4080-ab7d-1de3741bf319\/code.php",
|
||||||
|
Loading…
Reference in New Issue
Block a user