Update 2024-07-20 22:42:12

This commit is contained in:
Robot 2024-07-20 22:42:08 +02:00
parent 087a84ab8b
commit f002f739bd
Signed by: Robot
GPG Key ID: 14DECD44E7E1BB95
31 changed files with 1865 additions and 284 deletions

View File

@ -89,6 +89,10 @@ This repository contains an index (see below) of all the approved powers within
- **abstract class MathHelper** | [Details](src/152c8793-8b75-4715-996a-257b9f65451c) | [Code](src/152c8793-8b75-4715-996a-257b9f65451c/code.php) | [Settings](src/152c8793-8b75-4715-996a-257b9f65451c/settings.json) | SPK: `Super---152c8793_8b75_4715_996a_257b9f65451c---Power`
- **abstract class ObjectHelper** | [Details](src/91004529-94a9-4590-b842-e7c6b624ecf5) | [Code](src/91004529-94a9-4590-b842-e7c6b624ecf5/code.php) | [Settings](src/91004529-94a9-4590-b842-e7c6b624ecf5/settings.json) | SPK: `Super---91004529_94a9_4590_b842_e7c6b624ecf5---Power`
- **abstract class StringHelper** | [Details](src/1f28cb53-60d9-4db1-b517-3c7dc6b429ef) | [Code](src/1f28cb53-60d9-4db1-b517-3c7dc6b429ef/code.php) | [Settings](src/1f28cb53-60d9-4db1-b517-3c7dc6b429ef/settings.json) | SPK: `Super---1f28cb53_60d9_4db1_b517_3c7dc6b429ef---Power`
- **Namespace**: [VDM\Joomla\Abstraction\Remote](#vdm-joomla-abstraction-remote)
- **abstract class Get** | [Details](src/728ee726-3f0f-4762-899d-f8c9430cee58) | [Code](src/728ee726-3f0f-4762-899d-f8c9430cee58/code.php) | [Settings](src/728ee726-3f0f-4762-899d-f8c9430cee58/settings.json) | SPK: `Super---728ee726_3f0f_4762_899d_f8c9430cee58---Power`
- **abstract class Set** | [Details](src/eb7d69c2-4ee9-4bd0-aacc-ab51a12be895) | [Code](src/eb7d69c2-4ee9-4bd0-aacc-ab51a12be895/code.php) | [Settings](src/eb7d69c2-4ee9-4bd0-aacc-ab51a12be895/settings.json) | SPK: `Super---eb7d69c2_4ee9_4bd0_aacc_ab51a12be895---Power`
- **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`
@ -102,10 +106,6 @@ This repository contains an index (see below) of all the approved powers within
- **class Insert** | [Details](src/a455d916-cfe4-41df-9245-bafb709aacdb) | [Code](src/a455d916-cfe4-41df-9245-bafb709aacdb/code.php) | [Settings](src/a455d916-cfe4-41df-9245-bafb709aacdb/settings.json) | SPK: `Super---a455d916_cfe4_41df_9245_bafb709aacdb---Power`
- **class Load** | [Details](src/008d111c-9d43-427c-8dd4-2653e8b74be8) | [Code](src/008d111c-9d43-427c-8dd4-2653e8b74be8/code.php) | [Settings](src/008d111c-9d43-427c-8dd4-2653e8b74be8/settings.json) | SPK: `Super---008d111c_9d43_427c_8dd4_2653e8b74be8---Power`
- **class Update** | [Details](src/8f83fb79-f92b-4f1f-952b-325f6c22d11e) | [Code](src/8f83fb79-f92b-4f1f-952b-325f6c22d11e/code.php) | [Settings](src/8f83fb79-f92b-4f1f-952b-325f6c22d11e/settings.json) | SPK: `Super---8f83fb79_f92b_4f1f_952b_325f6c22d11e---Power`
- **Namespace**: [VDM\Joomla\Data\Remote](#vdm-joomla-data-remote)
- **class Get** | [Details](src/728ee726-3f0f-4762-899d-f8c9430cee58) | [Code](src/728ee726-3f0f-4762-899d-f8c9430cee58/code.php) | [Settings](src/728ee726-3f0f-4762-899d-f8c9430cee58/settings.json) | SPK: `Super---728ee726_3f0f_4762_899d_f8c9430cee58---Power`
- **class Set** | [Details](src/eb7d69c2-4ee9-4bd0-aacc-ab51a12be895) | [Code](src/eb7d69c2-4ee9-4bd0-aacc-ab51a12be895/code.php) | [Settings](src/eb7d69c2-4ee9-4bd0-aacc-ab51a12be895/settings.json) | SPK: `Super---eb7d69c2_4ee9_4bd0_aacc_ab51a12be895---Power`
- **Namespace**: [VDM\Joomla\Interfaces\Data](#vdm-joomla-interfaces-data)
- **interface DeleteInterface** | [Details](src/d8f9ba53-c490-4e8b-8e9f-6757224e069c) | [Code](src/d8f9ba53-c490-4e8b-8e9f-6757224e069c/code.php) | [Settings](src/d8f9ba53-c490-4e8b-8e9f-6757224e069c/settings.json) | SPK: `Super---d8f9ba53_c490_4e8b_8e9f_6757224e069c---Power`
@ -114,14 +114,19 @@ This repository contains an index (see below) of all the approved powers within
- **interface ItemsInterface** | [Details](src/7212e4db-371f-4cfd-8122-32e9bb100d83) | [Code](src/7212e4db-371f-4cfd-8122-32e9bb100d83/code.php) | [Settings](src/7212e4db-371f-4cfd-8122-32e9bb100d83/settings.json) | SPK: `Super---7212e4db_371f_4cfd_8122_32e9bb100d83---Power`
- **interface LoadInterface** | [Details](src/c548640c-a461-4424-9ac5-8dfb5ed06d8d) | [Code](src/c548640c-a461-4424-9ac5-8dfb5ed06d8d/code.php) | [Settings](src/c548640c-a461-4424-9ac5-8dfb5ed06d8d/settings.json) | SPK: `Super---c548640c_a461_4424_9ac5_8dfb5ed06d8d---Power`
- **interface MultiSubformInterface** | [Details](src/bb30f709-53d2-446a-ab3d-300fe6de0bc8) | [Code](src/bb30f709-53d2-446a-ab3d-300fe6de0bc8/code.php) | [Settings](src/bb30f709-53d2-446a-ab3d-300fe6de0bc8/settings.json) | SPK: `Super---bb30f709_53d2_446a_ab3d_300fe6de0bc8---Power`
- **interface RemoteGetInterface** | [Details](src/51de80f2-2868-4c2c-8198-ef79349e9bd7) | [Code](src/51de80f2-2868-4c2c-8198-ef79349e9bd7/code.php) | [Settings](src/51de80f2-2868-4c2c-8198-ef79349e9bd7/settings.json) | SPK: `Super---51de80f2_2868_4c2c_8198_ef79349e9bd7---Power`
- **interface RemoteSetInterface** | [Details](src/e335dd61-c2f9-4536-8ed9-aec5edee0b26) | [Code](src/e335dd61-c2f9-4536-8ed9-aec5edee0b26/code.php) | [Settings](src/e335dd61-c2f9-4536-8ed9-aec5edee0b26/settings.json) | SPK: `Super---e335dd61_c2f9_4536_8ed9_aec5edee0b26---Power`
- **interface SubformInterface** | [Details](src/34959721-415b-4b5e-8002-3d1fc84b3b2b) | [Code](src/34959721-415b-4b5e-8002-3d1fc84b3b2b/code.php) | [Settings](src/34959721-415b-4b5e-8002-3d1fc84b3b2b/settings.json) | SPK: `Super---34959721_415b_4b5e_8002_3d1fc84b3b2b---Power`
- **interface UpdateInterface** | [Details](src/68a41264-64c0-441a-a3d8-8a5e557b1883) | [Code](src/68a41264-64c0-441a-a3d8-8a5e557b1883/code.php) | [Settings](src/68a41264-64c0-441a-a3d8-8a5e557b1883/settings.json) | SPK: `Super---68a41264_64c0_441a_a3d8_8a5e557b1883---Power`
- **Namespace**: [VDM\Joomla\Interfaces\Git](#vdm-joomla-interfaces-git)
- **interface ApiInterface** | [Details](src/17ed2fec-49d6-4731-92c3-f9cd78fb6273) | [Code](src/17ed2fec-49d6-4731-92c3-f9cd78fb6273/code.php) | [Settings](src/17ed2fec-49d6-4731-92c3-f9cd78fb6273/settings.json) | SPK: `Super---17ed2fec_49d6_4731_92c3_f9cd78fb6273---Power`
- **Namespace**: [VDM\Joomla\Interfaces\Readme](#vdm-joomla-interfaces-readme)
- **interface ItemInterface** | [Details](src/65a0f81a-14fc-4870-9382-b8d830b19937) | [Code](src/65a0f81a-14fc-4870-9382-b8d830b19937/code.php) | [Settings](src/65a0f81a-14fc-4870-9382-b8d830b19937/settings.json) | SPK: `Super---65a0f81a_14fc_4870_9382_b8d830b19937---Power`
- **interface MainInterface** | [Details](src/217416f6-24cf-41c0-b18e-11086111d447) | [Code](src/217416f6-24cf-41c0-b18e-11086111d447/code.php) | [Settings](src/217416f6-24cf-41c0-b18e-11086111d447/settings.json) | SPK: `Super---217416f6_24cf_41c0_b18e_11086111d447---Power`
- **Namespace**: [VDM\Joomla\Interfaces\Remote](#vdm-joomla-interfaces-remote)
- **interface GetInterface** | [Details](src/51de80f2-2868-4c2c-8198-ef79349e9bd7) | [Code](src/51de80f2-2868-4c2c-8198-ef79349e9bd7/code.php) | [Settings](src/51de80f2-2868-4c2c-8198-ef79349e9bd7/settings.json) | SPK: `Super---51de80f2_2868_4c2c_8198_ef79349e9bd7---Power`
- **interface SetInterface** | [Details](src/e335dd61-c2f9-4536-8ed9-aec5edee0b26) | [Code](src/e335dd61-c2f9-4536-8ed9-aec5edee0b26/code.php) | [Settings](src/e335dd61-c2f9-4536-8ed9-aec5edee0b26/settings.json) | SPK: `Super---e335dd61_c2f9_4536_8ed9_aec5edee0b26---Power`
- **Namespace**: [VDM\Joomla\Utilities\Component](#vdm-joomla-utilities-component)
- **abstract class Helper** | [Details](src/640b5352-fb09-425f-a26e-cd44eda03f15) | [Code](src/640b5352-fb09-425f-a26e-cd44eda03f15/code.php) | [Settings](src/640b5352-fb09-425f-a26e-cd44eda03f15/settings.json) | SPK: `Super---640b5352_fb09_425f_a26e_cd44eda03f15---Power`
@ -142,6 +147,9 @@ This repository contains an index (see below) of all the approved powers within
- **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 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\Interfaces\Git\Repository](#vdm-joomla-interfaces-git-repository)
- **interface ContentsInterface** | [Details](src/d1de5d5b-bf29-4031-8094-76c4f6c75900) | [Code](src/d1de5d5b-bf29-4031-8094-76c4f6c75900/code.php) | [Settings](src/d1de5d5b-bf29-4031-8094-76c4f6c75900/settings.json) | SPK: `Super---d1de5d5b_bf29_4031_8094_76c4f6c75900---Power`
> remember to replace the `---` with `___` in the SPK to activate that Power in your code
---

View File

@ -0,0 +1,73 @@
```
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# interface ApiInterface (Details)
> namespace: **VDM\Joomla\Interfaces\Git**
```uml
@startuml
interface ApiInterface #Lavender {
+ load_(?string $url = null, ?string $token = null, ...) : void
+ reset_() : void
+ api() : string
}
note right of ApiInterface::load_
Load/Reload API.
since: 3.2.0
return: void
arguments:
?string $url = null
?string $token = null
bool $backup = true
end note
note right of ApiInterface::reset_
Reset to previous toke, url it set
since: 3.2.0
return: void
end note
note right of ApiInterface::api
Get the API url
since: 3.2.0
return: string
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---17ed2fec_49d6_4731_92c3_f9cd78fb6273---Power
```
> remember to replace the `---` with `___` to activate this Power in your code
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)

