From e3096c796e07c54aa620fbc07144932fcbd0535d Mon Sep 17 00:00:00 2001 From: aB0t Date: Fri, 18 Oct 2024 02:15:16 +0200 Subject: [PATCH] Update 2024-10-18 02:15:11 --- README.md | 16 +- .../README.md | 89 ++++++ .../code.php | 75 +++++ .../code.power | 52 +++ .../settings.json | 19 ++ .../README.md | 84 +++++ .../code.php | 114 +++++++ .../code.power | 83 +++++ .../settings.json | 39 +++ .../README.md | 120 +++++++ .../code.php | 109 +++++++ .../code.power | 86 +++++ .../settings.json | 19 ++ .../README.md | 16 +- .../code.php | 2 +- .../settings.json | 6 +- .../README.md | 84 +++++ .../code.php | 68 ++++ .../code.power | 45 +++ .../settings.json | 19 ++ .../README.md | 52 +++ .../code.php | 33 ++ .../code.power | 10 + .../settings.json | 19 ++ .../code.php | 2 +- .../code.php | 2 +- .../README.md | 134 ++++++++ .../code.php | 269 ++++++++++++++++ .../code.power | 240 ++++++++++++++ .../settings.json | 34 ++ .../README.md | 19 +- .../code.php | 156 ++++++--- .../code.power | 153 ++++++--- .../settings.json | 4 +- .../README.md | 3 + .../code.php | 35 ++- .../code.power | 35 ++- .../settings.json | 4 +- .../README.md | 87 +++++ .../code.php | 131 ++++++++ .../code.power | 105 +++++++ .../settings.json | 21 ++ .../code.php | 4 +- .../README.md | 104 ++++++ .../code.php | 149 +++++++++ .../code.power | 122 +++++++ .../settings.json | 26 ++ .../code.php | 4 +- .../README.md | 134 ++++++++ .../code.php | 297 ++++++++++++++++++ .../code.power | 268 ++++++++++++++++ .../settings.json | 34 ++ .../code.php | 2 +- .../README.md | 59 ++++ .../code.php | 34 ++ .../code.power | 13 + .../settings.json | 19 ++ .../code.php | 2 + .../code.power | 1 + .../settings.json | 4 + super-powers.json | 112 ++++++- 61 files changed, 3965 insertions(+), 116 deletions(-) create mode 100644 src/0e44d149-4863-47ec-8f0f-6a821ab3e77f/README.md create mode 100644 src/0e44d149-4863-47ec-8f0f-6a821ab3e77f/code.php create mode 100644 src/0e44d149-4863-47ec-8f0f-6a821ab3e77f/code.power create mode 100644 src/0e44d149-4863-47ec-8f0f-6a821ab3e77f/settings.json create mode 100644 src/21754a8b-2323-4a77-8459-378a74c1ec97/README.md create mode 100644 src/21754a8b-2323-4a77-8459-378a74c1ec97/code.php create mode 100644 src/21754a8b-2323-4a77-8459-378a74c1ec97/code.power create mode 100644 src/21754a8b-2323-4a77-8459-378a74c1ec97/settings.json create mode 100644 src/23ad6e72-1b82-40fb-836c-50da690bb174/README.md create mode 100644 src/23ad6e72-1b82-40fb-836c-50da690bb174/code.php create mode 100644 src/23ad6e72-1b82-40fb-836c-50da690bb174/code.power create mode 100644 src/23ad6e72-1b82-40fb-836c-50da690bb174/settings.json create mode 100644 src/3d3ec064-9867-41e6-a48a-964c15d753aa/README.md create mode 100644 src/3d3ec064-9867-41e6-a48a-964c15d753aa/code.php create mode 100644 src/3d3ec064-9867-41e6-a48a-964c15d753aa/code.power create mode 100644 src/3d3ec064-9867-41e6-a48a-964c15d753aa/settings.json create mode 100644 src/53f55e5b-63cb-49e7-b1e6-33e7a9f97856/README.md create mode 100644 src/53f55e5b-63cb-49e7-b1e6-33e7a9f97856/code.php create mode 100644 src/53f55e5b-63cb-49e7-b1e6-33e7a9f97856/code.power create mode 100644 src/53f55e5b-63cb-49e7-b1e6-33e7a9f97856/settings.json create mode 100644 src/68a0f9af-265a-4db1-bae9-a4e4531f94d7/README.md create mode 100644 src/68a0f9af-265a-4db1-bae9-a4e4531f94d7/code.php create mode 100644 src/68a0f9af-265a-4db1-bae9-a4e4531f94d7/code.power create mode 100644 src/68a0f9af-265a-4db1-bae9-a4e4531f94d7/settings.json create mode 100644 src/afb5b891-7130-422a-b389-1934b0e4fc48/README.md create mode 100644 src/afb5b891-7130-422a-b389-1934b0e4fc48/code.php create mode 100644 src/afb5b891-7130-422a-b389-1934b0e4fc48/code.power create mode 100644 src/afb5b891-7130-422a-b389-1934b0e4fc48/settings.json create mode 100644 src/d2a859ac-3f2a-4f69-a77f-f118b2e0a459/README.md create mode 100644 src/d2a859ac-3f2a-4f69-a77f-f118b2e0a459/code.php create mode 100644 src/d2a859ac-3f2a-4f69-a77f-f118b2e0a459/code.power create mode 100644 src/d2a859ac-3f2a-4f69-a77f-f118b2e0a459/settings.json create mode 100644 src/eef6ffc2-2af0-4336-958f-e0b9cf7c4ad0/README.md create mode 100644 src/eef6ffc2-2af0-4336-958f-e0b9cf7c4ad0/code.php create mode 100644 src/eef6ffc2-2af0-4336-958f-e0b9cf7c4ad0/code.power create mode 100644 src/eef6ffc2-2af0-4336-958f-e0b9cf7c4ad0/settings.json create mode 100644 src/feb3affa-5102-4307-93db-04525f4c66f0/README.md create mode 100644 src/feb3affa-5102-4307-93db-04525f4c66f0/code.php create mode 100644 src/feb3affa-5102-4307-93db-04525f4c66f0/code.power create mode 100644 src/feb3affa-5102-4307-93db-04525f4c66f0/settings.json diff --git a/README.md b/README.md index 1a3e99f..ec0feaa 100644 --- a/README.md +++ b/README.md @@ -68,7 +68,8 @@ This repository contains an index (see below) of all the approved powers within - **interface Registryinterface** | [Details](src/64e291c2-11f1-423d-a44d-837cc12cc017) | [Code](src/64e291c2-11f1-423d-a44d-837cc12cc017/code.php) | [Settings](src/64e291c2-11f1-423d-a44d-837cc12cc017/settings.json) | SPK: `Super---64e291c2_11f1_423d_a44d_837cc12cc017---Power` - **interface SchemaCheckerInterface** | [Details](src/b6e9854c-3672-42ec-8843-26c24b4635bd) | [Code](src/b6e9854c-3672-42ec-8843-26c24b4635bd/code.php) | [Settings](src/b6e9854c-3672-42ec-8843-26c24b4635bd/settings.json) | SPK: `Super---b6e9854c_3672_42ec_8843_26c24b4635bd---Power` - **interface SchemaInterface** | [Details](src/4dd11b9b-3c64-460b-aaa6-62ba467db7aa) | [Code](src/4dd11b9b-3c64-460b-aaa6-62ba467db7aa/code.php) | [Settings](src/4dd11b9b-3c64-460b-aaa6-62ba467db7aa/settings.json) | SPK: `Super---4dd11b9b_3c64_460b_aaa6_62ba467db7aa---Power` - - **interface Tableinterface** | [Details](src/2da6d6c4-eb29-4d69-8bc2-36d96e916adf) | [Code](src/2da6d6c4-eb29-4d69-8bc2-36d96e916adf/code.php) | [Settings](src/2da6d6c4-eb29-4d69-8bc2-36d96e916adf/settings.json) | SPK: `Super---2da6d6c4_eb29_4d69_8bc2_36d96e916adf---Power` + - **interface TableInterface** | [Details](src/2da6d6c4-eb29-4d69-8bc2-36d96e916adf) | [Code](src/2da6d6c4-eb29-4d69-8bc2-36d96e916adf/code.php) | [Settings](src/2da6d6c4-eb29-4d69-8bc2-36d96e916adf/settings.json) | SPK: `Super---2da6d6c4_eb29_4d69_8bc2_36d96e916adf---Power` + - **interface TableValidatorInterface** | [Details](src/feb3affa-5102-4307-93db-04525f4c66f0) | [Code](src/feb3affa-5102-4307-93db-04525f4c66f0/code.php) | [Settings](src/feb3affa-5102-4307-93db-04525f4c66f0/settings.json) | SPK: `Super---feb3affa_5102_4307_93db_04525f4c66f0---Power` - **interface UpdateInterface** | [Details](src/7179fde6-1e51-4b51-8545-7ca18f74a0f4) | [Code](src/7179fde6-1e51-4b51-8545-7ca18f74a0f4/code.php) | [Settings](src/7179fde6-1e51-4b51-8545-7ca18f74a0f4/settings.json) | SPK: `Super---7179fde6_1e51_4b51_8545_7ca18f74a0f4---Power` - **Namespace**: [VDM\Joomla\Model](#vdm-joomla-model) @@ -118,6 +119,16 @@ This repository contains an index (see below) of all the approved powers within - **Namespace**: [VDM\Joomla\Componentbuilder\Import](#vdm-joomla-componentbuilder-import) - **abstract class Factory** | [Details](src/ff8d5fdb-2d1f-4178-bd18-a43b8efd1068) | [Code](src/ff8d5fdb-2d1f-4178-bd18-a43b8efd1068/code.php) | [Settings](src/ff8d5fdb-2d1f-4178-bd18-a43b8efd1068/settings.json) | SPK: `Super---ff8d5fdb_2d1f_4178_bd18_a43b8efd1068---Power` + - **final class Item** | [Details](src/68a0f9af-265a-4db1-bae9-a4e4531f94d7) | [Code](src/68a0f9af-265a-4db1-bae9-a4e4531f94d7/code.php) | [Settings](src/68a0f9af-265a-4db1-bae9-a4e4531f94d7/settings.json) | SPK: `Super---68a0f9af_265a_4db1_bae9_a4e4531f94d7---Power` + - **final class Message** | [Details](src/eef6ffc2-2af0-4336-958f-e0b9cf7c4ad0) | [Code](src/eef6ffc2-2af0-4336-958f-e0b9cf7c4ad0/code.php) | [Settings](src/eef6ffc2-2af0-4336-958f-e0b9cf7c4ad0/settings.json) | SPK: `Super---eef6ffc2_2af0_4336_958f_e0b9cf7c4ad0---Power` + - **final class Row** | [Details](src/afb5b891-7130-422a-b389-1934b0e4fc48) | [Code](src/afb5b891-7130-422a-b389-1934b0e4fc48/code.php) | [Settings](src/afb5b891-7130-422a-b389-1934b0e4fc48/settings.json) | SPK: `Super---afb5b891_7130_422a_b389_1934b0e4fc48---Power` + - **final class Status** | [Details](src/d2a859ac-3f2a-4f69-a77f-f118b2e0a459) | [Code](src/d2a859ac-3f2a-4f69-a77f-f118b2e0a459/code.php) | [Settings](src/d2a859ac-3f2a-4f69-a77f-f118b2e0a459/settings.json) | SPK: `Super---d2a859ac_3f2a_4f69_a77f_f118b2e0a459---Power` +- **Namespace**: [VDM\Joomla\Componentbuilder\Interfaces](#vdm-joomla-componentbuilder-interfaces) + + - **interface ImportItemInterface** | [Details](src/53f55e5b-63cb-49e7-b1e6-33e7a9f97856) | [Code](src/53f55e5b-63cb-49e7-b1e6-33e7a9f97856/code.php) | [Settings](src/53f55e5b-63cb-49e7-b1e6-33e7a9f97856/settings.json) | SPK: `Super---53f55e5b_63cb_49e7_b1e6_33e7a9f97856---Power` + - **interface ImportMessageInterface** | [Details](src/23ad6e72-1b82-40fb-836c-50da690bb174) | [Code](src/23ad6e72-1b82-40fb-836c-50da690bb174/code.php) | [Settings](src/23ad6e72-1b82-40fb-836c-50da690bb174/settings.json) | SPK: `Super---23ad6e72_1b82_40fb_836c_50da690bb174---Power` + - **interface ImportRowInterface** | [Details](src/3d3ec064-9867-41e6-a48a-964c15d753aa) | [Code](src/3d3ec064-9867-41e6-a48a-964c15d753aa/code.php) | [Settings](src/3d3ec064-9867-41e6-a48a-964c15d753aa/settings.json) | SPK: `Super---3d3ec064_9867_41e6_a48a_964c15d753aa---Power` + - **interface ImportStatusInterface** | [Details](src/0e44d149-4863-47ec-8f0f-6a821ab3e77f) | [Code](src/0e44d149-4863-47ec-8f0f-6a821ab3e77f/code.php) | [Settings](src/0e44d149-4863-47ec-8f0f-6a821ab3e77f/settings.json) | SPK: `Super---0e44d149_4863_47ec_8f0f_6a821ab3e77f---Power` - **Namespace**: [VDM\Joomla\Componentbuilder\Service](#vdm-joomla-componentbuilder-service) - **class Spreadsheet** | [Details](src/c4a188de-ad78-4a6d-9d5b-01866846d701) | [Code](src/c4a188de-ad78-4a6d-9d5b-01866846d701/code.php) | [Settings](src/c4a188de-ad78-4a6d-9d5b-01866846d701/settings.json) | SPK: `Super---c4a188de_ad78_4a6d_9d5b_01866846d701---Power` @@ -187,6 +198,9 @@ This repository contains an index (see below) of all the approved powers within - **Namespace**: [VDM\Joomla\Componentbuilder\File\Service](#vdm-joomla-componentbuilder-file-service) - **class File** | [Details](src/202ccd9e-dfcf-4cde-a0ce-bde1fd27f088) | [Code](src/202ccd9e-dfcf-4cde-a0ce-bde1fd27f088/code.php) | [Settings](src/202ccd9e-dfcf-4cde-a0ce-bde1fd27f088/settings.json) | SPK: `Super---202ccd9e_dfcf_4cde_a0ce_bde1fd27f088---Power` +- **Namespace**: [VDM\Joomla\Componentbuilder\Import\Service](#vdm-joomla-componentbuilder-import-service) + + - **class Import** | [Details](src/21754a8b-2323-4a77-8459-378a74c1ec97) | [Code](src/21754a8b-2323-4a77-8459-378a74c1ec97/code.php) | [Settings](src/21754a8b-2323-4a77-8459-378a74c1ec97/settings.json) | SPK: `Super---21754a8b_2323_4a77_8459_378a74c1ec97---Power` - **Namespace**: [VDM\Joomla\Componentbuilder\Interfaces\Spreadsheet](#vdm-joomla-componentbuilder-interfaces-spreadsheet) - **interface FileReaderInterface** | [Details](src/61d1146f-2c2e-4e42-8492-d076f945cf35) | [Code](src/61d1146f-2c2e-4e42-8492-d076f945cf35/code.php) | [Settings](src/61d1146f-2c2e-4e42-8492-d076f945cf35/settings.json) | SPK: `Super---61d1146f_2c2e_4e42_8492_d076f945cf35---Power` diff --git a/src/0e44d149-4863-47ec-8f0f-6a821ab3e77f/README.md b/src/0e44d149-4863-47ec-8f0f-6a821ab3e77f/README.md new file mode 100644 index 0000000..c592471 --- /dev/null +++ b/src/0e44d149-4863-47ec-8f0f-6a821ab3e77f/README.md @@ -0,0 +1,89 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# interface ImportStatusInterface (Details) +> namespace: **VDM\Joomla\Componentbuilder\Interfaces** + +```uml +@startuml +interface ImportStatusInterface #Lavender { + + set(int $status, string $guid) : void + + table(string $table) : self + + field(string $fieldName) : self + + getTable() : string + + getField() : string +} + +note right of ImportStatusInterface::set + Updates the status in the database. +This method updates the import status in the database based on the result of the import process. +Status codes: +- 2: Being Processed. +- 3: Import completed successfully. +- 4: Import completed with errors. + + since: 3.2.2 + return: void +end note + +note right of ImportStatusInterface::table + Set the current active table + + since: 3.2.2 + return: self +end note + +note right of ImportStatusInterface::field + Set the current target status field name + + since: 3.2.2 + return: self +end note + +note right of ImportStatusInterface::getTable + Get the current active table + + since: 3.2.2 + return: string +end note + +note right of ImportStatusInterface::getField + Get the current target status field name + + since: 3.2.2 + 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---0e44d149_4863_47ec_8f0f_6a821ab3e77f---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) + diff --git a/src/0e44d149-4863-47ec-8f0f-6a821ab3e77f/code.php b/src/0e44d149-4863-47ec-8f0f-6a821ab3e77f/code.php new file mode 100644 index 0000000..b09a7df --- /dev/null +++ b/src/0e44d149-4863-47ec-8f0f-6a821ab3e77f/code.php @@ -0,0 +1,75 @@ + + * @git 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\Interfaces; + + +/** + * Import Status Interface + * + * @since 3.2.2 + */ +interface ImportStatusInterface +{ + /** + * Updates the status in the database. + * + * This method updates the import status in the database based on the result of the import process. + * Status codes: + * - 2: Being Processed. + * - 3: Import completed successfully. + * - 4: Import completed with errors. + * + * @param int $status The status code to set for the import (2 => processing, 3 => success, 4 => errors). + * @param string $guid The target import GUID + * + * @return void + * @since 3.2.2 + */ + public function set(int $status, string $guid): void; + + /** + * Set the current active table + * + * @param string $table The table that should be active + * + * @return self + * @since 3.2.2 + */ + public function table(string $table): self; + + /** + * Set the current target status field name + * + * @param string $fieldName The field name where the status is set + * + * @return self + * @since 3.2.2 + */ + public function field(string $fieldName): self; + + /** + * Get the current active table + * + * @return string + * @since 3.2.2 + */ + public function getTable(): string; + + /** + * Get the current target status field name + * + * @return string + * @since 3.2.2 + */ + public function getField(): string; +} + diff --git a/src/0e44d149-4863-47ec-8f0f-6a821ab3e77f/code.power b/src/0e44d149-4863-47ec-8f0f-6a821ab3e77f/code.power new file mode 100644 index 0000000..105f0bd --- /dev/null +++ b/src/0e44d149-4863-47ec-8f0f-6a821ab3e77f/code.power @@ -0,0 +1,52 @@ + /** + * Updates the status in the database. + * + * This method updates the import status in the database based on the result of the import process. + * Status codes: + * - 2: Being Processed. + * - 3: Import completed successfully. + * - 4: Import completed with errors. + * + * @param int $status The status code to set for the import (2 => processing, 3 => success, 4 => errors). + * @param string $guid The target import GUID + * + * @return void + * @since 3.2.2 + */ + public function set(int $status, string $guid): void; + + /** + * Set the current active table + * + * @param string $table The table that should be active + * + * @return self + * @since 3.2.2 + */ + public function table(string $table): self; + + /** + * Set the current target status field name + * + * @param string $fieldName The field name where the status is set + * + * @return self + * @since 3.2.2 + */ + public function field(string $fieldName): self; + + /** + * Get the current active table + * + * @return string + * @since 3.2.2 + */ + public function getTable(): string; + + /** + * Get the current target status field name + * + * @return string + * @since 3.2.2 + */ + public function getField(): string; \ No newline at end of file diff --git a/src/0e44d149-4863-47ec-8f0f-6a821ab3e77f/settings.json b/src/0e44d149-4863-47ec-8f0f-6a821ab3e77f/settings.json new file mode 100644 index 0000000..eb3bd38 --- /dev/null +++ b/src/0e44d149-4863-47ec-8f0f-6a821ab3e77f/settings.json @@ -0,0 +1,19 @@ +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "", + "guid": "0e44d149-4863-47ec-8f0f-6a821ab3e77f", + "implements": null, + "load_selection": null, + "name": "ImportStatusInterface", + "power_version": "1.0.0", + "system_name": "VDM.ImportStatusInterface", + "type": "interface", + "use_selection": null, + "extendsinterfaces": null, + "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Interfaces.ImportStatusInterface", + "description": "Import Status 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 \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/21754a8b-2323-4a77-8459-378a74c1ec97/README.md b/src/21754a8b-2323-4a77-8459-378a74c1ec97/README.md new file mode 100644 index 0000000..1670158 --- /dev/null +++ b/src/21754a8b-2323-4a77-8459-378a74c1ec97/README.md @@ -0,0 +1,84 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# class Import (Details) +> namespace: **VDM\Joomla\Componentbuilder\Import\Service** + +```uml +@startuml +class Import #Gold { + + register(Container $container) : void + + getRow(Container $container) : Row + + getItem(Container $container) : Item + + getMessage(Container $container) : Message + + getStatus(Container $container) : Status +} + +note right of Import::register + Registers the service provider with a DI container. + + since: 5.0.3 + return: void +end note + +note right of Import::getRow + Get The Row Class. + + since: 5.0.3 + return: Row +end note + +note right of Import::getItem + Get The Item Class. + + since: 5.0.3 + return: Item +end note + +note right of Import::getMessage + Get The Message Class. + + since: 5.0.3 + return: Message +end note + +note right of Import::getStatus + Get The Status Class. + + since: 5.0.3 + return: Status +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---21754a8b_2323_4a77_8459_378a74c1ec97---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) + diff --git a/src/21754a8b-2323-4a77-8459-378a74c1ec97/code.php b/src/21754a8b-2323-4a77-8459-378a74c1ec97/code.php new file mode 100644 index 0000000..9fe5c78 --- /dev/null +++ b/src/21754a8b-2323-4a77-8459-378a74c1ec97/code.php @@ -0,0 +1,114 @@ + + * @git 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\Import\Service; + + +use Joomla\DI\Container; +use Joomla\DI\ServiceProviderInterface; +use VDM\Joomla\Componentbuilder\Import\Row; +use VDM\Joomla\Componentbuilder\Import\Item; +use VDM\Joomla\Componentbuilder\Import\Message; +use VDM\Joomla\Componentbuilder\Import\Status; + + +/** + * Import Service Provider + * + * @since 5.0.3 + */ +class Import implements ServiceProviderInterface +{ + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * @since 5.0.3 + */ + public function register(Container $container) + { + $container->alias(Row::class, 'Import.Row') + ->share('Import.Row', [$this, 'getRow'], true); + + $container->alias(Item::class, 'Import.Item') + ->share('Import.Item', [$this, 'getItem'], true); + + $container->alias(Message::class, 'Import.Message') + ->share('Import.Message', [$this, 'getMessage'], true); + + $container->alias(Status::class, 'Import.Status') + ->share('Import.Status', [$this, 'getStatus'], true); + } + + /** + * Get The Row Class. + * + * @param Container $container The DI container. + * + * @return Row + * @since 5.0.3 + */ + public function getRow(Container $container): Row + { + return new Row(); + } + + /** + * Get The Item Class. + * + * @param Container $container The DI container. + * + * @return Item + * @since 5.0.3 + */ + public function getItem(Container $container): Item + { + return new Item( + $container->get('Table.Validator'), + $container->get('Data.Item'), + $container->get('Import.Row') + ); + } + + /** + * Get The Message Class. + * + * @param Container $container The DI container. + * + * @return Message + * @since 5.0.3 + */ + public function getMessage(Container $container): Message + { + return new Message( + $container->get('Data.Update'), + $container->get('Data.Insert') + ); + } + + /** + * Get The Status Class. + * + * @param Container $container The DI container. + * + * @return Status + * @since 5.0.3 + */ + public function getStatus(Container $container): Status + { + return new Status( + $container->get('Data.Item') + ); + } +} + diff --git a/src/21754a8b-2323-4a77-8459-378a74c1ec97/code.power b/src/21754a8b-2323-4a77-8459-378a74c1ec97/code.power new file mode 100644 index 0000000..c717831 --- /dev/null +++ b/src/21754a8b-2323-4a77-8459-378a74c1ec97/code.power @@ -0,0 +1,83 @@ + /** + * Registers the service provider with a DI container. + * + * @param Container $container The DI container. + * + * @return void + * @since 5.0.3 + */ + public function register(Container $container) + { + $container->alias(Row::class, 'Import.Row') + ->share('Import.Row', [$this, 'getRow'], true); + + $container->alias(Item::class, 'Import.Item') + ->share('Import.Item', [$this, 'getItem'], true); + + $container->alias(Message::class, 'Import.Message') + ->share('Import.Message', [$this, 'getMessage'], true); + + $container->alias(Status::class, 'Import.Status') + ->share('Import.Status', [$this, 'getStatus'], true); + } + + /** + * Get The Row Class. + * + * @param Container $container The DI container. + * + * @return Row + * @since 5.0.3 + */ + public function getRow(Container $container): Row + { + return new Row(); + } + + /** + * Get The Item Class. + * + * @param Container $container The DI container. + * + * @return Item + * @since 5.0.3 + */ + public function getItem(Container $container): Item + { + return new Item( + $container->get('Table.Validator'), + $container->get('Data.Item'), + $container->get('Import.Row') + ); + } + + /** + * Get The Message Class. + * + * @param Container $container The DI container. + * + * @return Message + * @since 5.0.3 + */ + public function getMessage(Container $container): Message + { + return new Message( + $container->get('Data.Update'), + $container->get('Data.Insert') + ); + } + + /** + * Get The Status Class. + * + * @param Container $container The DI container. + * + * @return Status + * @since 5.0.3 + */ + public function getStatus(Container $container): Status + { + return new Status( + $container->get('Data.Item') + ); + } \ No newline at end of file diff --git a/src/21754a8b-2323-4a77-8459-378a74c1ec97/settings.json b/src/21754a8b-2323-4a77-8459-378a74c1ec97/settings.json new file mode 100644 index 0000000..efbd361 --- /dev/null +++ b/src/21754a8b-2323-4a77-8459-378a74c1ec97/settings.json @@ -0,0 +1,39 @@ +{ + "add_head": "1", + "add_licensing_template": "2", + "extends": "", + "guid": "21754a8b-2323-4a77-8459-378a74c1ec97", + "implements": [ + "-1" + ], + "load_selection": null, + "name": "Import", + "power_version": "1.0.0", + "system_name": "JCB.Import.Service.Import", + "type": "class", + "use_selection": { + "use_selection0": { + "use": "afb5b891-7130-422a-b389-1934b0e4fc48", + "as": "default" + }, + "use_selection1": { + "use": "68a0f9af-265a-4db1-bae9-a4e4531f94d7", + "as": "default" + }, + "use_selection2": { + "use": "eef6ffc2-2af0-4336-958f-e0b9cf7c4ad0", + "as": "default" + }, + "use_selection3": { + "use": "d2a859ac-3f2a-4f69-a77f-f118b2e0a459", + "as": "default" + } + }, + "extendsinterfaces": null, + "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Import.Service.Import", + "description": "Import Service Provider\r\n\r\n@since 5.0.3", + "implements_custom": "ServiceProviderInterface", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git 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\\DI\\Container;\r\nuse Joomla\\DI\\ServiceProviderInterface;", + "composer": "" +} \ No newline at end of file diff --git a/src/23ad6e72-1b82-40fb-836c-50da690bb174/README.md b/src/23ad6e72-1b82-40fb-836c-50da690bb174/README.md new file mode 100644 index 0000000..e7a45da --- /dev/null +++ b/src/23ad6e72-1b82-40fb-836c-50da690bb174/README.md @@ -0,0 +1,120 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# interface ImportMessageInterface (Details) +> namespace: **VDM\Joomla\Componentbuilder\Interfaces** + +```uml +@startuml +interface ImportMessageInterface #Lavender { + + load(string $guid, string $entity, ...) : self + + get() : object + + reset() : void + + archive() : self + + set() : self + + addSuccess(string $message) : self + + addInfo(string $message) : self + + addError(string $message) : self +} + +note right of ImportMessageInterface::load + Load an entity that these message belong to + + since: 3.0.2 + return: self + + arguments: + string $guid + string $entity + string $table +end note + +note left of ImportMessageInterface::get + Get the messages of the last import event + + since: 3.0.2 + return: object +end note + +note right of ImportMessageInterface::reset + Reset the messages of the last import event + + since: 3.0.2 + return: void +end note + +note left of ImportMessageInterface::archive + Archive the messages in the DB of the last import event + + since: 3.0.2 + return: self +end note + +note right of ImportMessageInterface::set + Set the messages in the DB of the last import event + + since: 3.0.2 + return: self +end note + +note left of ImportMessageInterface::addSuccess + Adds a success message to the log. +This method records a success message for the import process. The message provides +relevant information, such as the number of rows processed and the success rate. + + since: 3.0.2 + return: self +end note + +note right of ImportMessageInterface::addInfo + Adds a info message to the log. +This method records a info message for the import process. The message provides +relevant information, such as the number of rows processed and the info rate. + + since: 3.0.2 + return: self +end note + +note left of ImportMessageInterface::addError + Adds an error message to the log. +This method records an error message when the import process encounters issues. +The message includes details about the failures, such as the number of failed rows +and the corresponding error rate. + + since: 3.0.2 + return: self +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---23ad6e72_1b82_40fb_836c_50da690bb174---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) + diff --git a/src/23ad6e72-1b82-40fb-836c-50da690bb174/code.php b/src/23ad6e72-1b82-40fb-836c-50da690bb174/code.php new file mode 100644 index 0000000..0fba231 --- /dev/null +++ b/src/23ad6e72-1b82-40fb-836c-50da690bb174/code.php @@ -0,0 +1,109 @@ + + * @git 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\Interfaces; + + +/** + * Import Message Interface + * + * @since 3.0.2 + */ +interface ImportMessageInterface +{ + /** + * Load an entity that these message belong to + * + * @param string $guid The entity guid these messages must be linked to. + * @param string $entity The entity type these messages must be linked to. + * @param string $table The messages table where these message must be stored. + * + * @return self + * @throws \InvalidArgumentException if any of the parameters are null or empty. + * @since 3.0.2 + */ + public function load(string $guid, string $entity, string $table): self; + + /** + * Get the messages of the last import event + * + * @return object + * @since 3.0.2 + */ + public function get(): object; + + /** + * Reset the messages of the last import event + * + * @return void + * @since 3.0.2 + */ + public function reset(): void; + + /** + * Archive the messages in the DB of the last import event + * + * @return self + * @throws \InvalidArgumentException if GUID, entity, or table is null. + * @since 3.0.2 + */ + public function archive(): self; + + /** + * Set the messages in the DB of the last import event + * + * @return self + * @throws \InvalidArgumentException if GUID, entity, or table is null. + * @since 3.0.2 + */ + public function set(): self; + + /** + * Adds a success message to the log. + * + * This method records a success message for the import process. The message provides + * relevant information, such as the number of rows processed and the success rate. + * + * @param string $message The success message to log. + * + * @return self + * @since 3.0.2 + */ + public function addSuccess(string $message): self; + + /** + * Adds a info message to the log. + * + * This method records a info message for the import process. The message provides + * relevant information, such as the number of rows processed and the info rate. + * + * @param string $message The info message to log. + * + * @return self + * @since 3.0.2 + */ + public function addInfo(string $message): self; + + /** + * Adds an error message to the log. + * + * This method records an error message when the import process encounters issues. + * The message includes details about the failures, such as the number of failed rows + * and the corresponding error rate. + * + * @param string $message The error message to log. + * + * @return self + * @since 3.0.2 + */ + public function addError(string $message): self; +} + diff --git a/src/23ad6e72-1b82-40fb-836c-50da690bb174/code.power b/src/23ad6e72-1b82-40fb-836c-50da690bb174/code.power new file mode 100644 index 0000000..051583b --- /dev/null +++ b/src/23ad6e72-1b82-40fb-836c-50da690bb174/code.power @@ -0,0 +1,86 @@ + /** + * Load an entity that these message belong to + * + * @param string $guid The entity guid these messages must be linked to. + * @param string $entity The entity type these messages must be linked to. + * @param string $table The messages table where these message must be stored. + * + * @return self + * @throws \InvalidArgumentException if any of the parameters are null or empty. + * @since 3.0.2 + */ + public function load(string $guid, string $entity, string $table): self; + + /** + * Get the messages of the last import event + * + * @return object + * @since 3.0.2 + */ + public function get(): object; + + /** + * Reset the messages of the last import event + * + * @return void + * @since 3.0.2 + */ + public function reset(): void; + + /** + * Archive the messages in the DB of the last import event + * + * @return self + * @throws \InvalidArgumentException if GUID, entity, or table is null. + * @since 3.0.2 + */ + public function archive(): self; + + /** + * Set the messages in the DB of the last import event + * + * @return self + * @throws \InvalidArgumentException if GUID, entity, or table is null. + * @since 3.0.2 + */ + public function set(): self; + + /** + * Adds a success message to the log. + * + * This method records a success message for the import process. The message provides + * relevant information, such as the number of rows processed and the success rate. + * + * @param string $message The success message to log. + * + * @return self + * @since 3.0.2 + */ + public function addSuccess(string $message): self; + + /** + * Adds a info message to the log. + * + * This method records a info message for the import process. The message provides + * relevant information, such as the number of rows processed and the info rate. + * + * @param string $message The info message to log. + * + * @return self + * @since 3.0.2 + */ + public function addInfo(string $message): self; + + /** + * Adds an error message to the log. + * + * This method records an error message when the import process encounters issues. + * The message includes details about the failures, such as the number of failed rows + * and the corresponding error rate. + * + * @param string $message The error message to log. + * + * @return self + * @since 3.0.2 + */ + public function addError(string $message): self; \ No newline at end of file diff --git a/src/23ad6e72-1b82-40fb-836c-50da690bb174/settings.json b/src/23ad6e72-1b82-40fb-836c-50da690bb174/settings.json new file mode 100644 index 0000000..ce1492a --- /dev/null +++ b/src/23ad6e72-1b82-40fb-836c-50da690bb174/settings.json @@ -0,0 +1,19 @@ +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "", + "guid": "23ad6e72-1b82-40fb-836c-50da690bb174", + "implements": null, + "load_selection": null, + "name": "ImportMessageInterface", + "power_version": "1.0.0", + "system_name": "VDM.ImportMessageInterface", + "type": "interface", + "use_selection": null, + "extendsinterfaces": null, + "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Interfaces.ImportMessageInterface", + "description": "Import Message Interface\r\n\r\n@since 3.0.2", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/2da6d6c4-eb29-4d69-8bc2-36d96e916adf/README.md b/src/2da6d6c4-eb29-4d69-8bc2-36d96e916adf/README.md index 2acd73a..6628597 100644 --- a/src/2da6d6c4-eb29-4d69-8bc2-36d96e916adf/README.md +++ b/src/2da6d6c4-eb29-4d69-8bc2-36d96e916adf/README.md @@ -6,12 +6,12 @@ ██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ ╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ ``` -# interface Tableinterface (Details) +# interface TableInterface (Details) > namespace: **VDM\Joomla\Interfaces** ```uml @startuml -interface Tableinterface #Lavender { +interface TableInterface #Lavender { + get(?string $table = null, ?string $field = null, ...) : mixed + title(string $table) : ?array + titleName(string $table) : string @@ -20,7 +20,7 @@ interface Tableinterface #Lavender { + fields(string $table, bool $default = false, ...) : ?array } -note right of Tableinterface::get +note right of TableInterface::get Get any value from a item/field/column of an area/view/table Example: $this->get('table_name', 'field_name', 'value_key'); Get an item/field/column of an area/view/table @@ -40,35 +40,35 @@ Example: $this->get(); ?string $key = null end note -note right of Tableinterface::title +note right of TableInterface::title Get title field from an area/view/table since: 3.2.0 return: ?array end note -note right of Tableinterface::titleName +note right of TableInterface::titleName Get title field name since: 3.2.0 return: string end note -note right of Tableinterface::tables +note right of TableInterface::tables Get all tables since: 3.2.0 return: array end note -note right of Tableinterface::exist +note right of TableInterface::exist Check if a table (and field) exist since: 3.2.0 return: bool end note -note right of Tableinterface::fields +note right of TableInterface::fields Get all fields of an area/view/table since: 3.2.0 diff --git a/src/2da6d6c4-eb29-4d69-8bc2-36d96e916adf/code.php b/src/2da6d6c4-eb29-4d69-8bc2-36d96e916adf/code.php index a7cef07..6f3d7cd 100644 --- a/src/2da6d6c4-eb29-4d69-8bc2-36d96e916adf/code.php +++ b/src/2da6d6c4-eb29-4d69-8bc2-36d96e916adf/code.php @@ -15,7 +15,7 @@ namespace VDM\Joomla\Interfaces; /** * The VDM Core Table Interface */ -interface Tableinterface +interface TableInterface { /** * Get any value from a item/field/column of an area/view/table diff --git a/src/2da6d6c4-eb29-4d69-8bc2-36d96e916adf/settings.json b/src/2da6d6c4-eb29-4d69-8bc2-36d96e916adf/settings.json index 1b25664..d31e1f5 100644 --- a/src/2da6d6c4-eb29-4d69-8bc2-36d96e916adf/settings.json +++ b/src/2da6d6c4-eb29-4d69-8bc2-36d96e916adf/settings.json @@ -5,13 +5,13 @@ "guid": "2da6d6c4-eb29-4d69-8bc2-36d96e916adf", "implements": null, "load_selection": null, - "name": "Tableinterface", + "name": "TableInterface", "power_version": "1.0.0", - "system_name": "VDM.Interfaces.Tableinterface", + "system_name": "VDM.Interfaces.TableInterface", "type": "interface", "use_selection": null, "extendsinterfaces": null, - "namespace": "[[[NamespacePrefix]]]\\Joomla\\Interfaces.Tableinterface", + "namespace": "[[[NamespacePrefix]]]\\Joomla\\Interfaces.TableInterface", "description": "The VDM Core Table Interface", "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git 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": "", diff --git a/src/3d3ec064-9867-41e6-a48a-964c15d753aa/README.md b/src/3d3ec064-9867-41e6-a48a-964c15d753aa/README.md new file mode 100644 index 0000000..9d4c4f9 --- /dev/null +++ b/src/3d3ec064-9867-41e6-a48a-964c15d753aa/README.md @@ -0,0 +1,84 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# interface ImportRowInterface (Details) +> namespace: **VDM\Joomla\Componentbuilder\Interfaces** + +```uml +@startuml +interface ImportRowInterface #Lavender { + + set(int $index, array $values) : void + + clear() : self + + getIndex() : int + + getValue(string $key) : mixed + + unsetValue(string $key) : void +} + +note right of ImportRowInterface::set + Set the row details + + since: 3.0.3 + return: void +end note + +note right of ImportRowInterface::clear + Clear the row details + + since: 3.0.3 + return: self +end note + +note right of ImportRowInterface::getIndex + Get Index + + since: 3.0.3 + return: int +end note + +note right of ImportRowInterface::getValue + Get Value + + since: 3.0.3 + return: mixed +end note + +note right of ImportRowInterface::unsetValue + Unset Value + + since: 3.0.3 + return: void +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---3d3ec064_9867_41e6_a48a_964c15d753aa---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) + diff --git a/src/3d3ec064-9867-41e6-a48a-964c15d753aa/code.php b/src/3d3ec064-9867-41e6-a48a-964c15d753aa/code.php new file mode 100644 index 0000000..e611e36 --- /dev/null +++ b/src/3d3ec064-9867-41e6-a48a-964c15d753aa/code.php @@ -0,0 +1,68 @@ + + * @git 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\Interfaces; + + +/** + * Import Row Interface + * + * @since 3.0.3 + */ +interface ImportRowInterface +{ + /** + * Set the row details + * + * @param int $index The row index + * @param array $values The values + * + * @return void + * @since 3.0.3 + */ + public function set(int $index, array $values): void; + + /** + * Clear the row details + * + * @return self + * @since 3.0.3 + */ + public function clear(): self; + + /** + * Get Index + * + * @return int + * @throws \InvalidArgumentException if any of the parameters are null or empty. + * @since 3.0.3 + */ + public function getIndex(): int; + + /** + * Get Value + * + * @return mixed + * @throws \InvalidArgumentException if any of the parameters are null or empty. + * @since 3.0.3 + */ + public function getValue(string $key); + + /** + * Unset Value + * + * @return void + * @throws \InvalidArgumentException if any of the parameters are null or empty. + * @since 3.0.3 + */ + public function unsetValue(string $key): void; +} + diff --git a/src/3d3ec064-9867-41e6-a48a-964c15d753aa/code.power b/src/3d3ec064-9867-41e6-a48a-964c15d753aa/code.power new file mode 100644 index 0000000..41ca0da --- /dev/null +++ b/src/3d3ec064-9867-41e6-a48a-964c15d753aa/code.power @@ -0,0 +1,45 @@ + /** + * Set the row details + * + * @param int $index The row index + * @param array $values The values + * + * @return void + * @since 3.0.3 + */ + public function set(int $index, array $values): void; + + /** + * Clear the row details + * + * @return self + * @since 3.0.3 + */ + public function clear(): self; + + /** + * Get Index + * + * @return int + * @throws \InvalidArgumentException if any of the parameters are null or empty. + * @since 3.0.3 + */ + public function getIndex(): int; + + /** + * Get Value + * + * @return mixed + * @throws \InvalidArgumentException if any of the parameters are null or empty. + * @since 3.0.3 + */ + public function getValue(string $key); + + /** + * Unset Value + * + * @return void + * @throws \InvalidArgumentException if any of the parameters are null or empty. + * @since 3.0.3 + */ + public function unsetValue(string $key): void; \ No newline at end of file diff --git a/src/3d3ec064-9867-41e6-a48a-964c15d753aa/settings.json b/src/3d3ec064-9867-41e6-a48a-964c15d753aa/settings.json new file mode 100644 index 0000000..01b7129 --- /dev/null +++ b/src/3d3ec064-9867-41e6-a48a-964c15d753aa/settings.json @@ -0,0 +1,19 @@ +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "", + "guid": "3d3ec064-9867-41e6-a48a-964c15d753aa", + "implements": null, + "load_selection": null, + "name": "ImportRowInterface", + "power_version": "1.0.0", + "system_name": "VDM.ImportRowInterface", + "type": "interface", + "use_selection": null, + "extendsinterfaces": null, + "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Interfaces.ImportRowInterface", + "description": "Import Row Interface\r\n\r\n@since 3.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 \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/53f55e5b-63cb-49e7-b1e6-33e7a9f97856/README.md b/src/53f55e5b-63cb-49e7-b1e6-33e7a9f97856/README.md new file mode 100644 index 0000000..58e15cd --- /dev/null +++ b/src/53f55e5b-63cb-49e7-b1e6-33e7a9f97856/README.md @@ -0,0 +1,52 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# interface ImportItemInterface (Details) +> namespace: **VDM\Joomla\Componentbuilder\Interfaces** + +```uml +@startuml +interface ImportItemInterface #Lavender { + + get(string $table, array $columns) : ?array +} + +note right of ImportItemInterface::get + Get the item from the import row values and ensure it is valid + + since: 4.0.3 + return: ?array +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---53f55e5b_63cb_49e7_b1e6_33e7a9f97856---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) + diff --git a/src/53f55e5b-63cb-49e7-b1e6-33e7a9f97856/code.php b/src/53f55e5b-63cb-49e7-b1e6-33e7a9f97856/code.php new file mode 100644 index 0000000..28ebff6 --- /dev/null +++ b/src/53f55e5b-63cb-49e7-b1e6-33e7a9f97856/code.php @@ -0,0 +1,33 @@ + + * @git 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\Interfaces; + + +/** + * Import Item Interface + * + * @since 3.0.3 + */ +interface ImportItemInterface +{ + /** + * Get the item from the import row values and ensure it is valid + * + * @param string $table The table these columns belongs to. + * @param array $columns The columns to extract. + * + * @return array|null + * @since 4.0.3 + */ + public function get(string $table, array $columns): ?array; +} + diff --git a/src/53f55e5b-63cb-49e7-b1e6-33e7a9f97856/code.power b/src/53f55e5b-63cb-49e7-b1e6-33e7a9f97856/code.power new file mode 100644 index 0000000..d86c772 --- /dev/null +++ b/src/53f55e5b-63cb-49e7-b1e6-33e7a9f97856/code.power @@ -0,0 +1,10 @@ + /** + * Get the item from the import row values and ensure it is valid + * + * @param string $table The table these columns belongs to. + * @param array $columns The columns to extract. + * + * @return array|null + * @since 4.0.3 + */ + public function get(string $table, array $columns): ?array; \ No newline at end of file diff --git a/src/53f55e5b-63cb-49e7-b1e6-33e7a9f97856/settings.json b/src/53f55e5b-63cb-49e7-b1e6-33e7a9f97856/settings.json new file mode 100644 index 0000000..55a2d8f --- /dev/null +++ b/src/53f55e5b-63cb-49e7-b1e6-33e7a9f97856/settings.json @@ -0,0 +1,19 @@ +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "", + "guid": "53f55e5b-63cb-49e7-b1e6-33e7a9f97856", + "implements": null, + "load_selection": null, + "name": "ImportItemInterface", + "power_version": "1.0.0", + "system_name": "VDM.ImportItemInterface", + "type": "interface", + "use_selection": null, + "extendsinterfaces": null, + "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Interfaces.ImportItemInterface", + "description": "Import Item Interface\r\n\r\n@since 3.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 \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/584747d1-3a86-453d-b7a3-a2219de8d777/code.php b/src/584747d1-3a86-453d-b7a3-a2219de8d777/code.php index ccd4d40..1f6606c 100644 --- a/src/584747d1-3a86-453d-b7a3-a2219de8d777/code.php +++ b/src/584747d1-3a86-453d-b7a3-a2219de8d777/code.php @@ -14,7 +14,7 @@ namespace VDM\Joomla\Abstraction; use VDM\Joomla\Utilities\StringHelper; use VDM\Joomla\Utilities\ArrayHelper; -use VDM\Joomla\Interfaces\Tableinterface as Table; +use VDM\Joomla\Interfaces\TableInterface as Table; use VDM\Joomla\Interfaces\ModelInterface; diff --git a/src/5f0205fa-5c43-424a-af7d-abc943c17c8c/code.php b/src/5f0205fa-5c43-424a-af7d-abc943c17c8c/code.php index aad47d7..6c6aef2 100644 --- a/src/5f0205fa-5c43-424a-af7d-abc943c17c8c/code.php +++ b/src/5f0205fa-5c43-424a-af7d-abc943c17c8c/code.php @@ -14,7 +14,7 @@ namespace VDM\Joomla\Abstraction; use Joomla\CMS\Factory; use VDM\Joomla\Interfaces\SchemaInterface as Schema; -use VDM\Joomla\Interfaces\Tableinterface as Table; +use VDM\Joomla\Interfaces\TableInterface as Table; use VDM\Joomla\Utilities\ClassHelper; use VDM\Joomla\Interfaces\SchemaCheckerInterface; diff --git a/src/68a0f9af-265a-4db1-bae9-a4e4531f94d7/README.md b/src/68a0f9af-265a-4db1-bae9-a4e4531f94d7/README.md new file mode 100644 index 0000000..18cd6ba --- /dev/null +++ b/src/68a0f9af-265a-4db1-bae9-a4e4531f94d7/README.md @@ -0,0 +1,134 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class Item (Details) +> namespace: **VDM\Joomla\Componentbuilder\Import** + +```uml +@startuml +class Item << (F,LightGreen) >> #RoyalBlue { + # Validator $validator + # Item $item + # Row $row + + __construct(Validator $validator, Item $item, ...) + + get(string $table, array $columns) : ?array + - getImportValue(mixed $value, string $field, ...) : mixed + - validImportValue(mixed $value, string $field, ...) : mixed + - getLocalValue(mixed $value, array $link) : mixed|null + - isValueExists(mixed $value, array $link) : bool + - setLocalValue(mixed $value, array $link) : mixed|null + - insertItemWithGuid(mixed $value, array $link) : ?string + - insertItemWithId(mixed $value, array $link) : mixed|null +} + +note right of Item::__construct + Constructor. + + since: 4.0.3 + + arguments: + Validator $validator + Item $item + Row $row +end note + +note left of Item::get + Get the item from the import row values and ensure it is valid + + since: 4.0.3 + return: ?array +end note + +note right of Item::getImportValue + Get the correct value needed for the import of the related row (item). + + since: 4.0.3 + return: mixed + + arguments: + mixed $value + string $field + string $table + ?array $link +end note + +note left of Item::validImportValue + Make sure we have a valid import value + + since: 4.0.3 + return: mixed + + arguments: + mixed $value + string $field + string $table +end note + +note right of Item::getLocalValue + Helper function to get the local value from the database table. + + since: 4.0.3 + return: mixed|null +end note + +note left of Item::isValueExists + Check if the value exists in the table for the given link. + + since: 4.0.3 + return: bool +end note + +note right of Item::setLocalValue + Create a new value in the database table if it doesn't already exist. + + since: 4.0.3 + return: mixed|null +end note + +note left of Item::insertItemWithGuid + Insert a new item with a GUID. + + since: 4.0.3 + return: ?string +end note + +note right of Item::insertItemWithId + Insert a new item with a non-numeric ID. + + since: 4.0.3 + return: mixed|null +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---68a0f9af_265a_4db1_bae9_a4e4531f94d7---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) + diff --git a/src/68a0f9af-265a-4db1-bae9-a4e4531f94d7/code.php b/src/68a0f9af-265a-4db1-bae9-a4e4531f94d7/code.php new file mode 100644 index 0000000..692e35b --- /dev/null +++ b/src/68a0f9af-265a-4db1-bae9-a4e4531f94d7/code.php @@ -0,0 +1,269 @@ + + * @git 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\Import; + + +use VDM\Joomla\Interfaces\TableValidatorInterface as Validator; +use VDM\Joomla\Interfaces\Data\ItemInterface as Item; +use VDM\Joomla\Componentbuilder\Interfaces\ImportRowInterface as Row; +use VDM\Joomla\Componentbuilder\Interfaces\ImportItemInterface; + + +/** + * Import Item Class + * + * @since 4.0.3 + */ +final class Item implements ImportItemInterface +{ + /** + * The Table Validator Class. + * + * @var Validator + * @since 4.0.3 + */ + protected Validator $validator; + + /** + * The Item Class. + * + * @var Item + * @since 4.0.3 + */ + protected Item $item; + + /** + * The Import Row Class. + * + * @var Row + * @since 4.0.3 + */ + protected Row $row; + + /** + * Constructor. + * + * @param Validator $validator The Table ValidatorI Class. + * @param Item $item The Item Class. + * @param Row $row The Import Row Class. + * + * @since 4.0.3 + */ + public function __construct(Validator $validator, Item $item, Row $row) + { + $this->validator = $validator; + $this->item = $item; + $this->row = $row; + } + + /** + * Get the item from the import row values and ensure it is valid + * + * @param string $table The table these columns belongs to. + * @param array $columns The columns to extract. + * + * @return array|null + * @since 4.0.3 + */ + public function get(string $table, array $columns): ?array + { + $item = []; + foreach ($columns as $column => $map) + { + if (($value = $this->row->getValue($column)) !== null && !isset($item[$map['name']])) + { + // get the valid importable value + $item[$map['name']] = $this->getImportValue($value, $map['name'], $table, $map['link'] ?? null); + + // remove value from global row values set + $this->row->unsetValue($column); + } + } + + return $item ?? null; + } + + /** + * Get the correct value needed for the import of the related row (item). + * + * @param mixed $value The value from the row. + * @param string $field The field name where the value is being stored. + * @param string $table The table this field belongs to. + * @param array $link The field link values. + * + * @return mixed + * @since 4.0.3 + */ + private function getImportValue($value, string $field, string $table, ?array $link) + { + // Validate the link array and return the original value if invalid + if (empty($link) || $link['type'] !== 1 || empty($link['table']) || empty($link['key']) || empty($link['value'])) + { + return $this->validImportValue($value, $field, $table); + } + + // Handle GUID key with validation via GuidHelper + if ($link['key'] === 'guid' && GuidHelper::item($value, $link['table'])) + { + return $value; + } + + // Handle numeric ID with validation + if ($link['key'] === 'id' && is_numeric($value) && $this->isValueExists($value, $link)) + { + return (int) $value; + } + + // Attempt to retrieve the local value + $local_value = $this->getLocalValue($value, $link); + + // If no local value exists, create it if necessary + if ($local_value === null) + { + $local_value = $this->setLocalValue($value, $link); + } + + return $this->validImportValue($local_value, $field, $table); + } + + /** + * Make sure we have a valid import value + * + * @param mixed $value The value. + * @param string $field The field name where the value is being stored. + * @param string $table The table this field belongs to. + * + * @return mixed + * @since 4.0.3 + */ + private function validImportValue($value, string $field, string $table) + { + // make sure our value will fit in the database table datatype + return $this->validator->getValid($value, $field, $table); + } + + /** + * Helper function to get the local value from the database table. + * + * @param mixed $value The value to search for. + * @param array $link The field link details. + * + * @return mixed|null The local value or null if not found. + * @since 4.0.3 + */ + private function getLocalValue($value, array $link) + { + // Attempt to retrieve the value based on the link['value'] and link['key'] + $local_value = $this->item->table($link['table'])->value($value, $link['value'], $link['key']); + + // If not found, try retrieving by link['key'] and link['key'] + if ($local_value === null && $this->isValueExists($value, $link)) + { + return $value; + } + + return $local_value; + } + + /** + * Check if the value exists in the table for the given link. + * + * @param mixed $value The value to check. + * @param array $link The field link details. + * + * @return bool True if the value exists, false otherwise. + * @since 4.0.3 + */ + private function isValueExists($value, array $link): bool + { + return $this->item->table($link['table'])->value($value, $link['key'], $link['key']) !== null; + } + + /** + * Create a new value in the database table if it doesn't already exist. + * + * @param mixed $value The value to create. + * @param array $link The field link details. + * + * @return mixed|null The newly created value or null if creation failed. + * @since 4.0.3 + */ + private function setLocalValue($value, array $link) + { + // Handle GUID creation if the provided value is not valid + if ($link['key'] === 'guid') + { + if (!GuidHelper::valid($value)) + { + return $this->insertItemWithGuid($value, $link); + } + return null; + } + + // Handle ID creation + if ($link['key'] === 'id') + { + if (!is_numeric($value)) + { + return $this->insertItemWithId($value, $link); + } + return null; + } + + // could not create local item (we don't have enough details) + return null; + } + + /** + * Insert a new item with a GUID. + * + * @param mixed $value The value to insert. + * @param array $link The field link details. + * + * @return string|null The new GUID or null if insertion failed. + * @since 4.0.3 + */ + private function insertItemWithGuid($value, array $link): ?string + { + $guid = GuidHelper::get(); + $item = (object) [$link['value'] => $value, $link['key'] => $guid]; + + if ($this->item->table($link['table'])->set($item, $link['key'], 'insert')) + { + return $guid; + } + + return null; + } + + /** + * Insert a new item with a non-numeric ID. + * + * @param mixed $value The value to insert. + * @param array $link The field link details. + * + * @return mixed|null The new ID or null if insertion failed. + * @since 4.0.3 + */ + private function insertItemWithId($value, array $link) + { + $item = (object) [$link['key'] => 0, $link['value'] => $value]; + + if ($this->item->table($link['table'])->set($item, $link['key'], 'insert')) + { + return $this->item->table($link['table'])->value($value, $link['value'], $link['key']); + } + + return null; + } +} + diff --git a/src/68a0f9af-265a-4db1-bae9-a4e4531f94d7/code.power b/src/68a0f9af-265a-4db1-bae9-a4e4531f94d7/code.power new file mode 100644 index 0000000..2036c53 --- /dev/null +++ b/src/68a0f9af-265a-4db1-bae9-a4e4531f94d7/code.power @@ -0,0 +1,240 @@ + /** + * The Table Validator Class. + * + * @var Validator + * @since 4.0.3 + */ + protected Validator $validator; + + /** + * The Item Class. + * + * @var Item + * @since 4.0.3 + */ + protected Item $item; + + /** + * The Import Row Class. + * + * @var Row + * @since 4.0.3 + */ + protected Row $row; + + /** + * Constructor. + * + * @param Validator $validator The Table ValidatorI Class. + * @param Item $item The Item Class. + * @param Row $row The Import Row Class. + * + * @since 4.0.3 + */ + public function __construct(Validator $validator, Item $item, Row $row) + { + $this->validator = $validator; + $this->item = $item; + $this->row = $row; + } + + /** + * Get the item from the import row values and ensure it is valid + * + * @param string $table The table these columns belongs to. + * @param array $columns The columns to extract. + * + * @return array|null + * @since 4.0.3 + */ + public function get(string $table, array $columns): ?array + { + $item = []; + foreach ($columns as $column => $map) + { + if (($value = $this->row->getValue($column)) !== null && !isset($item[$map['name']])) + { + // get the valid importable value + $item[$map['name']] = $this->getImportValue($value, $map['name'], $table, $map['link'] ?? null); + + // remove value from global row values set + $this->row->unsetValue($column); + } + } + + return $item ?? null; + } + + /** + * Get the correct value needed for the import of the related row (item). + * + * @param mixed $value The value from the row. + * @param string $field The field name where the value is being stored. + * @param string $table The table this field belongs to. + * @param array $link The field link values. + * + * @return mixed + * @since 4.0.3 + */ + private function getImportValue($value, string $field, string $table, ?array $link) + { + // Validate the link array and return the original value if invalid + if (empty($link) || $link['type'] !== 1 || empty($link['table']) || empty($link['key']) || empty($link['value'])) + { + return $this->validImportValue($value, $field, $table); + } + + // Handle GUID key with validation via GuidHelper + if ($link['key'] === 'guid' && GuidHelper::item($value, $link['table'])) + { + return $value; + } + + // Handle numeric ID with validation + if ($link['key'] === 'id' && is_numeric($value) && $this->isValueExists($value, $link)) + { + return (int) $value; + } + + // Attempt to retrieve the local value + $local_value = $this->getLocalValue($value, $link); + + // If no local value exists, create it if necessary + if ($local_value === null) + { + $local_value = $this->setLocalValue($value, $link); + } + + return $this->validImportValue($local_value, $field, $table); + } + + /** + * Make sure we have a valid import value + * + * @param mixed $value The value. + * @param string $field The field name where the value is being stored. + * @param string $table The table this field belongs to. + * + * @return mixed + * @since 4.0.3 + */ + private function validImportValue($value, string $field, string $table) + { + // make sure our value will fit in the database table datatype + return $this->validator->getValid($value, $field, $table); + } + + /** + * Helper function to get the local value from the database table. + * + * @param mixed $value The value to search for. + * @param array $link The field link details. + * + * @return mixed|null The local value or null if not found. + * @since 4.0.3 + */ + private function getLocalValue($value, array $link) + { + // Attempt to retrieve the value based on the link['value'] and link['key'] + $local_value = $this->item->table($link['table'])->value($value, $link['value'], $link['key']); + + // If not found, try retrieving by link['key'] and link['key'] + if ($local_value === null && $this->isValueExists($value, $link)) + { + return $value; + } + + return $local_value; + } + + /** + * Check if the value exists in the table for the given link. + * + * @param mixed $value The value to check. + * @param array $link The field link details. + * + * @return bool True if the value exists, false otherwise. + * @since 4.0.3 + */ + private function isValueExists($value, array $link): bool + { + return $this->item->table($link['table'])->value($value, $link['key'], $link['key']) !== null; + } + + /** + * Create a new value in the database table if it doesn't already exist. + * + * @param mixed $value The value to create. + * @param array $link The field link details. + * + * @return mixed|null The newly created value or null if creation failed. + * @since 4.0.3 + */ + private function setLocalValue($value, array $link) + { + // Handle GUID creation if the provided value is not valid + if ($link['key'] === 'guid') + { + if (!GuidHelper::valid($value)) + { + return $this->insertItemWithGuid($value, $link); + } + return null; + } + + // Handle ID creation + if ($link['key'] === 'id') + { + if (!is_numeric($value)) + { + return $this->insertItemWithId($value, $link); + } + return null; + } + + // could not create local item (we don't have enough details) + return null; + } + + /** + * Insert a new item with a GUID. + * + * @param mixed $value The value to insert. + * @param array $link The field link details. + * + * @return string|null The new GUID or null if insertion failed. + * @since 4.0.3 + */ + private function insertItemWithGuid($value, array $link): ?string + { + $guid = GuidHelper::get(); + $item = (object) [$link['value'] => $value, $link['key'] => $guid]; + + if ($this->item->table($link['table'])->set($item, $link['key'], 'insert')) + { + return $guid; + } + + return null; + } + + /** + * Insert a new item with a non-numeric ID. + * + * @param mixed $value The value to insert. + * @param array $link The field link details. + * + * @return mixed|null The new ID or null if insertion failed. + * @since 4.0.3 + */ + private function insertItemWithId($value, array $link) + { + $item = (object) [$link['key'] => 0, $link['value'] => $value]; + + if ($this->item->table($link['table'])->set($item, $link['key'], 'insert')) + { + return $this->item->table($link['table'])->value($value, $link['value'], $link['key']); + } + + return null; + } \ No newline at end of file diff --git a/src/68a0f9af-265a-4db1-bae9-a4e4531f94d7/settings.json b/src/68a0f9af-265a-4db1-bae9-a4e4531f94d7/settings.json new file mode 100644 index 0000000..f53b834 --- /dev/null +++ b/src/68a0f9af-265a-4db1-bae9-a4e4531f94d7/settings.json @@ -0,0 +1,34 @@ +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "", + "guid": "68a0f9af-265a-4db1-bae9-a4e4531f94d7", + "implements": [ + "53f55e5b-63cb-49e7-b1e6-33e7a9f97856" + ], + "load_selection": null, + "name": "Item", + "power_version": "1.0.0", + "system_name": "JCB.Import.Item", + "type": "final class", + "use_selection": { + "use_selection0": { + "use": "feb3affa-5102-4307-93db-04525f4c66f0", + "as": "Validator" + }, + "use_selection1": { + "use": "05744dd3-4030-4cf8-8dda-a93ab809b473", + "as": "Item" + }, + "use_selection2": { + "use": "3d3ec064-9867-41e6-a48a-964c15d753aa", + "as": "Row" + } + }, + "extendsinterfaces": null, + "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Import.Item", + "description": "Import Item 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 \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/79fd4f39-824d-4ab6-936d-959705ff24ec/README.md b/src/79fd4f39-824d-4ab6-936d-959705ff24ec/README.md index 9e678d3..79932c0 100644 --- a/src/79fd4f39-824d-4ab6-936d-959705ff24ec/README.md +++ b/src/79fd4f39-824d-4ab6-936d-959705ff24ec/README.md @@ -14,12 +14,15 @@ class Validator << (F,LightGreen) >> #RoyalBlue { # Table $table # array $validators + # array $defaults + __construct(Table $table) + getValid(mixed $value, string $field, ...) : mixed - validate(mixed $value, array $dbField) : bool - - getDefault(array $dbField) : mixed + - getDefault(array $dbField, mixed $value) : mixed - parseDataType(string $datatype) : array - getDatabaseField(string $field, string $table) : array + - registerValidators() : void + - registerDefaults() : void - validateInteger(mixed $value, array $typeInfo) : bool - validateString(mixed $value, array $typeInfo) : bool - validateText(mixed $value, array $typeInfo) : bool @@ -80,6 +83,20 @@ In your case, you use `$db = $this->table->get($table, $field, 'db')`. return: array end note +note right of Validator::registerValidators + Register validators for MySQL data types. + + since: 5.3.0 + return: void +end note + +note left of Validator::registerDefaults + Register default values for MySQL data types. + + since: 5.3.0 + return: void +end note + note right of Validator::validateInteger Validate integer types (including tinyint, smallint, mediumint, etc.). diff --git a/src/79fd4f39-824d-4ab6-936d-959705ff24ec/code.php b/src/79fd4f39-824d-4ab6-936d-959705ff24ec/code.php index 887a066..d56dd9d 100644 --- a/src/79fd4f39-824d-4ab6-936d-959705ff24ec/code.php +++ b/src/79fd4f39-824d-4ab6-936d-959705ff24ec/code.php @@ -13,6 +13,7 @@ namespace VDM\Joomla\Componentbuilder\Table; use VDM\Joomla\Componentbuilder\Table; +use VDM\Joomla\Interfaces\TableValidatorInterface; /** @@ -20,7 +21,7 @@ use VDM\Joomla\Componentbuilder\Table; * * @since 5.3.0 */ -final class Validator +final class Validator implements TableValidatorInterface { /** * The Table Class. @@ -38,6 +39,14 @@ final class Validator */ protected array $validators = []; + /** + * A map of defauts for the respective datatypes. + * + * @var array + * @since 5.3.0 + */ + protected array $defaults = []; + /** * Constructor. * @@ -50,28 +59,10 @@ final class Validator $this->table = $table; // Register datatype validators (mapping MySQL types to handlers) - $this->validators = [ - 'int' => [$this, 'validateInteger'], - 'tinyint' => [$this, 'validateInteger'], - 'smallint' => [$this, 'validateInteger'], - 'mediumint' => [$this, 'validateInteger'], - 'bigint' => [$this, 'validateInteger'], - 'varchar' => [$this, 'validateString'], - 'char' => [$this, 'validateString'], - 'text' => [$this, 'validateText'], - 'tinytext' => [$this, 'validateText'], - 'mediumtext' => [$this, 'validateText'], - 'longtext' => [$this, 'validateText'], - 'decimal' => [$this, 'validateDecimal'], - 'float' => [$this, 'validateFloat'], - 'double' => [$this, 'validateFloat'], - 'date' => [$this, 'validateDate'], - 'datetime' => [$this, 'validateDate'], - 'timestamp' => [$this, 'validateDate'], - 'time' => [$this, 'validateDate'], - 'json' => [$this, 'validateJson'], - 'blob' => [$this, 'validateBlob'], - ]; + $this->registerValidators(); + + // Register datatype defaults + $this->registerDefaults(); } /** @@ -79,9 +70,9 @@ final class Validator * If the value is valid, return it. If not, return the default value, * NULL (if allowed), or an empty string if 'EMPTY' is set. * - * @param mixed $value The value to validate. - * @param string $field The field name. - * @param string $table The table name. + * @param mixed $value The value to validate. + * @param string $field The field name. + * @param string $table The table name. * * @return mixed Returns the valid value, or the default, NULL, or empty string based on validation. * @since 5.3.0 @@ -101,15 +92,15 @@ final class Validator } // If invalid, return default, NULL (if allowed), or empty string - return $this->getDefault($dbField); + return $this->getDefault($dbField, $value); } /** * Validate if the given value is valid for the provided database field. * This is a private method as `getValid()` will handle the actual logic. * - * @param mixed $value The value to validate. - * @param array $dbField The database field details (type, default, null_switch, etc.). + * @param mixed $value The value to validate. + * @param array $dbField The database field details (type, default, null_switch, etc.). * * @return bool Returns true if the value is valid, false otherwise. * @since 5.3.0 @@ -133,17 +124,21 @@ final class Validator /** * Handle returning the default value, null, or empty string if validation fails. * - * @param array $dbField The database field details. + * @param array $dbField The database field details. + * @param mixed $value The value to validate. * * @return mixed The default value, null, or empty string based on field settings. * @since 5.3.0 */ - private function getDefault(array $dbField) + private function getDefault(array $dbField, $value) { + // get default value from field db + $db_default = isset($dbField['default']) ? $dbField['default'] : null; + // If a default value is provided, return it - if (!empty($dbField['default'])) + if ($db_default !== null) { - return strtoupper($dbField['default']) === 'EMPTY' ? '' : $dbField['default']; + return strtoupper($db_default) === 'EMPTY' ? '' : $db_default; } // Check if NULL is allowed @@ -152,8 +147,9 @@ final class Validator return null; } - // If no default value, return an empty string - return ''; + // Fallback to datatype default + $typeInfo = $this->parseDataType($dbField['type']); + return $this->defaults[$typeInfo['type']] ?? ''; } /** @@ -180,8 +176,8 @@ final class Validator * Retrieve the database field structure for the specified field and table. * In your case, you use `$db = $this->table->get($table, $field, 'db')`. * - * @param string $field The field name. - * @param string $table The table name. + * @param string $field The field name. + * @param string $table The table name. * * @return array The database field details, including type, default, null_switch, etc. * @since 5.3.0 @@ -192,12 +188,82 @@ final class Validator return $this->table->get($table, $field, 'db'); } + /** + * Register validators for MySQL data types. + * + * @return void + * @since 5.3.0 + */ + private function registerValidators(): void + { + $this->validators = [ + 'int' => [$this, 'validateInteger'], + 'tinyint' => [$this, 'validateInteger'], + 'smallint' => [$this, 'validateInteger'], + 'mediumint' => [$this, 'validateInteger'], + 'bigint' => [$this, 'validateInteger'], + 'varchar' => [$this, 'validateString'], + 'char' => [$this, 'validateString'], + 'text' => [$this, 'validateText'], + 'tinytext' => [$this, 'validateText'], + 'mediumtext' => [$this, 'validateText'], + 'longtext' => [$this, 'validateText'], + 'decimal' => [$this, 'validateDecimal'], + 'float' => [$this, 'validateFloat'], + 'double' => [$this, 'validateFloat'], + 'date' => [$this, 'validateDate'], + 'datetime' => [$this, 'validateDate'], + 'timestamp' => [$this, 'validateDate'], + 'time' => [$this, 'validateDate'], + 'json' => [$this, 'validateJson'], + 'blob' => [$this, 'validateBlob'], + 'tinyblob' => [$this, 'validateBlob'], + 'mediumblob' => [$this, 'validateBlob'], + 'longblob' => [$this, 'validateBlob'], + ]; + } + + /** + * Register default values for MySQL data types. + * + * @return void + * @since 5.3.0 + */ + private function registerDefaults(): void + { + $this->defaults = [ + 'int' => 0, + 'tinyint' => 0, + 'smallint' => 0, + 'mediumint' => 0, + 'bigint' => 0, + 'varchar' => '', + 'char' => '', + 'text' => '', + 'tinytext' => '', + 'mediumtext' => '', + 'longtext' => '', + 'decimal' => 0.0, + 'float' => 0.0, + 'double' => 0.0, + 'date' => '0000-00-00', + 'datetime' => '0000-00-00 00:00:00', + 'timestamp' => '0000-00-00 00:00:00', + 'time' => '00:00:00', + 'json' => '{}', + 'blob' => '', + 'tinyblob' => '', + 'mediumblob' => '', + 'longblob' => '', + ]; + } + // ----------------- Validation Methods ----------------- /** * Validate integer types (including tinyint, smallint, mediumint, etc.). * - * @param mixed $value The value to validate. + * @param mixed $value The value to validate. * @param array $typeInfo The parsed data type information. * * @return bool True if valid, false otherwise. @@ -222,7 +288,7 @@ final class Validator /** * Validate string types like VARCHAR and CHAR. * - * @param mixed $value The value to validate. + * @param mixed $value The value to validate. * @param array $typeInfo The parsed data type information. * * @return bool True if valid, false otherwise. @@ -247,7 +313,7 @@ final class Validator /** * Validate text types like TEXT, TINYTEXT, MEDIUMTEXT, LONGTEXT. * - * @param mixed $value The value to validate. + * @param mixed $value The value to validate. * @param array $typeInfo The parsed data type information. * * @return bool True if valid, false otherwise. @@ -261,7 +327,7 @@ final class Validator /** * Validate float, double, and decimal types. * - * @param mixed $value The value to validate. + * @param mixed $value The value to validate. * @param array $typeInfo The parsed data type information. * * @return bool True if valid, false otherwise. @@ -275,7 +341,7 @@ final class Validator /** * Validate decimal types (numeric precision and scale). * - * @param mixed $value The value to validate. + * @param mixed $value The value to validate. * @param array $typeInfo The parsed data type information. * * @return bool True if valid, false otherwise. @@ -289,7 +355,7 @@ final class Validator /** * Validate date, datetime, timestamp, and time types. * - * @param mixed $value The value to validate. + * @param mixed $value The value to validate. * @param array $typeInfo The parsed data type information. * * @return bool True if valid, false otherwise. @@ -316,7 +382,7 @@ final class Validator /** * Validate JSON types. * - * @param mixed $value The value to validate. + * @param mixed $value The value to validate. * @param array $typeInfo The parsed data type information. * * @return bool True if valid, false otherwise. @@ -331,7 +397,7 @@ final class Validator /** * Validate BLOB types (including TINYBLOB, MEDIUMBLOB, LONGBLOB). * - * @param mixed $value The value to validate. + * @param mixed $value The value to validate. * @param array $typeInfo The parsed data type information. * * @return bool True if valid, false otherwise. diff --git a/src/79fd4f39-824d-4ab6-936d-959705ff24ec/code.power b/src/79fd4f39-824d-4ab6-936d-959705ff24ec/code.power index 6b787c2..c0ee52c 100644 --- a/src/79fd4f39-824d-4ab6-936d-959705ff24ec/code.power +++ b/src/79fd4f39-824d-4ab6-936d-959705ff24ec/code.power @@ -14,6 +14,14 @@ */ protected array $validators = []; + /** + * A map of defauts for the respective datatypes. + * + * @var array + * @since 5.3.0 + */ + protected array $defaults = []; + /** * Constructor. * @@ -26,28 +34,10 @@ $this->table = $table; // Register datatype validators (mapping MySQL types to handlers) - $this->validators = [ - 'int' => [$this, 'validateInteger'], - 'tinyint' => [$this, 'validateInteger'], - 'smallint' => [$this, 'validateInteger'], - 'mediumint' => [$this, 'validateInteger'], - 'bigint' => [$this, 'validateInteger'], - 'varchar' => [$this, 'validateString'], - 'char' => [$this, 'validateString'], - 'text' => [$this, 'validateText'], - 'tinytext' => [$this, 'validateText'], - 'mediumtext' => [$this, 'validateText'], - 'longtext' => [$this, 'validateText'], - 'decimal' => [$this, 'validateDecimal'], - 'float' => [$this, 'validateFloat'], - 'double' => [$this, 'validateFloat'], - 'date' => [$this, 'validateDate'], - 'datetime' => [$this, 'validateDate'], - 'timestamp' => [$this, 'validateDate'], - 'time' => [$this, 'validateDate'], - 'json' => [$this, 'validateJson'], - 'blob' => [$this, 'validateBlob'], - ]; + $this->registerValidators(); + + // Register datatype defaults + $this->registerDefaults(); } /** @@ -55,9 +45,9 @@ * If the value is valid, return it. If not, return the default value, * NULL (if allowed), or an empty string if 'EMPTY' is set. * - * @param mixed $value The value to validate. - * @param string $field The field name. - * @param string $table The table name. + * @param mixed $value The value to validate. + * @param string $field The field name. + * @param string $table The table name. * * @return mixed Returns the valid value, or the default, NULL, or empty string based on validation. * @since 5.3.0 @@ -77,15 +67,15 @@ } // If invalid, return default, NULL (if allowed), or empty string - return $this->getDefault($dbField); + return $this->getDefault($dbField, $value); } /** * Validate if the given value is valid for the provided database field. * This is a private method as `getValid()` will handle the actual logic. * - * @param mixed $value The value to validate. - * @param array $dbField The database field details (type, default, null_switch, etc.). + * @param mixed $value The value to validate. + * @param array $dbField The database field details (type, default, null_switch, etc.). * * @return bool Returns true if the value is valid, false otherwise. * @since 5.3.0 @@ -109,17 +99,21 @@ /** * Handle returning the default value, null, or empty string if validation fails. * - * @param array $dbField The database field details. + * @param array $dbField The database field details. + * @param mixed $value The value to validate. * * @return mixed The default value, null, or empty string based on field settings. * @since 5.3.0 */ - private function getDefault(array $dbField) + private function getDefault(array $dbField, $value) { + // get default value from field db + $db_default = isset($dbField['default']) ? $dbField['default'] : null; + // If a default value is provided, return it - if (!empty($dbField['default'])) + if ($db_default !== null) { - return strtoupper($dbField['default']) === 'EMPTY' ? '' : $dbField['default']; + return strtoupper($db_default) === 'EMPTY' ? '' : $db_default; } // Check if NULL is allowed @@ -128,8 +122,9 @@ return null; } - // If no default value, return an empty string - return ''; + // Fallback to datatype default + $typeInfo = $this->parseDataType($dbField['type']); + return $this->defaults[$typeInfo['type']] ?? ''; } /** @@ -156,8 +151,8 @@ * Retrieve the database field structure for the specified field and table. * In your case, you use `$db = $this->table->get($table, $field, 'db')`. * - * @param string $field The field name. - * @param string $table The table name. + * @param string $field The field name. + * @param string $table The table name. * * @return array The database field details, including type, default, null_switch, etc. * @since 5.3.0 @@ -168,12 +163,82 @@ return $this->table->get($table, $field, 'db'); } + /** + * Register validators for MySQL data types. + * + * @return void + * @since 5.3.0 + */ + private function registerValidators(): void + { + $this->validators = [ + 'int' => [$this, 'validateInteger'], + 'tinyint' => [$this, 'validateInteger'], + 'smallint' => [$this, 'validateInteger'], + 'mediumint' => [$this, 'validateInteger'], + 'bigint' => [$this, 'validateInteger'], + 'varchar' => [$this, 'validateString'], + 'char' => [$this, 'validateString'], + 'text' => [$this, 'validateText'], + 'tinytext' => [$this, 'validateText'], + 'mediumtext' => [$this, 'validateText'], + 'longtext' => [$this, 'validateText'], + 'decimal' => [$this, 'validateDecimal'], + 'float' => [$this, 'validateFloat'], + 'double' => [$this, 'validateFloat'], + 'date' => [$this, 'validateDate'], + 'datetime' => [$this, 'validateDate'], + 'timestamp' => [$this, 'validateDate'], + 'time' => [$this, 'validateDate'], + 'json' => [$this, 'validateJson'], + 'blob' => [$this, 'validateBlob'], + 'tinyblob' => [$this, 'validateBlob'], + 'mediumblob' => [$this, 'validateBlob'], + 'longblob' => [$this, 'validateBlob'], + ]; + } + + /** + * Register default values for MySQL data types. + * + * @return void + * @since 5.3.0 + */ + private function registerDefaults(): void + { + $this->defaults = [ + 'int' => 0, + 'tinyint' => 0, + 'smallint' => 0, + 'mediumint' => 0, + 'bigint' => 0, + 'varchar' => '', + 'char' => '', + 'text' => '', + 'tinytext' => '', + 'mediumtext' => '', + 'longtext' => '', + 'decimal' => 0.0, + 'float' => 0.0, + 'double' => 0.0, + 'date' => '0000-00-00', + 'datetime' => '0000-00-00 00:00:00', + 'timestamp' => '0000-00-00 00:00:00', + 'time' => '00:00:00', + 'json' => '{}', + 'blob' => '', + 'tinyblob' => '', + 'mediumblob' => '', + 'longblob' => '', + ]; + } + // ----------------- Validation Methods ----------------- /** * Validate integer types (including tinyint, smallint, mediumint, etc.). * - * @param mixed $value The value to validate. + * @param mixed $value The value to validate. * @param array $typeInfo The parsed data type information. * * @return bool True if valid, false otherwise. @@ -198,7 +263,7 @@ /** * Validate string types like VARCHAR and CHAR. * - * @param mixed $value The value to validate. + * @param mixed $value The value to validate. * @param array $typeInfo The parsed data type information. * * @return bool True if valid, false otherwise. @@ -223,7 +288,7 @@ /** * Validate text types like TEXT, TINYTEXT, MEDIUMTEXT, LONGTEXT. * - * @param mixed $value The value to validate. + * @param mixed $value The value to validate. * @param array $typeInfo The parsed data type information. * * @return bool True if valid, false otherwise. @@ -237,7 +302,7 @@ /** * Validate float, double, and decimal types. * - * @param mixed $value The value to validate. + * @param mixed $value The value to validate. * @param array $typeInfo The parsed data type information. * * @return bool True if valid, false otherwise. @@ -251,7 +316,7 @@ /** * Validate decimal types (numeric precision and scale). * - * @param mixed $value The value to validate. + * @param mixed $value The value to validate. * @param array $typeInfo The parsed data type information. * * @return bool True if valid, false otherwise. @@ -265,7 +330,7 @@ /** * Validate date, datetime, timestamp, and time types. * - * @param mixed $value The value to validate. + * @param mixed $value The value to validate. * @param array $typeInfo The parsed data type information. * * @return bool True if valid, false otherwise. @@ -292,7 +357,7 @@ /** * Validate JSON types. * - * @param mixed $value The value to validate. + * @param mixed $value The value to validate. * @param array $typeInfo The parsed data type information. * * @return bool True if valid, false otherwise. @@ -307,7 +372,7 @@ /** * Validate BLOB types (including TINYBLOB, MEDIUMBLOB, LONGBLOB). * - * @param mixed $value The value to validate. + * @param mixed $value The value to validate. * @param array $typeInfo The parsed data type information. * * @return bool True if valid, false otherwise. diff --git a/src/79fd4f39-824d-4ab6-936d-959705ff24ec/settings.json b/src/79fd4f39-824d-4ab6-936d-959705ff24ec/settings.json index eccd6e1..47d25e2 100644 --- a/src/79fd4f39-824d-4ab6-936d-959705ff24ec/settings.json +++ b/src/79fd4f39-824d-4ab6-936d-959705ff24ec/settings.json @@ -3,7 +3,9 @@ "add_licensing_template": "2", "extends": "", "guid": "79fd4f39-824d-4ab6-936d-959705ff24ec", - "implements": null, + "implements": [ + "feb3affa-5102-4307-93db-04525f4c66f0" + ], "load_selection": null, "name": "Validator", "power_version": "1.0.0", diff --git a/src/85321deb-5c3a-401b-9ce1-039a746add51/README.md b/src/85321deb-5c3a-401b-9ce1-039a746add51/README.md index bcb73ab..f43bfb0 100644 --- a/src/85321deb-5c3a-401b-9ce1-039a746add51/README.md +++ b/src/85321deb-5c3a-401b-9ce1-039a746add51/README.md @@ -16,6 +16,9 @@ abstract Import #Orange { # Items $items # ImportEngine $import # string $queueTable + # string $queueStatusField + # int $queueWaitState + # int $queueProcessingState # string $targetName # string $targetImportClass # static $defaultName diff --git a/src/85321deb-5c3a-401b-9ce1-039a746add51/code.php b/src/85321deb-5c3a-401b-9ce1-039a746add51/code.php index 532f376..6fa74e8 100644 --- a/src/85321deb-5c3a-401b-9ce1-039a746add51/code.php +++ b/src/85321deb-5c3a-401b-9ce1-039a746add51/code.php @@ -54,6 +54,30 @@ abstract class Import extends AbstractCommand */ protected string $queueTable; + /** + * The queue status field + * + * @var string + * @since 5.0.2 + */ + protected string $queueStatusField; + + /** + * The queue awaiting status + * + * @var int + * @since 5.0.2 + */ + protected int $queueWaitState; + + /** + * The queue processing status + * + * @var int + * @since 5.0.2 + */ + protected int $queueProcessingState; + /** * The main import target name. * @@ -139,7 +163,7 @@ EOF); $io->title("Component Builder: {$this->targetName} import status"); // Get all imports in the queue that are in waiting state - if (($queue = $this->items->table($this->queueTable)->get([1], 'import_status')) === null) + if (($queue = $this->items->table($this->queueTable)->get([$this->queueWaitState], $this->queueStatusField)) === null) { // Get the current date and time $timestamp = date('Y-m-d H:i:s'); @@ -150,6 +174,15 @@ EOF); return 0; } + // take spreadsheets out of queue + $this->items->table($this->queueTable)->set(array_map(function($item) { + return [ + 'guid' => $item->guid, + $this->queueStatusField => $this->queueProcessingState + ]; + }, $queue)); + + // size of the queue $numberSteps = count((array) $queue); // Output initial task information diff --git a/src/85321deb-5c3a-401b-9ce1-039a746add51/code.power b/src/85321deb-5c3a-401b-9ce1-039a746add51/code.power index 18009a3..90501e1 100644 --- a/src/85321deb-5c3a-401b-9ce1-039a746add51/code.power +++ b/src/85321deb-5c3a-401b-9ce1-039a746add51/code.power @@ -22,6 +22,30 @@ */ protected string $queueTable; + /** + * The queue status field + * + * @var string + * @since 5.0.2 + */ + protected string $queueStatusField; + + /** + * The queue awaiting status + * + * @var int + * @since 5.0.2 + */ + protected int $queueWaitState; + + /** + * The queue processing status + * + * @var int + * @since 5.0.2 + */ + protected int $queueProcessingState; + /** * The main import target name. * @@ -107,7 +131,7 @@ EOF); $io->title("Component Builder: {$this->targetName} import status"); // Get all imports in the queue that are in waiting state - if (($queue = $this->items->table($this->queueTable)->get([1], 'import_status')) === null) + if (($queue = $this->items->table($this->queueTable)->get([$this->queueWaitState], $this->queueStatusField)) === null) { // Get the current date and time $timestamp = date('Y-m-d H:i:s'); @@ -118,6 +142,15 @@ EOF); return 0; } + // take spreadsheets out of queue + $this->items->table($this->queueTable)->set(array_map(function($item) { + return [ + 'guid' => $item->guid, + $this->queueStatusField => $this->queueProcessingState + ]; + }, $queue)); + + // size of the queue $numberSteps = count((array) $queue); // Output initial task information diff --git a/src/85321deb-5c3a-401b-9ce1-039a746add51/settings.json b/src/85321deb-5c3a-401b-9ce1-039a746add51/settings.json index c3cf55e..92498d2 100644 --- a/src/85321deb-5c3a-401b-9ce1-039a746add51/settings.json +++ b/src/85321deb-5c3a-401b-9ce1-039a746add51/settings.json @@ -14,11 +14,11 @@ "use": "ff8d5fdb-2d1f-4178-bd18-a43b8efd1068", "as": "ImportFactory" }, - "use_selection2": { + "use_selection1": { "use": "0f3f7188-3e0d-4d1a-8dee-7f8026cb65a9", "as": "ImportEngine" }, - "use_selection1": { + "use_selection2": { "use": "21bca8a4-5b28-41c4-843e-8097f0ba7cca", "as": "default" }, diff --git a/src/afb5b891-7130-422a-b389-1934b0e4fc48/README.md b/src/afb5b891-7130-422a-b389-1934b0e4fc48/README.md new file mode 100644 index 0000000..45489b2 --- /dev/null +++ b/src/afb5b891-7130-422a-b389-1934b0e4fc48/README.md @@ -0,0 +1,87 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class Row (Details) +> namespace: **VDM\Joomla\Componentbuilder\Import** + +```uml +@startuml +class Row << (F,LightGreen) >> #RoyalBlue { + - array $values + - int $index + - bool $isSet + + set(int $index, array $values) : void + + clear() : self + + getIndex() : int + + getValue(string $key) : mixed + + unsetValue(string $key) : void +} + +note right of Row::set + Set the row details + + since: 5.0.2 + return: void +end note + +note right of Row::clear + Clear the row details + + since: 5.0.2 + return: self +end note + +note right of Row::getIndex + Get Index + + since: 5.0.2 + return: int +end note + +note right of Row::getValue + Get Value + + since: 5.0.2 + return: mixed +end note + +note right of Row::unsetValue + Unset Value + + since: 5.0.2 + return: void +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---afb5b891_7130_422a_b389_1934b0e4fc48---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) + diff --git a/src/afb5b891-7130-422a-b389-1934b0e4fc48/code.php b/src/afb5b891-7130-422a-b389-1934b0e4fc48/code.php new file mode 100644 index 0000000..f894434 --- /dev/null +++ b/src/afb5b891-7130-422a-b389-1934b0e4fc48/code.php @@ -0,0 +1,131 @@ + + * @git 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\Import; + + +use VDM\Joomla\Componentbuilder\Interfaces\ImportRowInterface; + + +/** + * Import Row Class + * + * @since 4.0.3 + */ +final class Row implements ImportRowInterface +{ + /** + * The row array of values. + * + * @var array + * @since 5.0.2 + */ + private array $values; + + /** + * The row index. + * + * @var int + * @since 5.0.2 + */ + private int $index; + + /** + * A flag to track if values and index are set. + * + * @var bool + * @since 5.0.2 + */ + private bool $isSet = false; + + /** + * Set the row details + * + * @param int $index The row index + * @param array $values The values + * + * @return void + * @since 5.0.2 + */ + public function set(int $index, array $values): void + { + $this->index = $index; + $this->values = $values; + $this->isSet = true; + } + + /** + * Clear the row details + * + * @return self + * @since 5.0.2 + */ + public function clear(): self + { + $this->index = 0; + $this->values = []; + $this->isSet = false; + + return $this; + } + + /** + * Get Index + * + * @return int + * @throws \InvalidArgumentException if any of the parameters are null or empty. + * @since 5.0.2 + */ + public function getIndex(): int + { + if (!$this->isSet) + { + throw new \InvalidArgumentException('Index must not be null or empty. Use the set method to first set the index.'); + } + + return $this->index; + } + + /** + * Get Value + * + * @return mixed + * @throws \InvalidArgumentException if any of the parameters are null or empty. + * @since 5.0.2 + */ + public function getValue(string $key) + { + if (!$this->isSet) + { + throw new \InvalidArgumentException('Values must be set before accessing. Use the set method to first set the values.'); + } + + return $this->values[$key] ?? null; + } + + /** + * Unset Value + * + * @return void + * @throws \InvalidArgumentException if any of the parameters are null or empty. + * @since 5.0.2 + */ + public function unsetValue(string $key): void + { + if (!$this->isSet) + { + throw new \InvalidArgumentException('Values must be set before accessing. Use the set method to first set the values.'); + } + + unset($this->values[$key]); + } +} + diff --git a/src/afb5b891-7130-422a-b389-1934b0e4fc48/code.power b/src/afb5b891-7130-422a-b389-1934b0e4fc48/code.power new file mode 100644 index 0000000..4e9ec48 --- /dev/null +++ b/src/afb5b891-7130-422a-b389-1934b0e4fc48/code.power @@ -0,0 +1,105 @@ + /** + * The row array of values. + * + * @var array + * @since 5.0.2 + */ + private array $values; + + /** + * The row index. + * + * @var int + * @since 5.0.2 + */ + private int $index; + + /** + * A flag to track if values and index are set. + * + * @var bool + * @since 5.0.2 + */ + private bool $isSet = false; + + /** + * Set the row details + * + * @param int $index The row index + * @param array $values The values + * + * @return void + * @since 5.0.2 + */ + public function set(int $index, array $values): void + { + $this->index = $index; + $this->values = $values; + $this->isSet = true; + } + + /** + * Clear the row details + * + * @return self + * @since 5.0.2 + */ + public function clear(): self + { + $this->index = 0; + $this->values = []; + $this->isSet = false; + + return $this; + } + + /** + * Get Index + * + * @return int + * @throws \InvalidArgumentException if any of the parameters are null or empty. + * @since 5.0.2 + */ + public function getIndex(): int + { + if (!$this->isSet) + { + throw new \InvalidArgumentException('Index must not be null or empty. Use the set method to first set the index.'); + } + + return $this->index; + } + + /** + * Get Value + * + * @return mixed + * @throws \InvalidArgumentException if any of the parameters are null or empty. + * @since 5.0.2 + */ + public function getValue(string $key) + { + if (!$this->isSet) + { + throw new \InvalidArgumentException('Values must be set before accessing. Use the set method to first set the values.'); + } + + return $this->values[$key] ?? null; + } + + /** + * Unset Value + * + * @return void + * @throws \InvalidArgumentException if any of the parameters are null or empty. + * @since 5.0.2 + */ + public function unsetValue(string $key): void + { + if (!$this->isSet) + { + throw new \InvalidArgumentException('Values must be set before accessing. Use the set method to first set the values.'); + } + + unset($this->values[$key]); + } \ No newline at end of file diff --git a/src/afb5b891-7130-422a-b389-1934b0e4fc48/settings.json b/src/afb5b891-7130-422a-b389-1934b0e4fc48/settings.json new file mode 100644 index 0000000..08abe5f --- /dev/null +++ b/src/afb5b891-7130-422a-b389-1934b0e4fc48/settings.json @@ -0,0 +1,21 @@ +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "", + "guid": "afb5b891-7130-422a-b389-1934b0e4fc48", + "implements": [ + "3d3ec064-9867-41e6-a48a-964c15d753aa" + ], + "load_selection": null, + "name": "Row", + "power_version": "1.0.0", + "system_name": "JCB.Import.Row", + "type": "final class", + "use_selection": null, + "extendsinterfaces": null, + "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Import.Row", + "description": "Import Row 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 \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/bfd1d6d5-56c1-4fe9-9fee-1c5910e1f5d8/code.php b/src/bfd1d6d5-56c1-4fe9-9fee-1c5910e1f5d8/code.php index 5519d4e..6e4222d 100644 --- a/src/bfd1d6d5-56c1-4fe9-9fee-1c5910e1f5d8/code.php +++ b/src/bfd1d6d5-56c1-4fe9-9fee-1c5910e1f5d8/code.php @@ -12,7 +12,7 @@ namespace VDM\Joomla\Componentbuilder; -use VDM\Joomla\Interfaces\Tableinterface; +use VDM\Joomla\Interfaces\TableInterface; use VDM\Joomla\Abstraction\BaseTable; @@ -21,7 +21,7 @@ use VDM\Joomla\Abstraction\BaseTable; * * @since 3.2.0 */ -final class Table extends BaseTable implements Tableinterface +final class Table extends BaseTable implements TableInterface { /** * All areas/views/tables with their field details diff --git a/src/d2a859ac-3f2a-4f69-a77f-f118b2e0a459/README.md b/src/d2a859ac-3f2a-4f69-a77f-f118b2e0a459/README.md new file mode 100644 index 0000000..0004803 --- /dev/null +++ b/src/d2a859ac-3f2a-4f69-a77f-f118b2e0a459/README.md @@ -0,0 +1,104 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class Status (Details) +> namespace: **VDM\Joomla\Componentbuilder\Import** + +```uml +@startuml +class Status << (F,LightGreen) >> #RoyalBlue { + # Item $item + # string $table + # string $fieldName + + __construct(Item $item, ?string $table = null, ...) + + set(int $status, string $guid) : void + + table(string $table) : self + + field(string $fieldName) : self + + getTable() : string + + getField() : string +} + +note right of Status::__construct + Constructor. + + since: 5.0.2 + + arguments: + Item $item + ?string $table = null + ?string $field = null +end note + +note right of Status::set + Updates the status in the database. +This method updates the import status in the database based on the result of the import process. +Status codes: +- 2: Being Processed. +- 3: Import completed successfully. +- 4: Import completed with errors. + + since: 5.0.2 + return: void +end note + +note right of Status::table + Set the current active table + + since: 3.2.2 + return: self +end note + +note right of Status::field + Set the current target status field name + + since: 3.2.2 + return: self +end note + +note right of Status::getTable + Get the current active table + + since: 3.2.2 + return: string +end note + +note right of Status::getField + Get the current target status field name + + since: 3.2.2 + 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---d2a859ac_3f2a_4f69_a77f_f118b2e0a459---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) + diff --git a/src/d2a859ac-3f2a-4f69-a77f-f118b2e0a459/code.php b/src/d2a859ac-3f2a-4f69-a77f-f118b2e0a459/code.php new file mode 100644 index 0000000..fd30dd6 --- /dev/null +++ b/src/d2a859ac-3f2a-4f69-a77f-f118b2e0a459/code.php @@ -0,0 +1,149 @@ + + * @git 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\Import; + + +use VDM\Joomla\Interfaces\Data\ItemInterface as Item; +use VDM\Joomla\Componentbuilder\Interfaces\ImportStatusInterface; + + +/** + * Import Status Class + * + * @since 5.0.2 + */ +final class Status implements ImportStatusInterface +{ + /** + * The Item Class. + * + * @var Item + * @since 5.0.2 + */ + protected Item $item; + + /** + * Table Name + * + * @var string + * @since 5.0.2 + */ + protected string $table; + + /** + * Status Field Name + * + * @var string + * @since 5.0.2 + */ + protected string $fieldName; + + /** + * Constructor. + * + * @param Item $item The Item Class. + * @param string|null $table The table name + * @param string|null $field The field name. + * + * @since 5.0.2 + */ + public function __construct(Item $item, ?string $table = null, ?string $field = null) + { + $this->item = $item; + + if ($table !== null) + { + $this->table = $table; + } + + if ($field !== null) + { + $this->field = $field; + } + } + + /** + * Updates the status in the database. + * + * This method updates the import status in the database based on the result of the import process. + * Status codes: + * - 2: Being Processed. + * - 3: Import completed successfully. + * - 4: Import completed with errors. + * + * @param int $status The status code to set for the import (2 => processing, 3 => success, 4 => errors). + * @param string $guid The target import GUID + * + * @return void + * @since 5.0.2 + */ + public function set(int $status, string $guid): void + { + $this->item->table($this->getTable())->set((object) [ + 'guid' => $guid, + $this->getField() => $status + ]); + } + + /** + * Set the current active table + * + * @param string $table The table that should be active + * + * @return self + * @since 3.2.2 + */ + public function table(string $table): self + { + $this->table = $table; + + return $this; + } + + /** + * Set the current target status field name + * + * @param string $fieldName The field name where the status is set + * + * @return self + * @since 3.2.2 + */ + public function field(string $fieldName): self + { + $this->fieldName = $fieldName; + + return $this; + } + + /** + * Get the current active table + * + * @return string + * @since 3.2.2 + */ + public function getTable(): string + { + return $this->table; + } + + /** + * Get the current target status field name + * + * @return string + * @since 3.2.2 + */ + public function getField(): string + { + return $this->fieldName; + } +} + diff --git a/src/d2a859ac-3f2a-4f69-a77f-f118b2e0a459/code.power b/src/d2a859ac-3f2a-4f69-a77f-f118b2e0a459/code.power new file mode 100644 index 0000000..c8a6d8b --- /dev/null +++ b/src/d2a859ac-3f2a-4f69-a77f-f118b2e0a459/code.power @@ -0,0 +1,122 @@ + /** + * The Item Class. + * + * @var Item + * @since 5.0.2 + */ + protected Item $item; + + /** + * Table Name + * + * @var string + * @since 5.0.2 + */ + protected string $table; + + /** + * Status Field Name + * + * @var string + * @since 5.0.2 + */ + protected string $fieldName; + + /** + * Constructor. + * + * @param Item $item The Item Class. + * @param string|null $table The table name + * @param string|null $field The field name. + * + * @since 5.0.2 + */ + public function __construct(Item $item, ?string $table = null, ?string $field = null) + { + $this->item = $item; + + if ($table !== null) + { + $this->table = $table; + } + + if ($field !== null) + { + $this->field = $field; + } + } + + /** + * Updates the status in the database. + * + * This method updates the import status in the database based on the result of the import process. + * Status codes: + * - 2: Being Processed. + * - 3: Import completed successfully. + * - 4: Import completed with errors. + * + * @param int $status The status code to set for the import (2 => processing, 3 => success, 4 => errors). + * @param string $guid The target import GUID + * + * @return void + * @since 5.0.2 + */ + public function set(int $status, string $guid): void + { + $this->item->table($this->getTable())->set((object) [ + 'guid' => $guid, + $this->getField() => $status + ]); + } + + /** + * Set the current active table + * + * @param string $table The table that should be active + * + * @return self + * @since 3.2.2 + */ + public function table(string $table): self + { + $this->table = $table; + + return $this; + } + + /** + * Set the current target status field name + * + * @param string $fieldName The field name where the status is set + * + * @return self + * @since 3.2.2 + */ + public function field(string $fieldName): self + { + $this->fieldName = $fieldName; + + return $this; + } + + /** + * Get the current active table + * + * @return string + * @since 3.2.2 + */ + public function getTable(): string + { + return $this->table; + } + + /** + * Get the current target status field name + * + * @return string + * @since 3.2.2 + */ + public function getField(): string + { + return $this->fieldName; + } \ No newline at end of file diff --git a/src/d2a859ac-3f2a-4f69-a77f-f118b2e0a459/settings.json b/src/d2a859ac-3f2a-4f69-a77f-f118b2e0a459/settings.json new file mode 100644 index 0000000..39bc0ad --- /dev/null +++ b/src/d2a859ac-3f2a-4f69-a77f-f118b2e0a459/settings.json @@ -0,0 +1,26 @@ +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "", + "guid": "d2a859ac-3f2a-4f69-a77f-f118b2e0a459", + "implements": [ + "0e44d149-4863-47ec-8f0f-6a821ab3e77f" + ], + "load_selection": null, + "name": "Status", + "power_version": "1.0.0", + "system_name": "JCB.Import.Status", + "type": "final class", + "use_selection": { + "use_selection0": { + "use": "05744dd3-4030-4cf8-8dda-a93ab809b473", + "as": "Item" + } + }, + "extendsinterfaces": null, + "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Import.Status", + "description": "Import Status Class\r\n\r\n@since 5.0.2", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/e0f6ddbe-2a35-4537-942c-faff2ebd04f6/code.php b/src/e0f6ddbe-2a35-4537-942c-faff2ebd04f6/code.php index fe497f6..7f48355 100644 --- a/src/e0f6ddbe-2a35-4537-942c-faff2ebd04f6/code.php +++ b/src/e0f6ddbe-2a35-4537-942c-faff2ebd04f6/code.php @@ -12,7 +12,7 @@ namespace VDM\Joomla\Abstraction; -use VDM\Joomla\Interfaces\Tableinterface; +use VDM\Joomla\Interfaces\TableInterface; /** @@ -20,7 +20,7 @@ use VDM\Joomla\Interfaces\Tableinterface; * * @since 3.2.0 */ -abstract class BaseTable implements Tableinterface +abstract class BaseTable implements TableInterface { /** * All areas/views/tables with their field details diff --git a/src/eef6ffc2-2af0-4336-958f-e0b9cf7c4ad0/README.md b/src/eef6ffc2-2af0-4336-958f-e0b9cf7c4ad0/README.md new file mode 100644 index 0000000..baef041 --- /dev/null +++ b/src/eef6ffc2-2af0-4336-958f-e0b9cf7c4ad0/README.md @@ -0,0 +1,134 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# final class Message (Details) +> namespace: **VDM\Joomla\Componentbuilder\Import** + +```uml +@startuml +class Message << (F,LightGreen) >> #RoyalBlue { + # Update $update + # Insert $insert + - array $success + - array $error + - ?string $guid + - ?string $entity + - ?string $table + + __construct(Update $update, Insert $insert) + + load(string $guid, string $entity, ...) : self + + get() : object + + reset() : void + + archive() : self + + set() : self + + addSuccess(string $message) : self + + addInfo(string $message) : self + + addError(string $message) : self +} + +note right of Message::__construct + Constructor. + + since: 5.0.2 +end note + +note left of Message::load + Load an entity that these message belong to + + since: 5.0.2 + return: self + + arguments: + string $guid + string $entity + string $table +end note + +note right of Message::get + Get the messages of the last import event + + since: 5.0.2 + return: object +end note + +note left of Message::reset + Reset the messages of the last import event + + since: 5.0.2 + return: void +end note + +note right of Message::archive + Archive the messages in the DB of the last import event + + since: 5.0.2 + return: self +end note + +note left of Message::set + Set the messages in the DB of the last import event + + since: 5.0.2 + return: self +end note + +note right of Message::addSuccess + Adds a success message to the log. +This method records a success message for the import process. The message provides +relevant information, such as the number of rows processed and the success rate. + + since: 5.0.2 + return: self +end note + +note left of Message::addInfo + Adds a info message to the log. +This method records a info message for the import process. The message provides +relevant information, such as the number of rows processed and the info rate. + + since: 5.0.2 + return: self +end note + +note right of Message::addError + Adds an error message to the log. +This method records an error message when the import process encounters issues. +The message includes details about the failures, such as the number of failed rows +and the corresponding error rate. + + since: 5.0.2 + return: self +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---eef6ffc2_2af0_4336_958f_e0b9cf7c4ad0---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) + diff --git a/src/eef6ffc2-2af0-4336-958f-e0b9cf7c4ad0/code.php b/src/eef6ffc2-2af0-4336-958f-e0b9cf7c4ad0/code.php new file mode 100644 index 0000000..30c313b --- /dev/null +++ b/src/eef6ffc2-2af0-4336-958f-e0b9cf7c4ad0/code.php @@ -0,0 +1,297 @@ + + * @git 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\Import; + + +use VDM\Joomla\Interfaces\Data\UpdateInterface as Update; +use VDM\Joomla\Interfaces\Data\InsertInterface as Insert; +use VDM\Joomla\Utilities\GuidHelper; +use VDM\Joomla\Componentbuilder\Interfaces\ImportMessageInterface; + + +/** + * Import Messages Class + * + * @since 5.0.2 + */ +final class Message implements ImportMessageInterface +{ + /** + * The Update Class. + * + * @var Update + * @since 5.0.2 + */ + protected Update $update; + + /** + * The Insert Class. + * + * @var Insert + * @since 5.0.2 + */ + protected Insert $insert; + + /** + * The success message bus. + * + * @var array + * @since 5.0.2 + */ + private array $success = []; + + /** + * The error message bus. + * + * @var array + * @since 5.0.2 + */ + private array $error = []; + + /** + * The entity GUID value. + * + * @var string + * @since 5.0.2 + */ + private ?string $guid = null; + + /** + * The entity type value. + * + * @var string|null + * @since 5.0.2 + */ + private ?string $entity = null; + + /** + * The entity table value. + * + * @var string|null + * @since 5.0.2 + */ + private ?string $table = null; + + /** + * Constructor. + * + * @param Update $update The Update Class. + * @param Insert $insert The Insert Class. + * + * @since 5.0.2 + */ + public function __construct(Update $update, Insert $insert) + { + $this->update = $update; + $this->insert = $insert; + } + + /** + * Load an entity that these message belong to + * + * @param string $guid The entity guid these messages must be linked to. + * @param string $entity The entity type these messages must be linked to. + * @param string $table The messages table where these message must be stored. + * + * @return self + * @throws \InvalidArgumentException if any of the parameters are null or empty. + * @since 5.0.2 + */ + public function load(string $guid, string $entity, string $table): self + { + if (empty($guid) || empty($entity) || empty($table)) + { + throw new \InvalidArgumentException('GUID, entity, and table must not be null or empty.'); + } + + // set entity details + $this->guid = $guid; + $this->entity = $entity; + $this->table = $table; + } + + /** + * Get the messages of the last import event + * + * @return object + * @since 5.0.2 + */ + public function get(): object + { + return (object) [ + 'message_success' => $this->success ?? null, + 'message_info' => $this->info ?? null, + 'message_error' => $this->error ?? null + ]; + } + + /** + * Reset the messages of the last import event + * + * @return void + * @since 5.0.2 + */ + public function reset(): void + { + // clear the message bus + $this->success = []; + $this->info = []; + $this->error = []; + + $this->guid = null; + $this->entity = null; + $this->table = null; + } + + /** + * Archive the messages in the DB of the last import event + * + * @return self + * @throws \InvalidArgumentException if GUID, entity, or table is null. + * @since 5.0.2 + */ + public function archive(): self + { + if (empty($this->guid) || empty($this->entity) || empty($this->table)) + { + throw new \InvalidArgumentException('GUID, entity, and table must not be null or empty.'); + } + + // trash all messages from the past + $this->update->table($this->table)->rows([['entity' => $this->guid, 'published' => -2]], 'entity'); + + return $this; + } + + /** + * Set the messages in the DB of the last import event + * + * @return self + * @throws \InvalidArgumentException if GUID, entity, or table is null. + * @since 5.0.2 + */ + public function set(): self + { + if (empty($this->guid) || empty($this->entity) || empty($this->table)) + { + throw new \InvalidArgumentException('GUID, entity, and table must not be null or empty.'); + } + + // start message bucket + $messages = []; + + // set the success messages + if (!empty($this->success)) + { + foreach ($this->success as $message) + { + $messages[] = [ + 'guid' => GuidHelper::get(), + 'entity' => $this->guid, + 'entity_type' => $this->entity, + 'message' => $message, + 'message_status' => 1 + ]; + } + } + + // set the info messages + if (!empty($this->info)) + { + foreach ($this->info as $message) + { + $messages[] = [ + 'guid' => GuidHelper::get(), + 'entity' => $this->guid, + 'entity_type' => $this->entity, + 'message' => $message, + 'message_status' => 2 + ]; + } + } + + // set the error messages + if (!empty($this->error)) + { + foreach ($this->error as $message) + { + $messages[] = [ + 'guid' => GuidHelper::get(), + 'entity' => $this->guid, + 'entity_type' => $this->entity, + 'message' => $message, + 'message_status' => 3 + ]; + } + } + + $this->insert->table($this->table)->rows($messages); + + return $this; + } + + /** + * Adds a success message to the log. + * + * This method records a success message for the import process. The message provides + * relevant information, such as the number of rows processed and the success rate. + * + * @param string $message The success message to log. + * + * @return self + * @since 5.0.2 + */ + public function addSuccess(string $message): self + { + $this->success[] = $message; + + return $this; + } + + /** + * Adds a info message to the log. + * + * This method records a info message for the import process. The message provides + * relevant information, such as the number of rows processed and the info rate. + * + * @param string $message The info message to log. + * + * @return self + * @since 5.0.2 + */ + public function addInfo(string $message): self + { + $this->info[] = $message; + + return $this; + } + + /** + * Adds an error message to the log. + * + * This method records an error message when the import process encounters issues. + * The message includes details about the failures, such as the number of failed rows + * and the corresponding error rate. + * + * @param string $message The error message to log. + * + * @return self + * @since 5.0.2 + */ + public function addError(string $message): self + { + $this->error[] = $message; + + return $this; + } +} + diff --git a/src/eef6ffc2-2af0-4336-958f-e0b9cf7c4ad0/code.power b/src/eef6ffc2-2af0-4336-958f-e0b9cf7c4ad0/code.power new file mode 100644 index 0000000..1cdb0a3 --- /dev/null +++ b/src/eef6ffc2-2af0-4336-958f-e0b9cf7c4ad0/code.power @@ -0,0 +1,268 @@ + /** + * The Update Class. + * + * @var Update + * @since 5.0.2 + */ + protected Update $update; + + /** + * The Insert Class. + * + * @var Insert + * @since 5.0.2 + */ + protected Insert $insert; + + /** + * The success message bus. + * + * @var array + * @since 5.0.2 + */ + private array $success = []; + + /** + * The error message bus. + * + * @var array + * @since 5.0.2 + */ + private array $error = []; + + /** + * The entity GUID value. + * + * @var string + * @since 5.0.2 + */ + private ?string $guid = null; + + /** + * The entity type value. + * + * @var string|null + * @since 5.0.2 + */ + private ?string $entity = null; + + /** + * The entity table value. + * + * @var string|null + * @since 5.0.2 + */ + private ?string $table = null; + + /** + * Constructor. + * + * @param Update $update The Update Class. + * @param Insert $insert The Insert Class. + * + * @since 5.0.2 + */ + public function __construct(Update $update, Insert $insert) + { + $this->update = $update; + $this->insert = $insert; + } + + /** + * Load an entity that these message belong to + * + * @param string $guid The entity guid these messages must be linked to. + * @param string $entity The entity type these messages must be linked to. + * @param string $table The messages table where these message must be stored. + * + * @return self + * @throws \InvalidArgumentException if any of the parameters are null or empty. + * @since 5.0.2 + */ + public function load(string $guid, string $entity, string $table): self + { + if (empty($guid) || empty($entity) || empty($table)) + { + throw new \InvalidArgumentException('GUID, entity, and table must not be null or empty.'); + } + + // set entity details + $this->guid = $guid; + $this->entity = $entity; + $this->table = $table; + } + + /** + * Get the messages of the last import event + * + * @return object + * @since 5.0.2 + */ + public function get(): object + { + return (object) [ + 'message_success' => $this->success ?? null, + 'message_info' => $this->info ?? null, + 'message_error' => $this->error ?? null + ]; + } + + /** + * Reset the messages of the last import event + * + * @return void + * @since 5.0.2 + */ + public function reset(): void + { + // clear the message bus + $this->success = []; + $this->info = []; + $this->error = []; + + $this->guid = null; + $this->entity = null; + $this->table = null; + } + + /** + * Archive the messages in the DB of the last import event + * + * @return self + * @throws \InvalidArgumentException if GUID, entity, or table is null. + * @since 5.0.2 + */ + public function archive(): self + { + if (empty($this->guid) || empty($this->entity) || empty($this->table)) + { + throw new \InvalidArgumentException('GUID, entity, and table must not be null or empty.'); + } + + // trash all messages from the past + $this->update->table($this->table)->rows([['entity' => $this->guid, 'published' => -2]], 'entity'); + + return $this; + } + + /** + * Set the messages in the DB of the last import event + * + * @return self + * @throws \InvalidArgumentException if GUID, entity, or table is null. + * @since 5.0.2 + */ + public function set(): self + { + if (empty($this->guid) || empty($this->entity) || empty($this->table)) + { + throw new \InvalidArgumentException('GUID, entity, and table must not be null or empty.'); + } + + // start message bucket + $messages = []; + + // set the success messages + if (!empty($this->success)) + { + foreach ($this->success as $message) + { + $messages[] = [ + 'guid' => GuidHelper::get(), + 'entity' => $this->guid, + 'entity_type' => $this->entity, + 'message' => $message, + 'message_status' => 1 + ]; + } + } + + // set the info messages + if (!empty($this->info)) + { + foreach ($this->info as $message) + { + $messages[] = [ + 'guid' => GuidHelper::get(), + 'entity' => $this->guid, + 'entity_type' => $this->entity, + 'message' => $message, + 'message_status' => 2 + ]; + } + } + + // set the error messages + if (!empty($this->error)) + { + foreach ($this->error as $message) + { + $messages[] = [ + 'guid' => GuidHelper::get(), + 'entity' => $this->guid, + 'entity_type' => $this->entity, + 'message' => $message, + 'message_status' => 3 + ]; + } + } + + $this->insert->table($this->table)->rows($messages); + + return $this; + } + + /** + * Adds a success message to the log. + * + * This method records a success message for the import process. The message provides + * relevant information, such as the number of rows processed and the success rate. + * + * @param string $message The success message to log. + * + * @return self + * @since 5.0.2 + */ + public function addSuccess(string $message): self + { + $this->success[] = $message; + + return $this; + } + + /** + * Adds a info message to the log. + * + * This method records a info message for the import process. The message provides + * relevant information, such as the number of rows processed and the info rate. + * + * @param string $message The info message to log. + * + * @return self + * @since 5.0.2 + */ + public function addInfo(string $message): self + { + $this->info[] = $message; + + return $this; + } + + /** + * Adds an error message to the log. + * + * This method records an error message when the import process encounters issues. + * The message includes details about the failures, such as the number of failed rows + * and the corresponding error rate. + * + * @param string $message The error message to log. + * + * @return self + * @since 5.0.2 + */ + public function addError(string $message): self + { + $this->error[] = $message; + + return $this; + } \ No newline at end of file diff --git a/src/eef6ffc2-2af0-4336-958f-e0b9cf7c4ad0/settings.json b/src/eef6ffc2-2af0-4336-958f-e0b9cf7c4ad0/settings.json new file mode 100644 index 0000000..7ffbdce --- /dev/null +++ b/src/eef6ffc2-2af0-4336-958f-e0b9cf7c4ad0/settings.json @@ -0,0 +1,34 @@ +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "", + "guid": "eef6ffc2-2af0-4336-958f-e0b9cf7c4ad0", + "implements": [ + "23ad6e72-1b82-40fb-836c-50da690bb174" + ], + "load_selection": null, + "name": "Message", + "power_version": "1.0.0", + "system_name": "JCB.Import.Message", + "type": "final class", + "use_selection": { + "use_selection0": { + "use": "68a41264-64c0-441a-a3d8-8a5e557b1883", + "as": "Update" + }, + "use_selection1": { + "use": "03bbc8d5-86e8-4d2f-ae5f-0d44a4f7af13", + "as": "Insert" + }, + "use_selection2": { + "use": "9c513baf-b279-43fd-ae29-a585c8cbc4f0", + "as": "default" + } + }, + "extendsinterfaces": null, + "namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Import.Message", + "description": "Import Messages Class\r\n\r\n@since 5.0.2", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/f3c04c28-bce4-422e-be93-7d163e4e342b/code.php b/src/f3c04c28-bce4-422e-be93-7d163e4e342b/code.php index 18e7e02..0eb4281 100644 --- a/src/f3c04c28-bce4-422e-be93-7d163e4e342b/code.php +++ b/src/f3c04c28-bce4-422e-be93-7d163e4e342b/code.php @@ -14,7 +14,7 @@ namespace VDM\Joomla\Abstraction; use Joomla\CMS\Factory; use Joomla\CMS\Version; -use VDM\Joomla\Interfaces\Tableinterface as Table; +use VDM\Joomla\Interfaces\TableInterface as Table; use VDM\Joomla\Interfaces\SchemaInterface; diff --git a/src/feb3affa-5102-4307-93db-04525f4c66f0/README.md b/src/feb3affa-5102-4307-93db-04525f4c66f0/README.md new file mode 100644 index 0000000..5e515a7 --- /dev/null +++ b/src/feb3affa-5102-4307-93db-04525f4c66f0/README.md @@ -0,0 +1,59 @@ +``` +██████╗ ██████╗ ██╗ ██╗███████╗██████╗ +██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗ +██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝ +██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗ +██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║ +╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝ +``` +# interface TableValidatorInterface (Details) +> namespace: **VDM\Joomla\Interfaces** + +```uml +@startuml +interface TableValidatorInterface #Lavender { + + getValid(mixed $value, string $field, ...) : mixed +} + +note right of TableValidatorInterface::getValid + Returns the valid value based on datatype definition. +If the value is valid, return it. If not, return the default value, +NULL (if allowed), or an empty string if 'EMPTY' is set. + + since: 5.3.0 + return: mixed + + arguments: + mixed $value + string $field + string $table +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---feb3affa_5102_4307_93db_04525f4c66f0---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) + diff --git a/src/feb3affa-5102-4307-93db-04525f4c66f0/code.php b/src/feb3affa-5102-4307-93db-04525f4c66f0/code.php new file mode 100644 index 0000000..ca2f5a9 --- /dev/null +++ b/src/feb3affa-5102-4307-93db-04525f4c66f0/code.php @@ -0,0 +1,34 @@ + + * @git 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; + + +/** + * The VDM Core Table Validator Interface + */ +interface TableValidatorInterface +{ + /** + * Returns the valid value based on datatype definition. + * If the value is valid, return it. If not, return the default value, + * NULL (if allowed), or an empty string if 'EMPTY' is set. + * + * @param mixed $value The value to validate. + * @param string $field The field name. + * @param string $table The table name. + * + * @return mixed Returns the valid value, or the default, NULL, or empty string based on validation. + * @since 5.3.0 + */ + public function getValid($value, string $field, string $table); +} + diff --git a/src/feb3affa-5102-4307-93db-04525f4c66f0/code.power b/src/feb3affa-5102-4307-93db-04525f4c66f0/code.power new file mode 100644 index 0000000..ea672f4 --- /dev/null +++ b/src/feb3affa-5102-4307-93db-04525f4c66f0/code.power @@ -0,0 +1,13 @@ + /** + * Returns the valid value based on datatype definition. + * If the value is valid, return it. If not, return the default value, + * NULL (if allowed), or an empty string if 'EMPTY' is set. + * + * @param mixed $value The value to validate. + * @param string $field The field name. + * @param string $table The table name. + * + * @return mixed Returns the valid value, or the default, NULL, or empty string based on validation. + * @since 5.3.0 + */ + public function getValid($value, string $field, string $table); \ No newline at end of file diff --git a/src/feb3affa-5102-4307-93db-04525f4c66f0/settings.json b/src/feb3affa-5102-4307-93db-04525f4c66f0/settings.json new file mode 100644 index 0000000..e5fce6e --- /dev/null +++ b/src/feb3affa-5102-4307-93db-04525f4c66f0/settings.json @@ -0,0 +1,19 @@ +{ + "add_head": "0", + "add_licensing_template": "2", + "extends": "", + "guid": "feb3affa-5102-4307-93db-04525f4c66f0", + "implements": null, + "load_selection": null, + "name": "TableValidatorInterface", + "power_version": "1.0.0", + "system_name": "VDM.Interfaces.TableValidatorInterface", + "type": "interface", + "use_selection": null, + "extendsinterfaces": null, + "namespace": "[[[NamespacePrefix]]]\\Joomla\\Interfaces.TableValidatorInterface", + "description": "The VDM Core Table Validator Interface", + "licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe \r\n * @git 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": "" +} \ No newline at end of file diff --git a/src/ff8d5fdb-2d1f-4178-bd18-a43b8efd1068/code.php b/src/ff8d5fdb-2d1f-4178-bd18-a43b8efd1068/code.php index a2ceb5d..f28526a 100644 --- a/src/ff8d5fdb-2d1f-4178-bd18-a43b8efd1068/code.php +++ b/src/ff8d5fdb-2d1f-4178-bd18-a43b8efd1068/code.php @@ -16,6 +16,7 @@ use VDM\Joomla\Service\Table; use VDM\Joomla\Service\Database; use VDM\Joomla\Service\Model; use VDM\Joomla\Service\Data; +use VDM\Joomla\Componentbuilder\Import\Service\Import; use VDM\Joomla\Componentbuilder\File\Service\File; use VDM\Joomla\Componentbuilder\Service\Spreadsheet; use VDM\Joomla\Interfaces\FactoryInterface; @@ -50,6 +51,7 @@ abstract class Factory extends ExtendingFactory implements FactoryInterface ->registerServiceProvider(new Database()) ->registerServiceProvider(new Model()) ->registerServiceProvider(new Data()) + ->registerServiceProvider(new Import()) ->registerServiceProvider(new File()) ->registerServiceProvider(new Spreadsheet()); } diff --git a/src/ff8d5fdb-2d1f-4178-bd18-a43b8efd1068/code.power b/src/ff8d5fdb-2d1f-4178-bd18-a43b8efd1068/code.power index 5018ccd..6875f43 100644 --- a/src/ff8d5fdb-2d1f-4178-bd18-a43b8efd1068/code.power +++ b/src/ff8d5fdb-2d1f-4178-bd18-a43b8efd1068/code.power @@ -19,6 +19,7 @@ ->registerServiceProvider(new Database()) ->registerServiceProvider(new Model()) ->registerServiceProvider(new Data()) + ->registerServiceProvider(new Import()) ->registerServiceProvider(new File()) ->registerServiceProvider(new Spreadsheet()); } \ No newline at end of file diff --git a/src/ff8d5fdb-2d1f-4178-bd18-a43b8efd1068/settings.json b/src/ff8d5fdb-2d1f-4178-bd18-a43b8efd1068/settings.json index d049889..360f3d6 100644 --- a/src/ff8d5fdb-2d1f-4178-bd18-a43b8efd1068/settings.json +++ b/src/ff8d5fdb-2d1f-4178-bd18-a43b8efd1068/settings.json @@ -28,6 +28,10 @@ "use": "a5daf189-3345-4b13-8716-c51f686f545b", "as": "default" }, + "use_selection6": { + "use": "21754a8b-2323-4a77-8459-378a74c1ec97", + "as": "default" + }, "use_selection4": { "use": "202ccd9e-dfcf-4cde-a0ce-bde1fd27f088", "as": "default" diff --git a/super-powers.json b/super-powers.json index 4a0ef71..2b9dcdf 100644 --- a/super-powers.json +++ b/super-powers.json @@ -54,6 +54,17 @@ "spk": "Super---0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a---Power", "guid": "0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a" }, + "0e44d149-4863-47ec-8f0f-6a821ab3e77f": { + "name": "ImportStatusInterface", + "type": "interface", + "namespace": "VDM\\Joomla\\Componentbuilder\\Interfaces", + "code": "src\/0e44d149-4863-47ec-8f0f-6a821ab3e77f\/code.php", + "power": "src\/0e44d149-4863-47ec-8f0f-6a821ab3e77f\/code.power", + "settings": "src\/0e44d149-4863-47ec-8f0f-6a821ab3e77f\/settings.json", + "path": "src\/0e44d149-4863-47ec-8f0f-6a821ab3e77f", + "spk": "Super---0e44d149_4863_47ec_8f0f_6a821ab3e77f---Power", + "guid": "0e44d149-4863-47ec-8f0f-6a821ab3e77f" + }, "0f3f7188-3e0d-4d1a-8dee-7f8026cb65a9": { "name": "ImportCliInterface", "type": "interface", @@ -208,6 +219,17 @@ "spk": "Super---217416f6_24cf_41c0_b18e_11086111d447---Power", "guid": "217416f6-24cf-41c0-b18e-11086111d447" }, + "21754a8b-2323-4a77-8459-378a74c1ec97": { + "name": "Import", + "type": "class", + "namespace": "VDM\\Joomla\\Componentbuilder\\Import\\Service", + "code": "src\/21754a8b-2323-4a77-8459-378a74c1ec97\/code.php", + "power": "src\/21754a8b-2323-4a77-8459-378a74c1ec97\/code.power", + "settings": "src\/21754a8b-2323-4a77-8459-378a74c1ec97\/settings.json", + "path": "src\/21754a8b-2323-4a77-8459-378a74c1ec97", + "spk": "Super---21754a8b_2323_4a77_8459_378a74c1ec97---Power", + "guid": "21754a8b-2323-4a77-8459-378a74c1ec97" + }, "21bca8a4-5b28-41c4-843e-8097f0ba7cca": { "name": "Items", "type": "final class", @@ -219,6 +241,17 @@ "spk": "Super---21bca8a4_5b28_41c4_843e_8097f0ba7cca---Power", "guid": "21bca8a4-5b28-41c4-843e-8097f0ba7cca" }, + "23ad6e72-1b82-40fb-836c-50da690bb174": { + "name": "ImportMessageInterface", + "type": "interface", + "namespace": "VDM\\Joomla\\Componentbuilder\\Interfaces", + "code": "src\/23ad6e72-1b82-40fb-836c-50da690bb174\/code.php", + "power": "src\/23ad6e72-1b82-40fb-836c-50da690bb174\/code.power", + "settings": "src\/23ad6e72-1b82-40fb-836c-50da690bb174\/settings.json", + "path": "src\/23ad6e72-1b82-40fb-836c-50da690bb174", + "spk": "Super---23ad6e72_1b82_40fb_836c_50da690bb174---Power", + "guid": "23ad6e72-1b82-40fb-836c-50da690bb174" + }, "2ad31f74-f579-499d-b98b-c4f54fd615dd": { "name": "LoadInterface", "type": "interface", @@ -231,7 +264,7 @@ "guid": "2ad31f74-f579-499d-b98b-c4f54fd615dd" }, "2da6d6c4-eb29-4d69-8bc2-36d96e916adf": { - "name": "Tableinterface", + "name": "TableInterface", "type": "interface", "namespace": "VDM\\Joomla\\Interfaces", "code": "src\/2da6d6c4-eb29-4d69-8bc2-36d96e916adf\/code.php", @@ -296,6 +329,17 @@ "spk": "Super---3cf76fbf_fd95_4a33_878e_7aff6d36b7f6---Power", "guid": "3cf76fbf-fd95-4a33-878e-7aff6d36b7f6" }, + "3d3ec064-9867-41e6-a48a-964c15d753aa": { + "name": "ImportRowInterface", + "type": "interface", + "namespace": "VDM\\Joomla\\Componentbuilder\\Interfaces", + "code": "src\/3d3ec064-9867-41e6-a48a-964c15d753aa\/code.php", + "power": "src\/3d3ec064-9867-41e6-a48a-964c15d753aa\/code.power", + "settings": "src\/3d3ec064-9867-41e6-a48a-964c15d753aa\/settings.json", + "path": "src\/3d3ec064-9867-41e6-a48a-964c15d753aa", + "spk": "Super---3d3ec064_9867_41e6_a48a_964c15d753aa---Power", + "guid": "3d3ec064-9867-41e6-a48a-964c15d753aa" + }, "3fc72954-a303-4cac-b53c-554be38b85e7": { "name": "Delete", "type": "class", @@ -439,6 +483,17 @@ "spk": "Super---52a1d14f_304a_431c_8fa4_411179942db5---Power", "guid": "52a1d14f-304a-431c-8fa4-411179942db5" }, + "53f55e5b-63cb-49e7-b1e6-33e7a9f97856": { + "name": "ImportItemInterface", + "type": "interface", + "namespace": "VDM\\Joomla\\Componentbuilder\\Interfaces", + "code": "src\/53f55e5b-63cb-49e7-b1e6-33e7a9f97856\/code.php", + "power": "src\/53f55e5b-63cb-49e7-b1e6-33e7a9f97856\/code.power", + "settings": "src\/53f55e5b-63cb-49e7-b1e6-33e7a9f97856\/settings.json", + "path": "src\/53f55e5b-63cb-49e7-b1e6-33e7a9f97856", + "spk": "Super---53f55e5b_63cb_49e7_b1e6_33e7a9f97856---Power", + "guid": "53f55e5b-63cb-49e7-b1e6-33e7a9f97856" + }, "576685fd-263c-46bb-9fdc-1f5eb234cbb6": { "name": "GuidInterface", "type": "interface", @@ -560,6 +615,17 @@ "spk": "Super---67a5e0ca_0ff0_4979_9b41_da0b09988016---Power", "guid": "67a5e0ca-0ff0-4979-9b41-da0b09988016" }, + "68a0f9af-265a-4db1-bae9-a4e4531f94d7": { + "name": "Item", + "type": "final class", + "namespace": "VDM\\Joomla\\Componentbuilder\\Import", + "code": "src\/68a0f9af-265a-4db1-bae9-a4e4531f94d7\/code.php", + "power": "src\/68a0f9af-265a-4db1-bae9-a4e4531f94d7\/code.power", + "settings": "src\/68a0f9af-265a-4db1-bae9-a4e4531f94d7\/settings.json", + "path": "src\/68a0f9af-265a-4db1-bae9-a4e4531f94d7", + "spk": "Super---68a0f9af_265a_4db1_bae9_a4e4531f94d7---Power", + "guid": "68a0f9af-265a-4db1-bae9-a4e4531f94d7" + }, "68a41264-64c0-441a-a3d8-8a5e557b1883": { "name": "UpdateInterface", "type": "interface", @@ -934,6 +1000,17 @@ "spk": "Super---af0eedbe_603b_4671_8e5a_28165d88254b---Power", "guid": "af0eedbe-603b-4671-8e5a-28165d88254b" }, + "afb5b891-7130-422a-b389-1934b0e4fc48": { + "name": "Row", + "type": "final class", + "namespace": "VDM\\Joomla\\Componentbuilder\\Import", + "code": "src\/afb5b891-7130-422a-b389-1934b0e4fc48\/code.php", + "power": "src\/afb5b891-7130-422a-b389-1934b0e4fc48\/code.power", + "settings": "src\/afb5b891-7130-422a-b389-1934b0e4fc48\/settings.json", + "path": "src\/afb5b891-7130-422a-b389-1934b0e4fc48", + "spk": "Super---afb5b891_7130_422a_b389_1934b0e4fc48---Power", + "guid": "afb5b891-7130-422a-b389-1934b0e4fc48" + }, "b3d2ec33-76d4-4c3b-bb2c-86ac14a221ce": { "name": "Schema", "type": "final class", @@ -1110,6 +1187,17 @@ "spk": "Super---d1de5d5b_bf29_4031_8094_76c4f6c75900---Power", "guid": "d1de5d5b-bf29-4031-8094-76c4f6c75900" }, + "d2a859ac-3f2a-4f69-a77f-f118b2e0a459": { + "name": "Status", + "type": "final class", + "namespace": "VDM\\Joomla\\Componentbuilder\\Import", + "code": "src\/d2a859ac-3f2a-4f69-a77f-f118b2e0a459\/code.php", + "power": "src\/d2a859ac-3f2a-4f69-a77f-f118b2e0a459\/code.power", + "settings": "src\/d2a859ac-3f2a-4f69-a77f-f118b2e0a459\/settings.json", + "path": "src\/d2a859ac-3f2a-4f69-a77f-f118b2e0a459", + "spk": "Super---d2a859ac_3f2a_4f69_a77f_f118b2e0a459---Power", + "guid": "d2a859ac-3f2a-4f69-a77f-f118b2e0a459" + }, "d46c4667-378b-49e8-9782-ffb28d92415a": { "name": "Display", "type": "final class", @@ -1220,6 +1308,17 @@ "spk": "Super---eb7d69c2_4ee9_4bd0_aacc_ab51a12be895---Power", "guid": "eb7d69c2-4ee9-4bd0-aacc-ab51a12be895" }, + "eef6ffc2-2af0-4336-958f-e0b9cf7c4ad0": { + "name": "Message", + "type": "final class", + "namespace": "VDM\\Joomla\\Componentbuilder\\Import", + "code": "src\/eef6ffc2-2af0-4336-958f-e0b9cf7c4ad0\/code.php", + "power": "src\/eef6ffc2-2af0-4336-958f-e0b9cf7c4ad0\/code.power", + "settings": "src\/eef6ffc2-2af0-4336-958f-e0b9cf7c4ad0\/settings.json", + "path": "src\/eef6ffc2-2af0-4336-958f-e0b9cf7c4ad0", + "spk": "Super---eef6ffc2_2af0_4336_958f_e0b9cf7c4ad0---Power", + "guid": "eef6ffc2-2af0-4336-958f-e0b9cf7c4ad0" + }, "f11dc790-713e-4706-9a85-a318ed3ad56e": { "name": "MimeHelper", "type": "abstract class", @@ -1253,6 +1352,17 @@ "spk": "Super---fd3f322a_082d_4579_93ad_3352c5adfc71---Power", "guid": "fd3f322a-082d-4579-93ad-3352c5adfc71" }, + "feb3affa-5102-4307-93db-04525f4c66f0": { + "name": "TableValidatorInterface", + "type": "interface", + "namespace": "VDM\\Joomla\\Interfaces", + "code": "src\/feb3affa-5102-4307-93db-04525f4c66f0\/code.php", + "power": "src\/feb3affa-5102-4307-93db-04525f4c66f0\/code.power", + "settings": "src\/feb3affa-5102-4307-93db-04525f4c66f0\/settings.json", + "path": "src\/feb3affa-5102-4307-93db-04525f4c66f0", + "spk": "Super---feb3affa_5102_4307_93db_04525f4c66f0---Power", + "guid": "feb3affa-5102-4307-93db-04525f4c66f0" + }, "ff7d0111-8f79-42aa-ac14-b53ba2c49369": { "name": "IsString", "type": "trait",