View File

@ -0,0 +1,50 @@
<?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\Interfaces\Git;
/**
* The Git Api Interface
*
* @since 3.2.0
*/
interface ApiInterface
{
/**
* Load/Reload API.
*
* @param string|null $url The url.
* @param token|null $token The token.
* @param bool $backup The backup swapping switch.
*
* @return void
* @since 3.2.0
**/
public function load_(?string $url = null, ?string $token = null, bool $backup = true): void;
/**
* Reset to previous toke, url it set
*
* @return void
* @since 3.2.0
**/
public function reset_(): void;
/**
* Get the API url
*
* @return string
* @since 3.2.0
**/
public function api();
}

View File

@ -0,0 +1,27 @@
/**
* Load/Reload API.
*
* @param string|null $url The url.
* @param token|null $token The token.
* @param bool $backup The backup swapping switch.
*
* @return void
* @since 3.2.0
**/
public function load_(?string $url = null, ?string $token = null, bool $backup = true): void;
/**
* Reset to previous toke, url it set
*
* @return void
* @since 3.2.0
**/
public function reset_(): void;
/**
* Get the API url
*
* @return string
* @since 3.2.0
**/
public function api();

View File

@ -0,0 +1,19 @@
{
"add_head": "0",
"add_licensing_template": "2",
"extends": "",
"guid": "17ed2fec-49d6-4731-92c3-f9cd78fb6273",
"implements": null,
"load_selection": null,
"name": "ApiInterface",
"power_version": "1.0.0",
"system_name": "VDM.Git.ApiInterface",
"type": "interface",
"use_selection": null,
"extendsinterfaces": null,
"namespace": "[[[NamespacePrefix]]]\\Joomla\\Interfaces.Git.ApiInterface",
"description": "The Git Api Interface\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": "",
"composer": ""
}

View File

@ -6,12 +6,12 @@
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# interface RemoteGetInterface (Details)
> namespace: **VDM\Joomla\Interfaces\Data**
# interface GetInterface (Details)
> namespace: **VDM\Joomla\Interfaces\Remote**
```uml
@startuml
interface RemoteGetInterface #Lavender {
interface GetInterface #Lavender {
+ table(string $table) : self
+ init() : bool
+ reset(array $items) : bool
@ -19,35 +19,35 @@ interface RemoteGetInterface #Lavender {
+ getTable() : string
}
note right of RemoteGetInterface::table
note right of GetInterface::table
Set the current active table
since: 3.2.2
return: self
end note
note right of RemoteGetInterface::init
note right of GetInterface::init
Init all items not found in database
since: 3.2.0
return: bool
end note
note right of RemoteGetInterface::reset
note right of GetInterface::reset
Reset the items
since: 3.2.0
return: bool
end note
note right of RemoteGetInterface::item
note right of GetInterface::item
Load an item
since: 3.2.2
return: bool
end note
note right of RemoteGetInterface::getTable
note right of GetInterface::getTable
Get the current active table
since: 3.2.2

View File

@ -9,7 +9,7 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Interfaces\Data;
namespace VDM\Joomla\Interfaces\Remote;
/**
@ -17,7 +17,7 @@ namespace VDM\Joomla\Interfaces\Data;
*
* @since 3.2.2
*/
interface RemoteGetInterface
interface GetInterface
{
/**
* Set the current active table

View File

@ -5,13 +5,13 @@
"guid": "51de80f2-2868-4c2c-8198-ef79349e9bd7",
"implements": null,
"load_selection": null,
"name": "RemoteGetInterface",
"name": "GetInterface",
"power_version": "1.0.0",
"system_name": "VDM.Interfaces.RemoteGetInterface",
"system_name": "VDM.Interfaces.Remote.GetInterface",
"type": "interface",
"use_selection": null,
"extendsinterfaces": null,
"namespace": "[[[NamespacePrefix]]]\\Joomla\\Interfaces.Data.RemoteGetInterface",
"namespace": "[[[NamespacePrefix]]]\\Joomla\\Interfaces.Remote.GetInterface",
"description": "Load data based on global unique ids from remote system\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",
"head": "",

View File

@ -14,7 +14,7 @@
abstract SchemaChecker #Orange {
# ?Table $table
# ?Schema $schema
# CMSApplication $app
# $app
+ __construct(?Schema $schema = null, ?Table $table = null, ...)
+ run() : void
# initializeInstances() : void
@ -34,7 +34,7 @@ note right of SchemaChecker::__construct
arguments:
?Schema $schema = null
?Table $table = null
?CMSApplication $app = null
$app = null
end note
note left of SchemaChecker::run

View File

@ -12,8 +12,7 @@
namespace VDM\Joomla\Abstraction;
use Joomla\CMS\Factory;
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Factory;
use VDM\Joomla\Interfaces\SchemaInterface as Schema;
use VDM\Joomla\Interfaces\Tableinterface as Table;
use VDM\Joomla\Utilities\ClassHelper;
@ -46,22 +45,21 @@ abstract class SchemaChecker implements SchemaCheckerInterface
/**
* Application object.
*
* @var CMSApplication
* @since 3.2.2
**/
protected CMSApplication $app;
protected $app;
/**
* Constructor.
*
* @param Schema|null $schema The Schema Class.
* @param Table|null $table The Table Class.
* @param CMSApplication|null $app The app object.
* @param Schema|null $schema The Schema Class.
* @param Table|null $table The Table Class.
* @param $app The app object.
*
* @throws \Exception
* @since 3.2.2
*/
public function __construct(?Schema $schema = null, ?Table $table = null, ?CMSApplication $app = null)
public function __construct(?Schema $schema = null, ?Table $table = null, $app = null)
{
$this->schema = $schema;
$this->table = $table;

View File

@ -17,22 +17,21 @@
/**
* Application object.
*
* @var CMSApplication
* @since 3.2.2
**/
protected CMSApplication $app;
protected $app;
/**
* Constructor.
*
* @param Schema|null $schema The Schema Class.
* @param Table|null $table The Table Class.
* @param CMSApplication|null $app The app object.
* @param Schema|null $schema The Schema Class.
* @param Table|null $table The Table Class.
* @param $app The app object.
*
* @throws \Exception
* @since 3.2.2
*/
public function __construct(?Schema $schema = null, ?Table $table = null, ?CMSApplication $app = null)
public function __construct(?Schema $schema = null, ?Table $table = null, $app = null)
{
$this->schema = $schema;
$this->table = $table;

View File

@ -29,6 +29,6 @@
"namespace": "[[[NamespacePrefix]]]\\Joomla\\Abstraction.SchemaChecker",
"description": "Schema Checker\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",
"head": "use Joomla\\CMS\\Factory;\r\nuse Joomla\\CMS\\Application\\CMSApplication;",
"head": "use Joomla\\CMS\\Factory;",
"composer": ""
}

View File

@ -6,12 +6,12 @@
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# class Get (Details)
> namespace: **VDM\Joomla\Data\Remote**
# abstract class Get (Details)
> namespace: **VDM\Joomla\Abstraction\Remote**
```uml
@startuml
class Get #Gold {
abstract Get #Orange {
# Grep $grep
# Item $item
# string $table

View File

@ -9,12 +9,12 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Data\Remote;
namespace VDM\Joomla\Abstraction\Remote;
use VDM\Joomla\Interfaces\GrepInterface as Grep;
use VDM\Joomla\Interfaces\Data\ItemInterface as Item;
use VDM\Joomla\Interfaces\Data\RemoteGetInterface;
use VDM\Joomla\Interfaces\Remote\GetInterface;
/**
@ -22,7 +22,7 @@ use VDM\Joomla\Interfaces\Data\RemoteGetInterface;
*
* @since 3.2.0
*/
class Get implements RemoteGetInterface
abstract class Get implements GetInterface
{
/**
* The Grep Class.
@ -94,7 +94,7 @@ class Get implements RemoteGetInterface
{
foreach($items as $guid)
{
if ($this->item->table($this->getTable())->value($guid) !== null &&
if ($this->item->table($this->getTable())->value($guid) === null &&
($item = $this->grep->get($guid, ['remote'])) !== null)
{
$this->item->set($item);

View File

@ -68,7 +68,7 @@
{
foreach($items as $guid)
{
if ($this->item->table($this->getTable())->value($guid) !== null &&
if ($this->item->table($this->getTable())->value($guid) === null &&
($item = $this->grep->get($guid, ['remote'])) !== null)
{
$this->item->set($item);

View File

@ -9,8 +9,8 @@
"load_selection": null,
"name": "Get",
"power_version": "1.0.0",
"system_name": "VDM.Data.Remote.Get",
"type": "class",
"system_name": "VDM.Remote.Get",
"type": "abstract class",
"use_selection": {
"use_selection0": {
"use": "c182506a-ab84-439c-b962-1e606b58d545",
@ -22,7 +22,7 @@
}
},
"extendsinterfaces": null,
"namespace": "[[[NamespacePrefix]]]\\Joomla\\Data.Remote.Get",
"namespace": "[[[NamespacePrefix]]]\\Joomla\\Abstraction.Remote.Get",
"description": "Get data based on global unique ids from remote system\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": "",

View File

@ -45,8 +45,8 @@ final class Load extends Model implements ModelInterface
$table = $this->getTable();
}
// check if this is a valid table
if (($store = $this->table->get($table, $field, 'store')) !== null)
// check if this is a valid table (don't touch null)
if ($value !== null && ($store = $this->table->get($table, $field, 'store')) !== null)
{
// open the value based on the store method
switch($store)

View File

@ -17,8 +17,8 @@
$table = $this->getTable();
}
// check if this is a valid table
if (($store = $this->table->get($table, $field, 'store')) !== null)
// check if this is a valid table (don't touch null)
if ($value !== null && ($store = $this->table->get($table, $field, 'store')) !== null)
{
// open the value based on the store method
switch($store)

View File

@ -0,0 +1,190 @@
```
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# interface ContentsInterface (Details)
> namespace: **VDM\Joomla\Interfaces\Git\Repository**
> extends: **ApiInterface**
```uml
@startuml
interface ContentsInterface #Lavender {
+ get(string $owner, string $repo, ...) : mixed
+ metadata(string $owner, string $repo, ...) : null|array|object
+ create(string $owner, string $repo, ...) : ?object
+ root(string $owner, string $repo, ...) : ?array
+ update(string $owner, string $repo, ...) : ?object
+ delete(string $owner, string $repo, ...) : ?object
+ editor(string $owner, string $repo, ...) : ?string
+ blob(string $owner, string $repo, ...) : ?object
}
note right of ContentsInterface::get
Get a file from a repository.
Default the repository's default branch (usually master).
since: 3.2.0
return: mixed
arguments:
string $owner
string $repo
string $filepath
?string $ref = null
end note
note left of ContentsInterface::metadata
Get the metadata and contents (if a file) of an entry in a repository,
or a list of entries if a directory.
Default the repository's default branch (usually master).
since: 3.2.0
return: null|array|object
arguments:
string $owner
string $repo
string $filepath
?string $ref = null
end note
note right of ContentsInterface::create
Create a file in a repository.
since: 3.2.0
return: ?object
arguments:
string $owner
string $repo
string $filepath
string $content
string $message
string $branch = 'master'
?string $authorName = null
?string $authorEmail = null
?string $committerName = null
?string $committerEmail = null
?string $newBranch = null
?string $authorDate = null
?string $committerDate = null
?bool $signoff = null
end note
note left of ContentsInterface::root
Get the metadata of all the entries of the root directory.
since: 3.2.0
return: ?array
arguments:
string $owner
string $repo
?string $ref = null
end note
note right of ContentsInterface::update
Update a file in a repository.
since: 3.2.0
return: ?object
arguments:
string $owner
string $repo
string $filepath
string $content
string $message
string $sha
string $branch = 'master'
?string $authorName = null
?string $authorEmail = null
?string $committerName = null
?string $committerEmail = null
?string $authorDate = null
?string $committerDate = null
?string $fromPath = null
?string $newBranch = null
?bool $signoff = null
end note
note left of ContentsInterface::delete
Delete a file in a repository.
since: 3.2.0
return: ?object
arguments:
string $owner
string $repo
string $filepath
string $message
string $sha
?string $branch = null
?string $authorName = null
?string $authorEmail = null
?string $committerName = null
?string $committerEmail = null
?string $authorDate = null
?string $committerDate = null
?string $newBranch = null
?bool $signoff = null
end note
note right of ContentsInterface::editor
Get the EditorConfig definitions of a file in a repository.
since: 3.2.0
return: ?string
arguments:
string $owner
string $repo
string $filepath
string $ref = null
end note
note left of ContentsInterface::blob
Get the blob of a repository.
since: 3.2.0
return: ?object
arguments:
string $owner
string $repo
string $sha
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---d1de5d5b_bf29_4031_8094_76c4f6c75900---Power
```
> remember to replace the `---` with `___` to activate this Power in your code
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)

View File

@ -0,0 +1,209 @@
<?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\Interfaces\Git\Repository;
use VDM\Joomla\Interfaces\Git\ApiInterface;
/**
* The Git Repository Contents Interface
*
* @since 3.2.2
*/
interface ContentsInterface extends ApiInterface
{
/**
* Get a file from a repository.
*
* @param string $owner The owner name.
* @param string $repo The repository name.
* @param string $filepath The file path.
* @param string|null $ref Optional. The name of the commit/branch/tag.
* Default the repository's default branch (usually master).
*
* @return mixed
* @since 3.2.0
**/
public function get(string $owner, string $repo, string $filepath, ?string $ref = null);
/**
* Get the metadata and contents (if a file) of an entry in a repository,
* or a list of entries if a directory.
*
* @param string $owner The owner name.
* @param string $repo The repository name.
* @param string $filepath The file or directory path.
* @param string|null $ref Optional. The name of the commit/branch/tag.
* Default the repository's default branch (usually master).
*
* @return null|array|object
* @since 3.2.0
**/
public function metadata(string $owner, string $repo, string $filepath, ?string $ref = null): null|array|object;
/**
* Create a file in a repository.
*
* @param string $owner The owner name.
* @param string $repo The repository name.
* @param string $filepath The file path.
* @param string $content The file content.
* @param string $message The commit message.
* @param string $branch The branch name. Defaults to the repository's default branch.
* @param string|null $authorName The author's name.
* @param string|null $authorEmail The author's email.
* @param string|null $committerName The committer's name.
* @param string|null $committerEmail The committer's email.
* @param string|null $newBranch Whether to create a new branch. Defaults to null.
* @param string|null $authorDate The author's date.
* @param string|null $committerDate The committer's date.
* @param bool|null $signoff Add a Signed-off-by trailer. Defaults to null.
*
* @return object|null
* @since 3.2.0
**/
public function create(
string $owner,
string $repo,
string $filepath,
string $content,
string $message,
string $branch = 'master',
?string $authorName = null,
?string $authorEmail = null,
?string $committerName = null,
?string $committerEmail = null,
?string $newBranch = null,
?string $authorDate = null,
?string $committerDate = null,
?bool $signoff = null
): ?object;
/**
* Get the metadata of all the entries of the root directory.
*
* @param string $owner The owner name.
* @param string $repo The repository name.
* @param string|null $ref The name of the commit/branch/tag. Default the repository's default branch (usually master).
*
* @return array|null
* @since 3.2.0
**/
public function root(string $owner, string $repo, ?string $ref = null): ?array;
/**
* Update a file in a repository.
*
* @param string $owner The owner name.
* @param string $repo The repository name.
* @param string $filepath The file path.
* @param string $content The file content.
* @param string $message The commit message.
* @param string $sha The blob SHA of the file.
* @param string $branch The branch name. Defaults to the repository's default branch.
* @param string|null $authorName The author name. Defaults to the authenticated user.
* @param string|null $authorEmail The author email. Defaults to the authenticated user.
* @param string|null $committerName The committer name. Defaults to the authenticated user.
* @param string|null $committerEmail The committer email. Defaults to the authenticated user.
* @param string|null $authorDate The author date.
* @param string|null $committerDate The committer date.
* @param string|null $fromPath The original file path to move/rename.
* @param string|null $newBranch The new branch to create from the specified branch.
* @param bool|null $signoff Add a Signed-off-by trailer.
*
* @return object|null
* @since 3.2.0
**/
public function update(
string $owner,
string $repo,
string $filepath,
string $content,
string $message,
string $sha,
string $branch = 'master',
?string $authorName = null,
?string $authorEmail = null,
?string $committerName = null,
?string $committerEmail = null,
?string $authorDate = null,
?string $committerDate = null,
?string $fromPath = null,
?string $newBranch = null,
?bool $signoff = null
): ?object;
/**
* Delete a file in a repository.
*
* @param string $owner The owner name.
* @param string $repo The repository name.
* @param string $filepath The file path.
* @param string $message The commit message.
* @param string $sha The blob SHA of the file.
* @param string|null $branch The branch name (optional).
* @param string|null $authorName The author name (optional).
* @param string|null $authorEmail The author email (optional).
* @param string|null $committerName The committer name (optional).
* @param string|null $committerEmail The committer email (optional).
* @param string|null $authorDate The author date (optional).
* @param string|null $committerDate The committer date (optional).
* @param string|null $newBranch The new branch name (optional).
* @param bool|null $signoff Add a Signed-off-by trailer (optional).
*
* @return object|null
* @since 3.2.0
**/
public function delete(
string $owner,
string $repo,
string $filepath,
string $message,
string $sha,
?string $branch = null,
?string $authorName = null,
?string $authorEmail = null,
?string $committerName = null,
?string $committerEmail = null,
?string $authorDate = null,
?string $committerDate = null,
?string $newBranch = null,
?bool $signoff = null
): ?object;
/**
* Get the EditorConfig definitions of a file in a repository.
*
* @param string $owner The owner name.
* @param string $repo The repository name.
* @param string $filepath The file path.
* @param string|null $ref The name of the commit/branch/tag.
*
* @return string|null
* @since 3.2.0
**/
public function editor(string $owner, string $repo, string $filepath, string $ref = null): ?string;
/**
* Get the blob of a repository.
*
* @param string $owner The owner name.
* @param string $repo The repository name.
* @param string $sha The SHA hash of the blob.
*
* @return object|null
* @since 3.2.0
**/
public function blob(string $owner, string $repo, string $sha): ?object;
}

View File

@ -0,0 +1,183 @@
/**
* Get a file from a repository.
*
* @param string $owner The owner name.
* @param string $repo The repository name.
* @param string $filepath The file path.
* @param string|null $ref Optional. The name of the commit/branch/tag.
* Default the repository's default branch (usually master).
*
* @return mixed
* @since 3.2.0
**/
public function get(string $owner, string $repo, string $filepath, ?string $ref = null);
/**
* Get the metadata and contents (if a file) of an entry in a repository,
* or a list of entries if a directory.
*
* @param string $owner The owner name.
* @param string $repo The repository name.
* @param string $filepath The file or directory path.
* @param string|null $ref Optional. The name of the commit/branch/tag.
* Default the repository's default branch (usually master).
*
* @return null|array|object
* @since 3.2.0
**/
public function metadata(string $owner, string $repo, string $filepath, ?string $ref = null): null|array|object;
/**
* Create a file in a repository.
*
* @param string $owner The owner name.
* @param string $repo The repository name.
* @param string $filepath The file path.
* @param string $content The file content.
* @param string $message The commit message.
* @param string $branch The branch name. Defaults to the repository's default branch.
* @param string|null $authorName The author's name.
* @param string|null $authorEmail The author's email.
* @param string|null $committerName The committer's name.
* @param string|null $committerEmail The committer's email.
* @param string|null $newBranch Whether to create a new branch. Defaults to null.
* @param string|null $authorDate The author's date.
* @param string|null $committerDate The committer's date.
* @param bool|null $signoff Add a Signed-off-by trailer. Defaults to null.
*
* @return object|null
* @since 3.2.0
**/
public function create(
string $owner,
string $repo,
string $filepath,
string $content,
string $message,
string $branch = 'master',
?string $authorName = null,
?string $authorEmail = null,
?string $committerName = null,
?string $committerEmail = null,
?string $newBranch = null,
?string $authorDate = null,
?string $committerDate = null,
?bool $signoff = null
): ?object;
/**
* Get the metadata of all the entries of the root directory.
*
* @param string $owner The owner name.
* @param string $repo The repository name.
* @param string|null $ref The name of the commit/branch/tag. Default the repository's default branch (usually master).
*
* @return array|null
* @since 3.2.0
**/
public function root(string $owner, string $repo, ?string $ref = null): ?array;
/**
* Update a file in a repository.
*
* @param string $owner The owner name.
* @param string $repo The repository name.
* @param string $filepath The file path.
* @param string $content The file content.
* @param string $message The commit message.
* @param string $sha The blob SHA of the file.
* @param string $branch The branch name. Defaults to the repository's default branch.
* @param string|null $authorName The author name. Defaults to the authenticated user.
* @param string|null $authorEmail The author email. Defaults to the authenticated user.
* @param string|null $committerName The committer name. Defaults to the authenticated user.
* @param string|null $committerEmail The committer email. Defaults to the authenticated user.
* @param string|null $authorDate The author date.
* @param string|null $committerDate The committer date.
* @param string|null $fromPath The original file path to move/rename.
* @param string|null $newBranch The new branch to create from the specified branch.
* @param bool|null $signoff Add a Signed-off-by trailer.
*
* @return object|null
* @since 3.2.0
**/
public function update(
string $owner,
string $repo,
string $filepath,
string $content,
string $message,
string $sha,
string $branch = 'master',
?string $authorName = null,
?string $authorEmail = null,
?string $committerName = null,
?string $committerEmail = null,
?string $authorDate = null,
?string $committerDate = null,
?string $fromPath = null,
?string $newBranch = null,
?bool $signoff = null
): ?object;
/**
* Delete a file in a repository.
*
* @param string $owner The owner name.
* @param string $repo The repository name.
* @param string $filepath The file path.
* @param string $message The commit message.
* @param string $sha The blob SHA of the file.
* @param string|null $branch The branch name (optional).
* @param string|null $authorName The author name (optional).
* @param string|null $authorEmail The author email (optional).
* @param string|null $committerName The committer name (optional).
* @param string|null $committerEmail The committer email (optional).
* @param string|null $authorDate The author date (optional).
* @param string|null $committerDate The committer date (optional).
* @param string|null $newBranch The new branch name (optional).
* @param bool|null $signoff Add a Signed-off-by trailer (optional).
*
* @return object|null
* @since 3.2.0
**/
public function delete(
string $owner,
string $repo,
string $filepath,
string $message,
string $sha,
?string $branch = null,
?string $authorName = null,
?string $authorEmail = null,
?string $committerName = null,
?string $committerEmail = null,
?string $authorDate = null,
?string $committerDate = null,
?string $newBranch = null,
?bool $signoff = null
): ?object;
/**
* Get the EditorConfig definitions of a file in a repository.
*
* @param string $owner The owner name.
* @param string $repo The repository name.
* @param string $filepath The file path.
* @param string|null $ref The name of the commit/branch/tag.
*
* @return string|null
* @since 3.2.0
**/
public function editor(string $owner, string $repo, string $filepath, string $ref = null): ?string;
/**
* Get the blob of a repository.
*
* @param string $owner The owner name.
* @param string $repo The repository name.
* @param string $sha The SHA hash of the blob.
*
* @return object|null
* @since 3.2.0
**/
public function blob(string $owner, string $repo, string $sha): ?object;

View File

@ -0,0 +1,21 @@
{
"add_head": "0",
"add_licensing_template": "2",
"extends": "",
"guid": "d1de5d5b-bf29-4031-8094-76c4f6c75900",
"implements": null,
"load_selection": null,
"name": "ContentsInterface",
"power_version": "1.0.0",
"system_name": "VDM.Interfaces.Repository.ContentsInterface",
"type": "interface",
"use_selection": null,
"extendsinterfaces": [
"17ed2fec-49d6-4731-92c3-f9cd78fb6273"
],
"namespace": "[[[NamespacePrefix]]]\\Joomla\\Interfaces.Git.Repository.ContentsInterface",
"description": "The Git Repository Contents Interface\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",
"head": "",
"composer": ""
}

View File

@ -6,45 +6,53 @@
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# interface RemoteSetInterface (Details)
> namespace: **VDM\Joomla\Interfaces\Data**
# interface SetInterface (Details)
> namespace: **VDM\Joomla\Interfaces\Remote**
```uml
@startuml
interface RemoteSetInterface #Lavender {
interface SetInterface #Lavender {
+ table(string $table) : self
+ area(string $area) : self
+ setSettingsPath(string $settingsPath) : self
+ setIndexSettingsPath(string $settingsIndexPath) : self
+ items(array $guids) : bool
+ getTable() : string
}
note right of RemoteSetInterface::table
note right of SetInterface::table
Set the current active table
since: 3.2.2
return: self
end note
note right of RemoteSetInterface::setSettingsPath
note right of SetInterface::area
Set the current active area
since: 3.2.2
return: self
end note
note right of SetInterface::setSettingsPath
Set the settings path
since: 3.2.2
return: self
end note
note right of RemoteSetInterface::items
note right of SetInterface::setIndexSettingsPath
Set the index settings path
since: 3.2.2
return: self
end note
note right of SetInterface::items
Save items remotely
since: 3.2.2
return: bool
end note
note right of RemoteSetInterface::getTable
Get the current active table
since: 3.2.2
return: string
end note
@enduml
```

View File

@ -9,7 +9,7 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Interfaces\Data;
namespace VDM\Joomla\Interfaces\Remote;
/**
@ -17,7 +17,7 @@ namespace VDM\Joomla\Interfaces\Data;
*
* @since 3.2.2
*/
interface RemoteSetInterface
interface SetInterface
{
/**
* Set the current active table
@ -29,6 +29,16 @@ interface RemoteSetInterface
*/
public function table(string $table): self;
/**
* Set the current active area
*
* @param string $area The area that should be active
*
* @return self
* @since 3.2.2
*/
public function area(string $area): self;
/**
* Set the settings path
*
@ -39,6 +49,16 @@ interface RemoteSetInterface
*/
public function setSettingsPath(string $settingsPath): self;
/**
* Set the index settings path
*
* @param string $settingsIndexPath The repository index settings path
*
* @return self
* @since 3.2.2
*/
public function setIndexSettingsPath(string $settingsIndexPath): self;
/**
* Save items remotely
*
@ -48,14 +68,6 @@ interface RemoteSetInterface
* @throws \Exception
* @since 3.2.2
*/
public function items(array $guids): bool;
/**
* Get the current active table
*
* @return string
* @since 3.2.2
*/
public function getTable(): string;
public function items(array $guids): bool;
}

View File

@ -8,6 +8,16 @@
*/
public function table(string $table): self;
/**
* Set the current active area
*
* @param string $area The area that should be active
*
* @return self
* @since 3.2.2
*/
public function area(string $area): self;
/**
* Set the settings path
*
@ -18,6 +28,16 @@
*/
public function setSettingsPath(string $settingsPath): self;
/**
* Set the index settings path
*
* @param string $settingsIndexPath The repository index settings path
*
* @return self
* @since 3.2.2
*/
public function setIndexSettingsPath(string $settingsIndexPath): self;
/**
* Save items remotely
*
@ -27,12 +47,4 @@
* @throws \Exception
* @since 3.2.2
*/
public function items(array $guids): bool;
/**
* Get the current active table
*
* @return string
* @since 3.2.2
*/
public function getTable(): string;
public function items(array $guids): bool;

View File

@ -5,13 +5,13 @@
"guid": "e335dd61-c2f9-4536-8ed9-aec5edee0b26",
"implements": null,
"load_selection": null,
"name": "RemoteSetInterface",
"name": "SetInterface",
"power_version": "1.0.0",
"system_name": "VDM.Interfaces.RemoteSetInterface",
"system_name": "VDM.Interfaces.Remote.SetInterface",
"type": "interface",
"use_selection": null,
"extendsinterfaces": null,
"namespace": "[[[NamespacePrefix]]]\\Joomla\\Interfaces.Data.RemoteSetInterface",
"namespace": "[[[NamespacePrefix]]]\\Joomla\\Interfaces.Remote.SetInterface",
"description": "Set data based on global unique ids to remote system\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",
"head": "",

View File

@ -6,12 +6,12 @@
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# class Set (Details)
> namespace: **VDM\Joomla\Data\Remote**
# abstract class Set (Details)
> namespace: **VDM\Joomla\Abstraction\Remote**
```uml
@startuml
class Set #Gold {
abstract Set #Orange {
# Grep $grep
# Items $items
# ItemReadme $itemReadme
@ -19,26 +19,40 @@ class Set #Gold {
# Git $git
+ array $repos
# string $table
# string $area
# array $map
# array $settings
+ __construct(array $repos, Grep $grep, ...)
+ table(string $table) : self
+ area(string $area) : self
+ setSettingsPath(string $settingsPath) : self
+ setIndexSettingsPath(string $settingsIndexPath) : self
+ items(array $guids) : bool
+ getTable() : string
# {abstract} updateItem(object $item, object $existing, ...) : bool
# {abstract} createItem(object $item, object $repo) : void
# {abstract} updateItemReadme(object $item, object $existing, ...) : void
# {abstract} createItemReadme(object $item, object $repo) : void
# {abstract} saveRepoMainSettings(array $repo) : void
# getTable() : string
# getArea() : string
# saveRepoMainSettings(array $repoBucket) : void
# isInvalidIndexRepo(mixed $repo, mixed $settings) : bool
# mergeIndexSettings(string $repoGuid, array $settings) : array
# updateIndexMainFile(object $repo, string $path, ...) : void
# getLocalItems(array $guids) : ?array
# save(object $item) : void
# fetchLocalItems(array $guids) : ?array
# mapItems(array $items) : array
# mapItem(object $item) : object
# save(object $item) : void
# getIndexItem(object $item) : ?array
# canWrite() : bool
# areObjectsEqual(object $obj1, object $obj2) : bool
# getSettingsPath() : string
# getIndexSettingsPath() : string
# index_map_IndexName(object $item) : ?string
# index_map_IndexSettingsPath(object $item) : string
# index_map_IndexPath(object $item) : string
# index_map_IndexKey(object $item) : string
# index_map_IndexGUID(object $item) : string
}
note right of Set::__construct
@ -55,6 +69,7 @@ note right of Set::__construct
Git $git
?string $table = null
?string $settingsPath = null
?string $settingsIndexPath = null
end note
note left of Set::table
@ -64,13 +79,27 @@ note left of Set::table
return: self
end note
note right of Set::setSettingsPath
note right of Set::area
Set the current active area
since: 3.2.2
return: self
end note
note left of Set::setSettingsPath
Set the settings path
since: 3.2.2
return: self
end note
note right of Set::setIndexSettingsPath
Set the index settings path
since: 3.2.2
return: self
end note
note left of Set::items
Save items remotely
@ -78,14 +107,7 @@ note left of Set::items
return: bool
end note
note right of Set::getTable
Get the current active table
since: 3.2.2
return: string
end note
note left of Set::updateItem
note right of Set::updateItem
update an existing item (if changed)
since: 3.2.2
@ -97,14 +119,14 @@ note left of Set::updateItem
object $repo
end note
note right of Set::createItem
note left of Set::createItem
create a new item
since: 3.2.2
return: void
end note
note left of Set::updateItemReadme
note right of Set::updateItemReadme
update an existing item readme
since: 3.2.2
@ -116,20 +138,61 @@ note left of Set::updateItemReadme
object $repo
end note
note right of Set::createItemReadme
note left of Set::createItemReadme
create a new item readme
since: 3.2.2
return: void
end note
note left of Set::saveRepoMainSettings
note right of Set::getTable
Get the current active table
since: 3.2.2
return: string
end note
note left of Set::getArea
Get the current active area
since: 3.2.2
return: string
end note
note right of Set::saveRepoMainSettings
Update/Create the repo main readme and index
since: 3.2.2
return: void
end note
note left of Set::isInvalidIndexRepo
Validate repository and settings
since: 3.2.2
return: bool
end note
note right of Set::mergeIndexSettings
Merge current settings with new settings
since: 3.2.2
return: array
end note
note left of Set::updateIndexMainFile
Update a file in the repository
since: 3.2.2
return: void
arguments:
object $repo
string $path
string $content
string $message
end note
note right of Set::getLocalItems
Get items
@ -137,42 +200,49 @@ note right of Set::getLocalItems
return: ?array
end note
note left of Set::save
Save an item remotely
since: 3.2.2
return: void
end note
note right of Set::fetchLocalItems
note left of Set::fetchLocalItems
Fetch items from the database
since: 3.2.2
return: ?array
end note
note left of Set::mapItems
note right of Set::mapItems
Map items to their properties
since: 3.2.2
return: array
end note
note right of Set::mapItem
note left of Set::mapItem
Map a single item to its properties
since: 3.2.2
return: object
end note
note left of Set::canWrite
note right of Set::save
Save an item remotely
since: 3.2.2
return: void
end note
note left of Set::getIndexItem
Get index values
since: 3.2.2
return: ?array
end note
note right of Set::canWrite
check that we have an active repo towards which we can write data
since: 3.2.2
return: bool
end note
note right of Set::areObjectsEqual
note left of Set::areObjectsEqual
Checks if two objects are equal by comparing their JSON representations.
This method converts both input objects to JSON strings and compares these strings.
If the JSON strings are identical, the objects are considered equal.
@ -181,12 +251,54 @@ If the JSON strings are identical, the objects are considered equal.
return: bool
end note
note left of Set::getSettingsPath
note right of Set::getSettingsPath
Get the settings path
since: 3.2.2
return: string
end note
note left of Set::getIndexSettingsPath
Get the index settings path
since: 3.2.2
return: string
end note
note right of Set::index_map_IndexName
Get the item name for the index values
since: 3.2.2
return: ?string
end note
note left of Set::index_map_IndexSettingsPath
Get the item settings path for the index values
since: 3.2.2
return: string
end note
note right of Set::index_map_IndexPath
Get the item path for the index values
since: 3.2.2
return: string
end note
note left of Set::index_map_IndexKey
Get the item JPK for the index values
since: 3.2.2
return: string
end note
note right of Set::index_map_IndexGUID
Get the item GUID for the index values
since: 3.2.2
return: string
end note
@enduml
```

View File

@ -9,15 +9,15 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Data\Remote;
namespace VDM\Joomla\Abstraction\Remote;
use VDM\Joomla\Interfaces\GrepInterface as Grep;
use VDM\Joomla\Interfaces\Data\ItemsInterface as Items;
use VDM\Joomla\Interfaces\Readme\ItemInterface as ItemReadme;
use VDM\Joomla\Interfaces\Readme\MainInterface as MainReadme;
use VDM\Joomla\Gitea\Repository\Contents as Git;
use VDM\Joomla\Interfaces\Data\RemoteSetInterface;
use VDM\Joomla\Interfaces\Git\Repository\ContentsInterface as Git;
use VDM\Joomla\Interfaces\Remote\SetInterface;
/**
@ -25,7 +25,7 @@ use VDM\Joomla\Interfaces\Data\RemoteSetInterface;
*
* @since 3.2.2
*/
class Set implements RemoteSetInterface
abstract class Set implements SetInterface
{
/**
* The Grep Class.
@ -71,7 +71,7 @@ class Set implements RemoteSetInterface
* All active repos
*
* @var array
* @since 3.2.0
* @since 3.2.2
**/
public array $repos;
@ -79,10 +79,18 @@ class Set implements RemoteSetInterface
* Table Name
*
* @var string
* @since 3.2.1
* @since 3.2.2
*/
protected string $table;
/**
* Area Name
*
* @var string
* @since 3.2.2
*/
protected string $area;
/**
* The item map
*
@ -91,6 +99,14 @@ class Set implements RemoteSetInterface
*/
protected array $map;
/**
* The index map
*
* @var array
* @since 3.2.2
*/
protected array $index_map;
/**
* The repo main settings
*
@ -99,6 +115,22 @@ class Set implements RemoteSetInterface
*/
protected array $settings;
/**
* Prefix Key
*
* @var string
* @since 3.2.2
*/
protected string $prefix_key = 'Super---';
/**
* Suffix Key
*
* @var string
* @since 3.2.2
*/
protected string $suffix_key = '---Power';
/**
* The item settings file path
*
@ -107,23 +139,32 @@ class Set implements RemoteSetInterface
*/
protected string $settings_path = 'item.json';
/**
* The index settings file path
*
* @var string
* @since 3.2.2
*/
protected string $index_settings_path = 'index.json';
/**
* Constructor.
*
* @param array $repos The active repos
* @param Grep $grep The Grep Class.
* @param Items $items The Items Class.
* @param ItemReadme $itemReadme The Item Readme Class.
* @param MainReadme $mainReadme The Main Readme Class.
* @param Git $git The Contents Class.
* @param string|null $table The table name.
* @param string|null $settingsPath The settings path.
* @param array $repos The active repos
* @param Grep $grep The Grep Class.
* @param Items $items The Items Class.
* @param ItemReadme $itemReadme The Item Readme Class.
* @param MainReadme $mainReadme The Main Readme Class.
* @param Git $git The Contents Class.
* @param string|null $table The table name.
* @param string|null $settingsPath The settings path.
* @param string|null $settingsIndexPath The index settings path.
*
* @since 3.2.2
*/
public function __construct(array $repos, Grep $grep, Items $items,
ItemReadme $itemReadme, MainReadme $mainReadme, Git $git,
?string $table = null, ?string $settingsPath = null)
?string $table = null, ?string $settingsPath = null, ?string $settingsIndexPath = null)
{
$this->repos = $repos;
$this->grep = $grep;
@ -142,6 +183,16 @@ class Set implements RemoteSetInterface
$this->settings_path = $settingsPath;
}
if ($settingsIndexPath !== null)
{
$this->setIndexSettingsPath($settingsIndexPath);
}
if (empty($this->area))
{
$this->area = ucfirst(str_replace('_', ' ', $this->table));
}
// set the branch to writing
$this->grep->setBranchField('write_branch');
}
@ -161,6 +212,21 @@ class Set implements RemoteSetInterface
return $this;
}
/**
* Set the current active area
*
* @param string $area The area that should be active
*
* @return self
* @since 3.2.2
*/
public function area(string $area): self
{
$this->area = ucfirst(str_replace('_', ' ', $area));
return $this;
}
/**
* Set the settings path
*
@ -176,6 +242,23 @@ class Set implements RemoteSetInterface
return $this;
}
/**
* Set the index settings path
*
* @param string $settingsIndexPath The repository index settings path
*
* @return self
* @since 3.2.2
*/
public function setIndexSettingsPath(string $settingsIndexPath): self
{
$this->index_settings_path = $settingsIndexPath;
$this->grep->setIndexPath($settingsIndexPath);
return $this;
}
/**
* Save items remotely
*
@ -189,7 +272,7 @@ class Set implements RemoteSetInterface
{
if (!$this->canWrite())
{
throw new \Exception("At least one [Item] content repository must be configured with a [Write Branch] value in the repositories area for the push function to operate correctly.");
throw new \Exception("At least one [{$this->getArea()}] content repository must be configured with a [Write Branch] value in the repositories area for the push function to operate correctly.");
}
// we reset the index settings
@ -197,7 +280,7 @@ class Set implements RemoteSetInterface
if (($items = $this->getLocalItems($guids)) === null)
{
throw new \Exception("At least one valid local [Item] must exist for the push function to operate correctly.");
throw new \Exception("At least one valid local [{$this->getArea()}] must exist for the push function to operate correctly.");
}
foreach ($items as $item)
@ -217,17 +300,6 @@ class Set implements RemoteSetInterface
return true;
}
/**
* Get the current active table
*
* @return string
* @since 3.2.2
*/
public function getTable(): string
{
return $this->table;
}
/**
* update an existing item (if changed)
*
@ -274,15 +346,149 @@ class Set implements RemoteSetInterface
*/
abstract protected function createItemReadme(object $item, object $repo): void;
/**
* Get the current active table
*
* @return string
* @since 3.2.2
*/
protected function getTable(): string
{
return $this->table;
}
/**
* Get the current active area
*
* @return string
* @since 3.2.2
*/
protected function getArea(): string
{
return $this->area;
}
/**
* Update/Create the repo main readme and index
*
* @param array $repo
*
* @param array $repoBucket
*
* @return void
* @since 3.2.2
*/
abstract protected function saveRepoMainSettings(array $repo): void;
protected function saveRepoMainSettings(array $repoBucket): void
{
$repo = $repoBucket['repo'] ?? null;
$settings = $repoBucket['items'] ?? null;
if ($this->isInvalidIndexRepo($repo, $settings))
{
return;
}
$repoGuid = $repo->guid ?? null;
if (empty($repoGuid))
{
return;
}
$settings = $this->mergeIndexSettings($repoGuid, $settings);
$this->updateIndexMainFile(
$repo,
$this->getIndexSettingsPath(),
json_encode($settings, JSON_PRETTY_PRINT),
'Update main index file'
);
$this->updateIndexMainFile(
$repo,
'README.md',
$this->mainReadme->get($settings),
'Update main readme file'
);
}
/**
* Validate repository and settings
*
* @param mixed $repo
* @param mixed $settings
*
* @return bool
* @since 3.2.2
*/
protected function isInvalidIndexRepo($repo, $settings): bool
{
return empty($repo) || empty($settings);
}
/**
* Merge current settings with new settings
*
* @param string $repoGuid
* @param array $settings
*
* @return array
* @since 3.2.2
*/
protected function mergeIndexSettings(string $repoGuid, array $settings): array
{
$current_settings = $this->grep->getRemoteIndex($repoGuid);
if ($current_settings === null || (array) $current_settings === [])
{
return $settings;
}
$mergedSettings = [];
foreach ($current_settings as $guid => $setting)
{
$mergedSettings[$guid] = (array) $setting;
}
foreach ($settings as $guid => $setting)
{
$mergedSettings[$guid] = (array) $setting;
}
return $mergedSettings;
}
/**
* Update a file in the repository
*
* @param object $repo
* @param string $path
* @param string $content
* @param string $message
*
* @return void
* @since 3.2.2
*/
protected function updateIndexMainFile(object $repo, string $path,
string $content, string $message): void
{
$meta = $this->git->metadata(
$repo->organisation,
$repo->repository,
$path,
$repo->write_branch
);
if ($meta !== null && isset($meta->sha))
{
$this->git->update(
$repo->organisation,
$repo->repository,
$path,
$content,
$message,
$meta->sha,
$repo->write_branch
);
}
}
/**
* Get items
@ -304,52 +510,6 @@ class Set implements RemoteSetInterface
return $this->mapItems($items);
}
/**
* Save an item remotely
*
* @param object $item The item to save
*
* @return void
* @since 3.2.2
*/
protected function save(object $item): void
{
foreach ($this->repos as $key => $repo)
{
if (empty($repo->write_branch) || $repo->write_branch === 'default')
{
continue;
}
$this->git->load_($repo->base ?? null, $repo->token ?? null);
if (($existing = $this->grep->get($guid, ['remote'], $repo)) !== null)
{
if ($this->updateItem($item, $existing, $repo))
{
$this->updateItemReadme($item, $existing, $repo);
}
}
else
{
$this->createItem($item, $repo);
$this->createItemReadme($item, $repo);
if (!isset($this->settings[$key]))
{
$this->settings[$key] = ['repo' => $repo, 'items' => [$item]);
}
else
{
$this->settings[$key]['items'][] = $item;
}
}
$this->git->reset_();
}
}
/**
* Fetch items from the database
*
@ -360,7 +520,7 @@ class Set implements RemoteSetInterface
*/
protected function fetchLocalItems(array $guids): ?array
{
return $this->items->table($this->table)->get($guids);
return $this->items->table($this->getTable())->get($guids);
}
/**
@ -408,6 +568,87 @@ class Set implements RemoteSetInterface
return (object) $power;
}
/**
* Save an item remotely
*
* @param object $item The item to save
*
* @return void
* @since 3.2.2
*/
protected function save(object $item): void
{
if (empty($item->guid))
{
return;
}
$index_item = null;
foreach ($this->repos as $key => $repo)
{
if (empty($repo->write_branch) || $repo->write_branch === 'default')
{
continue;
}
$this->git->load_($repo->base ?? null, $repo->token ?? null);
if (($existing = $this->grep->get($item->guid, ['remote'], $repo)) !== null)
{
if ($this->updateItem($item, $existing, $repo))
{
$this->updateItemReadme($item, $existing, $repo);
}
}
else
{
$this->createItem($item, $repo);
$this->createItemReadme($item, $repo);
$index_item ??= $this->getIndexItem($item);
if (!isset($this->settings[$key]))
{
$this->settings[$key] = ['repo' => $repo, 'items' => [$item->guid => $index_item]];
}
else
{
$this->settings[$key]['items'][$item->guid] = $index_item;
}
}
$this->git->reset_();
}
}
/**
* Get index values
*
* @param object $item The item
*
* @return array|null
* @since 3.2.2
*/
protected function getIndexItem(object $item): ?array
{
if (empty($this->index_map))
{
return null;
}
$index_item = [];
foreach ($this->index_map as $key => $function_name)
{
if (method_exists($this, $function_name))
{
$index_item[$key] = $this->{$function_name}($item);
}
}
return $index_item ?? null;
}
/**
* check that we have an active repo towards which we can write data
*
@ -458,6 +699,84 @@ class Set implements RemoteSetInterface
protected function getSettingsPath(): string
{
return $this->settings_path;
}
/**
* Get the index settings path
*
* @return string
* @since 3.2.2
*/
protected function getIndexSettingsPath(): string
{
return $this->index_settings_path;
}
//// index_map_ (area) /////////////////////////////////////////////
/**
* Get the item name for the index values
*
* @param object $item
*
* @return string|null
* @since 3.2.2
*/
protected function index_map_IndexName(object $item): ?string
{
return $item->system_name ?? null;
}
/**
* Get the item settings path for the index values
*
* @param object $item
*
* @return string
* @since 3.2.2
*/
protected function index_map_IndexSettingsPath(object $item): string
{
return "src/{$item->guid}/" . $this->getSettingsPath();
}
/**
* Get the item path for the index values
*
* @param object $item
*
* @return string
* @since 3.2.2
*/
protected function index_map_IndexPath(object $item): string
{
return "src/{$item->guid}";
}
/**
* Get the item JPK for the index values
*
* @param object $item
*
* @return string
* @since 3.2.2
*/
protected function index_map_IndexKey(object $item): string
{
return $this->prefix_key . str_replace('-', '_', $item->guid) . $this->suffix_key;
}
/**
* Get the item GUID for the index values
*
* @param object $item
*
* @return string
* @since 3.2.2
*/
protected function index_map_IndexGUID(object $item): string
{
return $item->guid;
}
}

View File

@ -42,7 +42,7 @@
* All active repos
*
* @var array
* @since 3.2.0
* @since 3.2.2
**/
public array $repos;
@ -50,10 +50,18 @@
* Table Name
*
* @var string
* @since 3.2.1
* @since 3.2.2
*/
protected string $table;
/**
* Area Name
*
* @var string
* @since 3.2.2
*/
protected string $area;
/**
* The item map
*
@ -62,6 +70,14 @@
*/
protected array $map;
/**
* The index map
*
* @var array
* @since 3.2.2
*/
protected array $index_map;
/**
* The repo main settings
*
@ -70,6 +86,22 @@
*/
protected array $settings;
/**
* Prefix Key
*
* @var string
* @since 3.2.2
*/
protected string $prefix_key = 'Super---';
/**
* Suffix Key
*
* @var string
* @since 3.2.2
*/
protected string $suffix_key = '---Power';
/**
* The item settings file path
*
@ -78,23 +110,32 @@
*/
protected string $settings_path = 'item.json';
/**
* The index settings file path
*
* @var string
* @since 3.2.2
*/
protected string $index_settings_path = 'index.json';
/**
* Constructor.
*
* @param array $repos The active repos
* @param Grep $grep The Grep Class.
* @param Items $items The Items Class.
* @param ItemReadme $itemReadme The Item Readme Class.
* @param MainReadme $mainReadme The Main Readme Class.
* @param Git $git The Contents Class.
* @param string|null $table The table name.
* @param string|null $settingsPath The settings path.
* @param array $repos The active repos
* @param Grep $grep The Grep Class.
* @param Items $items The Items Class.
* @param ItemReadme $itemReadme The Item Readme Class.
* @param MainReadme $mainReadme The Main Readme Class.
* @param Git $git The Contents Class.
* @param string|null $table The table name.
* @param string|null $settingsPath The settings path.
* @param string|null $settingsIndexPath The index settings path.
*
* @since 3.2.2
*/
public function __construct(array $repos, Grep $grep, Items $items,
ItemReadme $itemReadme, MainReadme $mainReadme, Git $git,
?string $table = null, ?string $settingsPath = null)
?string $table = null, ?string $settingsPath = null, ?string $settingsIndexPath = null)
{
$this->repos = $repos;
$this->grep = $grep;
@ -113,6 +154,16 @@
$this->settings_path = $settingsPath;
}
if ($settingsIndexPath !== null)
{
$this->setIndexSettingsPath($settingsIndexPath);
}
if (empty($this->area))
{
$this->area = ucfirst(str_replace('_', ' ', $this->table));
}
// set the branch to writing
$this->grep->setBranchField('write_branch');
}
@ -132,6 +183,21 @@
return $this;
}
/**
* Set the current active area
*
* @param string $area The area that should be active
*
* @return self
* @since 3.2.2
*/
public function area(string $area): self
{
$this->area = ucfirst(str_replace('_', ' ', $area));
return $this;
}
/**
* Set the settings path
*
@ -147,6 +213,23 @@
return $this;
}
/**
* Set the index settings path
*
* @param string $settingsIndexPath The repository index settings path
*
* @return self
* @since 3.2.2
*/
public function setIndexSettingsPath(string $settingsIndexPath): self
{
$this->index_settings_path = $settingsIndexPath;
$this->grep->setIndexPath($settingsIndexPath);
return $this;
}
/**
* Save items remotely
*
@ -160,7 +243,7 @@
{
if (!$this->canWrite())
{
throw new \Exception("At least one [Item] content repository must be configured with a [Write Branch] value in the repositories area for the push function to operate correctly.");
throw new \Exception("At least one [{$this->getArea()}] content repository must be configured with a [Write Branch] value in the repositories area for the push function to operate correctly.");
}
// we reset the index settings
@ -168,7 +251,7 @@
if (($items = $this->getLocalItems($guids)) === null)
{
throw new \Exception("At least one valid local [Item] must exist for the push function to operate correctly.");
throw new \Exception("At least one valid local [{$this->getArea()}] must exist for the push function to operate correctly.");
}
foreach ($items as $item)
@ -188,17 +271,6 @@
return true;
}
/**
* Get the current active table
*
* @return string
* @since 3.2.2
*/
public function getTable(): string
{
return $this->table;
}
/**
* update an existing item (if changed)
*
@ -245,15 +317,149 @@
*/
abstract protected function createItemReadme(object $item, object $repo): void;
/**
* Get the current active table
*
* @return string
* @since 3.2.2
*/
protected function getTable(): string
{
return $this->table;
}
/**
* Get the current active area
*
* @return string
* @since 3.2.2
*/
protected function getArea(): string
{
return $this->area;
}
/**
* Update/Create the repo main readme and index
*
* @param array $repo
*
* @param array $repoBucket
*
* @return void
* @since 3.2.2
*/
abstract protected function saveRepoMainSettings(array $repo): void;
protected function saveRepoMainSettings(array $repoBucket): void
{
$repo = $repoBucket['repo'] ?? null;
$settings = $repoBucket['items'] ?? null;
if ($this->isInvalidIndexRepo($repo, $settings))
{
return;
}
$repoGuid = $repo->guid ?? null;
if (empty($repoGuid))
{
return;
}
$settings = $this->mergeIndexSettings($repoGuid, $settings);
$this->updateIndexMainFile(
$repo,
$this->getIndexSettingsPath(),
json_encode($settings, JSON_PRETTY_PRINT),
'Update main index file'
);
$this->updateIndexMainFile(
$repo,
'README.md',
$this->mainReadme->get($settings),
'Update main readme file'
);
}
/**
* Validate repository and settings
*
* @param mixed $repo
* @param mixed $settings
*
* @return bool
* @since 3.2.2
*/
protected function isInvalidIndexRepo($repo, $settings): bool
{
return empty($repo) || empty($settings);
}
/**
* Merge current settings with new settings
*
* @param string $repoGuid
* @param array $settings
*
* @return array
* @since 3.2.2
*/
protected function mergeIndexSettings(string $repoGuid, array $settings): array
{
$current_settings = $this->grep->getRemoteIndex($repoGuid);
if ($current_settings === null || (array) $current_settings === [])
{
return $settings;
}
$mergedSettings = [];
foreach ($current_settings as $guid => $setting)
{
$mergedSettings[$guid] = (array) $setting;
}
foreach ($settings as $guid => $setting)
{
$mergedSettings[$guid] = (array) $setting;
}
return $mergedSettings;
}
/**
* Update a file in the repository
*
* @param object $repo
* @param string $path
* @param string $content
* @param string $message
*
* @return void
* @since 3.2.2
*/
protected function updateIndexMainFile(object $repo, string $path,
string $content, string $message): void
{
$meta = $this->git->metadata(
$repo->organisation,
$repo->repository,
$path,
$repo->write_branch
);
if ($meta !== null && isset($meta->sha))
{
$this->git->update(
$repo->organisation,
$repo->repository,
$path,
$content,
$message,
$meta->sha,
$repo->write_branch
);
}
}
/**
* Get items
@ -275,52 +481,6 @@
return $this->mapItems($items);
}
/**
* Save an item remotely
*
* @param object $item The item to save
*
* @return void
* @since 3.2.2
*/
protected function save(object $item): void
{
foreach ($this->repos as $key => $repo)
{
if (empty($repo->write_branch) || $repo->write_branch === 'default')
{
continue;
}
$this->git->load_($repo->base ?? null, $repo->token ?? null);
if (($existing = $this->grep->get($guid, ['remote'], $repo)) !== null)
{
if ($this->updateItem($item, $existing, $repo))
{
$this->updateItemReadme($item, $existing, $repo);
}
}
else
{
$this->createItem($item, $repo);
$this->createItemReadme($item, $repo);
if (!isset($this->settings[$key]))
{
$this->settings[$key] = ['repo' => $repo, 'items' => [$item]);
}
else
{
$this->settings[$key]['items'][] = $item;
}
}
$this->git->reset_();
}
}
/**
* Fetch items from the database
*
@ -331,7 +491,7 @@
*/
protected function fetchLocalItems(array $guids): ?array
{
return $this->items->table($this->table)->get($guids);
return $this->items->table($this->getTable())->get($guids);
}
/**
@ -379,6 +539,87 @@
return (object) $power;
}
/**
* Save an item remotely
*
* @param object $item The item to save
*
* @return void
* @since 3.2.2
*/
protected function save(object $item): void
{
if (empty($item->guid))
{
return;
}
$index_item = null;
foreach ($this->repos as $key => $repo)
{
if (empty($repo->write_branch) || $repo->write_branch === 'default')
{
continue;
}
$this->git->load_($repo->base ?? null, $repo->token ?? null);
if (($existing = $this->grep->get($item->guid, ['remote'], $repo)) !== null)
{
if ($this->updateItem($item, $existing, $repo))
{
$this->updateItemReadme($item, $existing, $repo);
}
}
else
{
$this->createItem($item, $repo);
$this->createItemReadme($item, $repo);
$index_item ??= $this->getIndexItem($item);
if (!isset($this->settings[$key]))
{
$this->settings[$key] = ['repo' => $repo, 'items' => [$item->guid => $index_item]];
}
else
{
$this->settings[$key]['items'][$item->guid] = $index_item;
}
}
$this->git->reset_();
}
}
/**
* Get index values
*
* @param object $item The item
*
* @return array|null
* @since 3.2.2
*/
protected function getIndexItem(object $item): ?array
{
if (empty($this->index_map))
{
return null;
}
$index_item = [];
foreach ($this->index_map as $key => $function_name)
{
if (method_exists($this, $function_name))
{
$index_item[$key] = $this->{$function_name}($item);
}
}
return $index_item ?? null;
}
/**
* check that we have an active repo towards which we can write data
*
@ -429,4 +670,82 @@
protected function getSettingsPath(): string
{
return $this->settings_path;
}
/**
* Get the index settings path
*
* @return string
* @since 3.2.2
*/
protected function getIndexSettingsPath(): string
{
return $this->index_settings_path;
}
//// index_map_ (area) /////////////////////////////////////////////
/**
* Get the item name for the index values
*
* @param object $item
*
* @return string|null
* @since 3.2.2
*/
protected function index_map_IndexName(object $item): ?string
{
return $item->system_name ?? null;
}
/**
* Get the item settings path for the index values
*
* @param object $item
*
* @return string
* @since 3.2.2
*/
protected function index_map_IndexSettingsPath(object $item): string
{
return "src/{$item->guid}/" . $this->getSettingsPath();
}
/**
* Get the item path for the index values
*
* @param object $item
*
* @return string
* @since 3.2.2
*/
protected function index_map_IndexPath(object $item): string
{
return "src/{$item->guid}";
}
/**
* Get the item JPK for the index values
*
* @param object $item
*
* @return string
* @since 3.2.2
*/
protected function index_map_IndexKey(object $item): string
{
return $this->prefix_key . str_replace('-', '_', $item->guid) . $this->suffix_key;
}
/**
* Get the item GUID for the index values
*
* @param object $item
*
* @return string
* @since 3.2.2
*/
protected function index_map_IndexGUID(object $item): string
{
return $item->guid;
}

View File

@ -9,8 +9,8 @@
"load_selection": null,
"name": "Set",
"power_version": "1.0.0",
"system_name": "VDM.Data.Remote.Set",
"type": "class",
"system_name": "VDM.Abstraction.Remote.Set",
"type": "abstract class",
"use_selection": {
"use_selection0": {
"use": "c182506a-ab84-439c-b962-1e606b58d545",
@ -29,12 +29,12 @@
"as": "MainReadme"
},
"use_selection4": {
"use": "8d1baef6-fcad-49a9-848f-428009cdb989",
"use": "d1de5d5b-bf29-4031-8094-76c4f6c75900",
"as": "Git"
}
},
"extendsinterfaces": null,
"namespace": "[[[NamespacePrefix]]]\\Joomla\\Data.Remote.Set",
"namespace": "[[[NamespacePrefix]]]\\Joomla\\Abstraction.Remote.Set",
"description": "Set data based on global unique ids to remote repository\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",
"head": "",

View File

@ -109,6 +109,17 @@
"spk": "Super---152c8793_8b75_4715_996a_257b9f65451c---Power",
"guid": "152c8793-8b75-4715-996a-257b9f65451c"
},
"17ed2fec-49d6-4731-92c3-f9cd78fb6273": {
"name": "ApiInterface",
"type": "interface",
"namespace": "VDM\\Joomla\\Interfaces\\Git",
"code": "src\/17ed2fec-49d6-4731-92c3-f9cd78fb6273\/code.php",
"power": "src\/17ed2fec-49d6-4731-92c3-f9cd78fb6273\/code.power",
"settings": "src\/17ed2fec-49d6-4731-92c3-f9cd78fb6273\/settings.json",
"path": "src\/17ed2fec-49d6-4731-92c3-f9cd78fb6273",
"spk": "Super---17ed2fec_49d6_4731_92c3_f9cd78fb6273---Power",
"guid": "17ed2fec-49d6-4731-92c3-f9cd78fb6273"
},
"19b2ba92-1655-4384-acfb-979c80de8b6d": {
"name": "Table",
"type": "class",
@ -308,9 +319,9 @@
"guid": "4dd11b9b-3c64-460b-aaa6-62ba467db7aa"
},
"51de80f2-2868-4c2c-8198-ef79349e9bd7": {
"name": "RemoteGetInterface",
"name": "GetInterface",
"type": "interface",
"namespace": "VDM\\Joomla\\Interfaces\\Data",
"namespace": "VDM\\Joomla\\Interfaces\\Remote",
"code": "src\/51de80f2-2868-4c2c-8198-ef79349e9bd7\/code.php",
"power": "src\/51de80f2-2868-4c2c-8198-ef79349e9bd7\/code.power",
"settings": "src\/51de80f2-2868-4c2c-8198-ef79349e9bd7\/settings.json",
@ -474,8 +485,8 @@
},
"728ee726-3f0f-4762-899d-f8c9430cee58": {
"name": "Get",
"type": "class",
"namespace": "VDM\\Joomla\\Data\\Remote",
"type": "abstract class",
"namespace": "VDM\\Joomla\\Abstraction\\Remote",
"code": "src\/728ee726-3f0f-4762-899d-f8c9430cee58\/code.php",
"power": "src\/728ee726-3f0f-4762-899d-f8c9430cee58\/code.power",
"settings": "src\/728ee726-3f0f-4762-899d-f8c9430cee58\/settings.json",
@ -835,6 +846,17 @@
"spk": "Super---cefe4092_a4c2_41a6_a683_bd3ab5419cc6---Power",
"guid": "cefe4092-a4c2-41a6-a683-bd3ab5419cc6"
},
"d1de5d5b-bf29-4031-8094-76c4f6c75900": {
"name": "ContentsInterface",
"type": "interface",
"namespace": "VDM\\Joomla\\Interfaces\\Git\\Repository",
"code": "src\/d1de5d5b-bf29-4031-8094-76c4f6c75900\/code.php",
"power": "src\/d1de5d5b-bf29-4031-8094-76c4f6c75900\/code.power",
"settings": "src\/d1de5d5b-bf29-4031-8094-76c4f6c75900\/settings.json",
"path": "src\/d1de5d5b-bf29-4031-8094-76c4f6c75900",
"spk": "Super---d1de5d5b_bf29_4031_8094_76c4f6c75900---Power",
"guid": "d1de5d5b-bf29-4031-8094-76c4f6c75900"
},
"d8f9ba53-c490-4e8b-8e9f-6757224e069c": {
"name": "DeleteInterface",
"type": "interface",
@ -880,9 +902,9 @@
"guid": "e0f6ddbe-2a35-4537-942c-faff2ebd04f6"
},
"e335dd61-c2f9-4536-8ed9-aec5edee0b26": {
"name": "RemoteSetInterface",
"name": "SetInterface",
"type": "interface",
"namespace": "VDM\\Joomla\\Interfaces\\Data",
"namespace": "VDM\\Joomla\\Interfaces\\Remote",
"code": "src\/e335dd61-c2f9-4536-8ed9-aec5edee0b26\/code.php",
"power": "src\/e335dd61-c2f9-4536-8ed9-aec5edee0b26\/code.power",
"settings": "src\/e335dd61-c2f9-4536-8ed9-aec5edee0b26\/settings.json",
@ -892,8 +914,8 @@
},
"eb7d69c2-4ee9-4bd0-aacc-ab51a12be895": {
"name": "Set",
"type": "class",
"namespace": "VDM\\Joomla\\Data\\Remote",
"type": "abstract class",
"namespace": "VDM\\Joomla\\Abstraction\\Remote",
"code": "src\/eb7d69c2-4ee9-4bd0-aacc-ab51a12be895\/code.php",
"power": "src\/eb7d69c2-4ee9-4bd0-aacc-ab51a12be895\/code.power",
"settings": "src\/eb7d69c2-4ee9-4bd0-aacc-ab51a12be895\/settings.json",