forked from joomla/super-powers
Update 2024-10-18 03:09:11
This commit is contained in:
parent
e3096c796e
commit
44d1649eb0
@ -119,13 +119,18 @@ This repository contains an index (see below) of all the approved powers within
|
|||||||
- **Namespace**: [VDM\Joomla\Componentbuilder\Import](#vdm-joomla-componentbuilder-import)
|
- **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`
|
- **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 Assessor** | [Details](src/19a66b48-620c-439b-ab8a-3c0d43e040c3) | [Code](src/19a66b48-620c-439b-ab8a-3c0d43e040c3/code.php) | [Settings](src/19a66b48-620c-439b-ab8a-3c0d43e040c3/settings.json) | SPK: `Super---19a66b48_620c_439b_ab8a_3c0d43e040c3---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 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 Mapper** | [Details](src/90b48ea8-0930-48d1-869a-bce9c901589c) | [Code](src/90b48ea8-0930-48d1-869a-bce9c901589c/code.php) | [Settings](src/90b48ea8-0930-48d1-869a-bce9c901589c/settings.json) | SPK: `Super---90b48ea8_0930_48d1_869a_bce9c901589c---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 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 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`
|
- **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`
|
||||||
|
- **class Data** | [Details](src/05f23281-58e3-482e-be42-2dc1355ef4ea) | [Code](src/05f23281-58e3-482e-be42-2dc1355ef4ea/code.php) | [Settings](src/05f23281-58e3-482e-be42-2dc1355ef4ea/settings.json) | SPK: `Super---05f23281_58e3_482e_be42_2dc1355ef4ea---Power`
|
||||||
- **Namespace**: [VDM\Joomla\Componentbuilder\Interfaces](#vdm-joomla-componentbuilder-interfaces)
|
- **Namespace**: [VDM\Joomla\Componentbuilder\Interfaces](#vdm-joomla-componentbuilder-interfaces)
|
||||||
|
|
||||||
|
- **interface ImportAssessorInterface** | [Details](src/57c00d53-5581-4fd1-b3ea-080422710243) | [Code](src/57c00d53-5581-4fd1-b3ea-080422710243/code.php) | [Settings](src/57c00d53-5581-4fd1-b3ea-080422710243/settings.json) | SPK: `Super---57c00d53_5581_4fd1_b3ea_080422710243---Power`
|
||||||
- **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 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 ImportMapperInterface** | [Details](src/250a7272-9ae1-4c63-a058-26bad9ad6f70) | [Code](src/250a7272-9ae1-4c63-a058-26bad9ad6f70/code.php) | [Settings](src/250a7272-9ae1-4c63-a058-26bad9ad6f70/settings.json) | SPK: `Super---250a7272_9ae1_4c63_a058_26bad9ad6f70---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 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 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`
|
- **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`
|
||||||
|
45
src/05f23281-58e3-482e-be42-2dc1355ef4ea/README.md
Normal file
45
src/05f23281-58e3-482e-be42-2dc1355ef4ea/README.md
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
```
|
||||||
|
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||||
|
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||||
|
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||||
|
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||||
|
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||||
|
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||||
|
```
|
||||||
|
# class Data (Details)
|
||||||
|
> namespace: **VDM\Joomla\Componentbuilder\Import**
|
||||||
|
> extends: **Registry**
|
||||||
|
|
||||||
|
```uml
|
||||||
|
@startuml
|
||||||
|
class Data #Gold {
|
||||||
|
}
|
||||||
|
|
||||||
|
@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---05f23281_58e3_482e_be42_2dc1355ef4ea---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)
|
||||||
|
|
26
src/05f23281-58e3-482e-be42-2dc1355ef4ea/code.php
Normal file
26
src/05f23281-58e3-482e-be42-2dc1355ef4ea/code.php
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 4th September, 2022
|
||||||
|
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||||
|
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||||
|
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||||
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace VDM\Joomla\Componentbuilder\Import;
|
||||||
|
|
||||||
|
|
||||||
|
use VDM\Joomla\Abstraction\Registry;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Import Data Registry
|
||||||
|
*
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
class Data extends Registry
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
1
src/05f23281-58e3-482e-be42-2dc1355ef4ea/code.power
Normal file
1
src/05f23281-58e3-482e-be42-2dc1355ef4ea/code.power
Normal file
@ -0,0 +1 @@
|
|||||||
|
###CODEPOWER###
|
19
src/05f23281-58e3-482e-be42-2dc1355ef4ea/settings.json
Normal file
19
src/05f23281-58e3-482e-be42-2dc1355ef4ea/settings.json
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"add_head": "0",
|
||||||
|
"add_licensing_template": "2",
|
||||||
|
"extends": "7e822c03-1b20-41d1-9427-f5b8d5836af7",
|
||||||
|
"guid": "05f23281-58e3-482e-be42-2dc1355ef4ea",
|
||||||
|
"implements": null,
|
||||||
|
"load_selection": null,
|
||||||
|
"name": "Data",
|
||||||
|
"power_version": "1.0.0",
|
||||||
|
"system_name": "JCB.Import.Data",
|
||||||
|
"type": "class",
|
||||||
|
"use_selection": null,
|
||||||
|
"extendsinterfaces": null,
|
||||||
|
"namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Import.Data",
|
||||||
|
"description": "Import Data Registry\r\n\r\n@since 3.2.0",
|
||||||
|
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/joomla\/Component-Builder>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
|
||||||
|
"head": "",
|
||||||
|
"composer": ""
|
||||||
|
}
|
72
src/19a66b48-620c-439b-ab8a-3c0d43e040c3/README.md
Normal file
72
src/19a66b48-620c-439b-ab8a-3c0d43e040c3/README.md
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
```
|
||||||
|
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||||
|
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||||
|
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||||
|
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||||
|
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||||
|
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||||
|
```
|
||||||
|
# final class Assessor (Details)
|
||||||
|
> namespace: **VDM\Joomla\Componentbuilder\Import**
|
||||||
|
|
||||||
|
```uml
|
||||||
|
@startuml
|
||||||
|
class Assessor << (F,LightGreen) >> #RoyalBlue {
|
||||||
|
# Data $data
|
||||||
|
# Status $status
|
||||||
|
# Message $message
|
||||||
|
+ __construct(Data $data, Status $status, ...)
|
||||||
|
+ evaluate(int $rowCounter, int $successCounter, ...) : void
|
||||||
|
}
|
||||||
|
|
||||||
|
note right of Assessor::__construct
|
||||||
|
Constructor.
|
||||||
|
|
||||||
|
since: 4.0.3
|
||||||
|
|
||||||
|
arguments:
|
||||||
|
Data $data
|
||||||
|
Status $status
|
||||||
|
Message $message
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Assessor::evaluate
|
||||||
|
Evaluates the import process and sets the success/error message based on the success rate.
|
||||||
|
|
||||||
|
since: 4.0.3
|
||||||
|
return: void
|
||||||
|
|
||||||
|
arguments:
|
||||||
|
int $rowCounter
|
||||||
|
int $successCounter
|
||||||
|
int $errorCounter
|
||||||
|
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---19a66b48_620c_439b_ab8a_3c0d43e040c3---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)
|
||||||
|
|
129
src/19a66b48-620c-439b-ab8a-3c0d43e040c3/code.php
Normal file
129
src/19a66b48-620c-439b-ab8a-3c0d43e040c3/code.php
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 4th September, 2022
|
||||||
|
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||||
|
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||||
|
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||||
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace VDM\Joomla\Componentbuilder\Import;
|
||||||
|
|
||||||
|
|
||||||
|
use VDM\Joomla\Componentbuilder\Import\Data;
|
||||||
|
use VDM\Joomla\Componentbuilder\Interfaces\ImportStatusInterface as Status;
|
||||||
|
use VDM\Joomla\Componentbuilder\Interfaces\ImportMessageInterface as Message;
|
||||||
|
use VDM\Joomla\Componentbuilder\Interfaces\ImportAssessorInterface;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Import Assessor Class
|
||||||
|
*
|
||||||
|
* @since 4.0.3
|
||||||
|
*/
|
||||||
|
final class Assessor implements ImportAssessorInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The Data Class.
|
||||||
|
*
|
||||||
|
* @var Data
|
||||||
|
* @since 4.0.3
|
||||||
|
*/
|
||||||
|
protected Data $data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Import Status Class.
|
||||||
|
*
|
||||||
|
* @var Status
|
||||||
|
* @since 4.0.3
|
||||||
|
*/
|
||||||
|
protected Status $status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Import Message Class.
|
||||||
|
*
|
||||||
|
* @var Message
|
||||||
|
* @since 4.0.3
|
||||||
|
*/
|
||||||
|
protected Message $message;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constants for defining the success threshold
|
||||||
|
* Minimum success rate to consider the import successful
|
||||||
|
*
|
||||||
|
* @since 4.0.3
|
||||||
|
*/
|
||||||
|
private const SUCCESS_THRESHOLD = 0.80;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param Data $data The Data Class.
|
||||||
|
* @param Status $status The Import Status Class.
|
||||||
|
* @param Message $message The Import Message Class.
|
||||||
|
*
|
||||||
|
* @since 4.0.3
|
||||||
|
*/
|
||||||
|
public function __construct(Data $data, Status $status, Message $message)
|
||||||
|
{
|
||||||
|
$this->data = $data;
|
||||||
|
$this->status = $status;
|
||||||
|
$this->message = $message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Evaluates the import process and sets the success/error message based on the success rate.
|
||||||
|
*
|
||||||
|
* @param int $rowCounter Total number of rows processed.
|
||||||
|
* @param int $successCounter Number of successfully processed rows.
|
||||||
|
* @param int $errorCounter Number of rows that failed to process.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 4.0.3
|
||||||
|
*/
|
||||||
|
public function evaluate(int $rowCounter, int $successCounter, int $errorCounter): void
|
||||||
|
{
|
||||||
|
// No rows processed case
|
||||||
|
if ($rowCounter === 0)
|
||||||
|
{
|
||||||
|
$this->message->addError(Text::_('COM_COMPONENTBUILDER_NO_ROWS_WERE_PROCESSED'));
|
||||||
|
|
||||||
|
if (($guid = $this->data->get('import.guid')) !== null)
|
||||||
|
{
|
||||||
|
$this->status->set(4, $guid); // Status 4 => completed with errors
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$successRate = $successCounter / $rowCounter;
|
||||||
|
$errorRate = (1 - $successRate) * 100;
|
||||||
|
$successPercentage = $successRate * 100;
|
||||||
|
|
||||||
|
// Determine appropriate message based on success rate
|
||||||
|
if ($successRate >= self::SUCCESS_THRESHOLD)
|
||||||
|
{
|
||||||
|
$this->message->addSuccess(Text::sprintf('COM_COMPONENTBUILDER_D_ROWS_PROCESSED_SUCCESS_RATE_TWOF_IMPORT_SUCCESSFUL',
|
||||||
|
$rowCounter,
|
||||||
|
$successPercentage
|
||||||
|
));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->message->addError(Text::sprintf('COM_COMPONENTBUILDER_IMPORT_FAILED_D_ROWS_PROCESSED_WITH_ONLY_D_SUCCESSES_ERROR_RATE_TWOF',
|
||||||
|
$rowCounter,
|
||||||
|
$successCounter,
|
||||||
|
$errorRate
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (($guid = $this->data->get('import.guid')) !== null)
|
||||||
|
{
|
||||||
|
// Update import status based on success rate
|
||||||
|
$importStatus = ($successPercentage == 100) ? 3 : 4; // 3 => completed, 4 => completed with errors
|
||||||
|
$this->status->set($importStatus, $guid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
100
src/19a66b48-620c-439b-ab8a-3c0d43e040c3/code.power
Normal file
100
src/19a66b48-620c-439b-ab8a-3c0d43e040c3/code.power
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
/**
|
||||||
|
* The Data Class.
|
||||||
|
*
|
||||||
|
* @var Data
|
||||||
|
* @since 4.0.3
|
||||||
|
*/
|
||||||
|
protected Data $data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Import Status Class.
|
||||||
|
*
|
||||||
|
* @var Status
|
||||||
|
* @since 4.0.3
|
||||||
|
*/
|
||||||
|
protected Status $status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Import Message Class.
|
||||||
|
*
|
||||||
|
* @var Message
|
||||||
|
* @since 4.0.3
|
||||||
|
*/
|
||||||
|
protected Message $message;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constants for defining the success threshold
|
||||||
|
* Minimum success rate to consider the import successful
|
||||||
|
*
|
||||||
|
* @since 4.0.3
|
||||||
|
*/
|
||||||
|
private const SUCCESS_THRESHOLD = 0.80;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param Data $data The Data Class.
|
||||||
|
* @param Status $status The Import Status Class.
|
||||||
|
* @param Message $message The Import Message Class.
|
||||||
|
*
|
||||||
|
* @since 4.0.3
|
||||||
|
*/
|
||||||
|
public function __construct(Data $data, Status $status, Message $message)
|
||||||
|
{
|
||||||
|
$this->data = $data;
|
||||||
|
$this->status = $status;
|
||||||
|
$this->message = $message;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Evaluates the import process and sets the success/error message based on the success rate.
|
||||||
|
*
|
||||||
|
* @param int $rowCounter Total number of rows processed.
|
||||||
|
* @param int $successCounter Number of successfully processed rows.
|
||||||
|
* @param int $errorCounter Number of rows that failed to process.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 4.0.3
|
||||||
|
*/
|
||||||
|
public function evaluate(int $rowCounter, int $successCounter, int $errorCounter): void
|
||||||
|
{
|
||||||
|
// No rows processed case
|
||||||
|
if ($rowCounter === 0)
|
||||||
|
{
|
||||||
|
$this->message->addError(Text::_('No rows were processed.'));
|
||||||
|
|
||||||
|
if (($guid = $this->data->get('import.guid')) !== null)
|
||||||
|
{
|
||||||
|
$this->status->set(4, $guid); // Status 4 => completed with errors
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$successRate = $successCounter / $rowCounter;
|
||||||
|
$errorRate = (1 - $successRate) * 100;
|
||||||
|
$successPercentage = $successRate * 100;
|
||||||
|
|
||||||
|
// Determine appropriate message based on success rate
|
||||||
|
if ($successRate >= self::SUCCESS_THRESHOLD)
|
||||||
|
{
|
||||||
|
$this->message->addSuccess(Text::sprintf('%d rows processed. Success rate: %.2f%%. Import successful!',
|
||||||
|
$rowCounter,
|
||||||
|
$successPercentage
|
||||||
|
));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->message->addError(Text::sprintf('Import failed. %d rows processed with only %d successes. Error rate: %.2f%%.',
|
||||||
|
$rowCounter,
|
||||||
|
$successCounter,
|
||||||
|
$errorRate
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (($guid = $this->data->get('import.guid')) !== null)
|
||||||
|
{
|
||||||
|
// Update import status based on success rate
|
||||||
|
$importStatus = ($successPercentage == 100) ? 3 : 4; // 3 => completed, 4 => completed with errors
|
||||||
|
$this->status->set($importStatus, $guid);
|
||||||
|
}
|
||||||
|
}
|
34
src/19a66b48-620c-439b-ab8a-3c0d43e040c3/settings.json
Normal file
34
src/19a66b48-620c-439b-ab8a-3c0d43e040c3/settings.json
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
{
|
||||||
|
"add_head": "0",
|
||||||
|
"add_licensing_template": "2",
|
||||||
|
"extends": "",
|
||||||
|
"guid": "19a66b48-620c-439b-ab8a-3c0d43e040c3",
|
||||||
|
"implements": [
|
||||||
|
"57c00d53-5581-4fd1-b3ea-080422710243"
|
||||||
|
],
|
||||||
|
"load_selection": null,
|
||||||
|
"name": "Assessor",
|
||||||
|
"power_version": "1.0.0",
|
||||||
|
"system_name": "JCB.Import.Assessor",
|
||||||
|
"type": "final class",
|
||||||
|
"use_selection": {
|
||||||
|
"use_selection0": {
|
||||||
|
"use": "05f23281-58e3-482e-be42-2dc1355ef4ea",
|
||||||
|
"as": "default"
|
||||||
|
},
|
||||||
|
"use_selection1": {
|
||||||
|
"use": "0e44d149-4863-47ec-8f0f-6a821ab3e77f",
|
||||||
|
"as": "Status"
|
||||||
|
},
|
||||||
|
"use_selection2": {
|
||||||
|
"use": "23ad6e72-1b82-40fb-836c-50da690bb174",
|
||||||
|
"as": "Message"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"extendsinterfaces": null,
|
||||||
|
"namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Import.Assessor",
|
||||||
|
"description": "Import Assessor Class\r\n\r\n@since 4.0.3",
|
||||||
|
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/joomla\/Component-Builder>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
|
||||||
|
"head": "",
|
||||||
|
"composer": ""
|
||||||
|
}
|
@ -13,10 +13,13 @@
|
|||||||
@startuml
|
@startuml
|
||||||
class Import #Gold {
|
class Import #Gold {
|
||||||
+ register(Container $container) : void
|
+ register(Container $container) : void
|
||||||
|
+ getData(Container $container) : Data
|
||||||
|
+ getMapper(Container $container) : Mapper
|
||||||
+ getRow(Container $container) : Row
|
+ getRow(Container $container) : Row
|
||||||
+ getItem(Container $container) : Item
|
+ getItem(Container $container) : Item
|
||||||
+ getMessage(Container $container) : Message
|
+ getMessage(Container $container) : Message
|
||||||
+ getStatus(Container $container) : Status
|
+ getStatus(Container $container) : Status
|
||||||
|
+ getAssessor(Container $container) : Assessor
|
||||||
}
|
}
|
||||||
|
|
||||||
note right of Import::register
|
note right of Import::register
|
||||||
@ -26,7 +29,21 @@ note right of Import::register
|
|||||||
return: void
|
return: void
|
||||||
end note
|
end note
|
||||||
|
|
||||||
note right of Import::getRow
|
note left of Import::getData
|
||||||
|
Get The Data Class.
|
||||||
|
|
||||||
|
since: 5.0.3
|
||||||
|
return: Data
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Import::getMapper
|
||||||
|
Get The Mapper Class.
|
||||||
|
|
||||||
|
since: 5.0.3
|
||||||
|
return: Mapper
|
||||||
|
end note
|
||||||
|
|
||||||
|
note left of Import::getRow
|
||||||
Get The Row Class.
|
Get The Row Class.
|
||||||
|
|
||||||
since: 5.0.3
|
since: 5.0.3
|
||||||
@ -40,7 +57,7 @@ note right of Import::getItem
|
|||||||
return: Item
|
return: Item
|
||||||
end note
|
end note
|
||||||
|
|
||||||
note right of Import::getMessage
|
note left of Import::getMessage
|
||||||
Get The Message Class.
|
Get The Message Class.
|
||||||
|
|
||||||
since: 5.0.3
|
since: 5.0.3
|
||||||
@ -54,6 +71,13 @@ note right of Import::getStatus
|
|||||||
return: Status
|
return: Status
|
||||||
end note
|
end note
|
||||||
|
|
||||||
|
note left of Import::getAssessor
|
||||||
|
Get The Assessor Class.
|
||||||
|
|
||||||
|
since: 5.0.3
|
||||||
|
return: Assessor
|
||||||
|
end note
|
||||||
|
|
||||||
@enduml
|
@enduml
|
||||||
```
|
```
|
||||||
|
|
||||||
|
@ -14,10 +14,13 @@ namespace VDM\Joomla\Componentbuilder\Import\Service;
|
|||||||
|
|
||||||
use Joomla\DI\Container;
|
use Joomla\DI\Container;
|
||||||
use Joomla\DI\ServiceProviderInterface;
|
use Joomla\DI\ServiceProviderInterface;
|
||||||
|
use VDM\Joomla\Componentbuilder\Import\Data;
|
||||||
|
use VDM\Joomla\Componentbuilder\Import\Mapper;
|
||||||
use VDM\Joomla\Componentbuilder\Import\Row;
|
use VDM\Joomla\Componentbuilder\Import\Row;
|
||||||
use VDM\Joomla\Componentbuilder\Import\Item;
|
use VDM\Joomla\Componentbuilder\Import\Item;
|
||||||
use VDM\Joomla\Componentbuilder\Import\Message;
|
use VDM\Joomla\Componentbuilder\Import\Message;
|
||||||
use VDM\Joomla\Componentbuilder\Import\Status;
|
use VDM\Joomla\Componentbuilder\Import\Status;
|
||||||
|
use VDM\Joomla\Componentbuilder\Import\Assessor;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -37,6 +40,12 @@ class Import implements ServiceProviderInterface
|
|||||||
*/
|
*/
|
||||||
public function register(Container $container)
|
public function register(Container $container)
|
||||||
{
|
{
|
||||||
|
$container->alias(Data::class, 'Import.Data')
|
||||||
|
->share('Import.Data', [$this, 'getData'], true);
|
||||||
|
|
||||||
|
$container->alias(Mapper::class, 'Import.Mapper')
|
||||||
|
->share('Import.Mapper', [$this, 'getMapper'], true);
|
||||||
|
|
||||||
$container->alias(Row::class, 'Import.Row')
|
$container->alias(Row::class, 'Import.Row')
|
||||||
->share('Import.Row', [$this, 'getRow'], true);
|
->share('Import.Row', [$this, 'getRow'], true);
|
||||||
|
|
||||||
@ -48,6 +57,37 @@ class Import implements ServiceProviderInterface
|
|||||||
|
|
||||||
$container->alias(Status::class, 'Import.Status')
|
$container->alias(Status::class, 'Import.Status')
|
||||||
->share('Import.Status', [$this, 'getStatus'], true);
|
->share('Import.Status', [$this, 'getStatus'], true);
|
||||||
|
|
||||||
|
$container->alias(Assessor::class, 'Import.Assessor')
|
||||||
|
->share('Import.Assessor', [$this, 'getAssessor'], true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get The Data Class.
|
||||||
|
*
|
||||||
|
* @param Container $container The DI container.
|
||||||
|
*
|
||||||
|
* @return Data
|
||||||
|
* @since 5.0.3
|
||||||
|
*/
|
||||||
|
public function getData(Container $container): Data
|
||||||
|
{
|
||||||
|
return new Data();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get The Mapper Class.
|
||||||
|
*
|
||||||
|
* @param Container $container The DI container.
|
||||||
|
*
|
||||||
|
* @return Mapper
|
||||||
|
* @since 5.0.3
|
||||||
|
*/
|
||||||
|
public function getMapper(Container $container): Mapper
|
||||||
|
{
|
||||||
|
return new Mapper(
|
||||||
|
$container->get('Table')
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -110,5 +150,22 @@ class Import implements ServiceProviderInterface
|
|||||||
$container->get('Data.Item')
|
$container->get('Data.Item')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get The Assessor Class.
|
||||||
|
*
|
||||||
|
* @param Container $container The DI container.
|
||||||
|
*
|
||||||
|
* @return Assessor
|
||||||
|
* @since 5.0.3
|
||||||
|
*/
|
||||||
|
public function getAssessor(Container $container): Assessor
|
||||||
|
{
|
||||||
|
return new Assessor(
|
||||||
|
$container->get('Import.Data'),
|
||||||
|
$container->get('Import.Status'),
|
||||||
|
$container->get('Import.Message')
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,6 +8,12 @@
|
|||||||
*/
|
*/
|
||||||
public function register(Container $container)
|
public function register(Container $container)
|
||||||
{
|
{
|
||||||
|
$container->alias(Data::class, 'Import.Data')
|
||||||
|
->share('Import.Data', [$this, 'getData'], true);
|
||||||
|
|
||||||
|
$container->alias(Mapper::class, 'Import.Mapper')
|
||||||
|
->share('Import.Mapper', [$this, 'getMapper'], true);
|
||||||
|
|
||||||
$container->alias(Row::class, 'Import.Row')
|
$container->alias(Row::class, 'Import.Row')
|
||||||
->share('Import.Row', [$this, 'getRow'], true);
|
->share('Import.Row', [$this, 'getRow'], true);
|
||||||
|
|
||||||
@ -19,6 +25,37 @@
|
|||||||
|
|
||||||
$container->alias(Status::class, 'Import.Status')
|
$container->alias(Status::class, 'Import.Status')
|
||||||
->share('Import.Status', [$this, 'getStatus'], true);
|
->share('Import.Status', [$this, 'getStatus'], true);
|
||||||
|
|
||||||
|
$container->alias(Assessor::class, 'Import.Assessor')
|
||||||
|
->share('Import.Assessor', [$this, 'getAssessor'], true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get The Data Class.
|
||||||
|
*
|
||||||
|
* @param Container $container The DI container.
|
||||||
|
*
|
||||||
|
* @return Data
|
||||||
|
* @since 5.0.3
|
||||||
|
*/
|
||||||
|
public function getData(Container $container): Data
|
||||||
|
{
|
||||||
|
return new Data();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get The Mapper Class.
|
||||||
|
*
|
||||||
|
* @param Container $container The DI container.
|
||||||
|
*
|
||||||
|
* @return Mapper
|
||||||
|
* @since 5.0.3
|
||||||
|
*/
|
||||||
|
public function getMapper(Container $container): Mapper
|
||||||
|
{
|
||||||
|
return new Mapper(
|
||||||
|
$container->get('Table')
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -81,3 +118,20 @@
|
|||||||
$container->get('Data.Item')
|
$container->get('Data.Item')
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get The Assessor Class.
|
||||||
|
*
|
||||||
|
* @param Container $container The DI container.
|
||||||
|
*
|
||||||
|
* @return Assessor
|
||||||
|
* @since 5.0.3
|
||||||
|
*/
|
||||||
|
public function getAssessor(Container $container): Assessor
|
||||||
|
{
|
||||||
|
return new Assessor(
|
||||||
|
$container->get('Import.Data'),
|
||||||
|
$container->get('Import.Status'),
|
||||||
|
$container->get('Import.Message')
|
||||||
|
);
|
||||||
|
}
|
@ -13,20 +13,32 @@
|
|||||||
"type": "class",
|
"type": "class",
|
||||||
"use_selection": {
|
"use_selection": {
|
||||||
"use_selection0": {
|
"use_selection0": {
|
||||||
"use": "afb5b891-7130-422a-b389-1934b0e4fc48",
|
"use": "05f23281-58e3-482e-be42-2dc1355ef4ea",
|
||||||
"as": "default"
|
"as": "default"
|
||||||
},
|
},
|
||||||
"use_selection1": {
|
"use_selection1": {
|
||||||
"use": "68a0f9af-265a-4db1-bae9-a4e4531f94d7",
|
"use": "90b48ea8-0930-48d1-869a-bce9c901589c",
|
||||||
"as": "default"
|
"as": "default"
|
||||||
},
|
},
|
||||||
"use_selection2": {
|
"use_selection2": {
|
||||||
"use": "eef6ffc2-2af0-4336-958f-e0b9cf7c4ad0",
|
"use": "afb5b891-7130-422a-b389-1934b0e4fc48",
|
||||||
"as": "default"
|
"as": "default"
|
||||||
},
|
},
|
||||||
"use_selection3": {
|
"use_selection3": {
|
||||||
|
"use": "68a0f9af-265a-4db1-bae9-a4e4531f94d7",
|
||||||
|
"as": "default"
|
||||||
|
},
|
||||||
|
"use_selection4": {
|
||||||
|
"use": "eef6ffc2-2af0-4336-958f-e0b9cf7c4ad0",
|
||||||
|
"as": "default"
|
||||||
|
},
|
||||||
|
"use_selection5": {
|
||||||
"use": "d2a859ac-3f2a-4f69-a77f-f118b2e0a459",
|
"use": "d2a859ac-3f2a-4f69-a77f-f118b2e0a459",
|
||||||
"as": "default"
|
"as": "default"
|
||||||
|
},
|
||||||
|
"use_selection6": {
|
||||||
|
"use": "19a66b48-620c-439b-ab8a-3c0d43e040c3",
|
||||||
|
"as": "default"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"extendsinterfaces": null,
|
"extendsinterfaces": null,
|
||||||
|
68
src/250a7272-9ae1-4c63-a058-26bad9ad6f70/README.md
Normal file
68
src/250a7272-9ae1-4c63-a058-26bad9ad6f70/README.md
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
```
|
||||||
|
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||||
|
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||||
|
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||||
|
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||||
|
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||||
|
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||||
|
```
|
||||||
|
# interface ImportMapperInterface (Details)
|
||||||
|
> namespace: **VDM\Joomla\Componentbuilder\Interfaces**
|
||||||
|
|
||||||
|
```uml
|
||||||
|
@startuml
|
||||||
|
interface ImportMapperInterface #Lavender {
|
||||||
|
+ set(object $map, string $parentTable) : void
|
||||||
|
+ getParent() : array
|
||||||
|
+ getJoin() : array
|
||||||
|
}
|
||||||
|
|
||||||
|
note right of ImportMapperInterface::set
|
||||||
|
Set the tables mapper
|
||||||
|
|
||||||
|
since: 4.0.3
|
||||||
|
return: void
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of ImportMapperInterface::getParent
|
||||||
|
Get the parent table keys
|
||||||
|
|
||||||
|
since: 4.0.3
|
||||||
|
return: array
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of ImportMapperInterface::getJoin
|
||||||
|
Get the join tables keys
|
||||||
|
|
||||||
|
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---250a7272_9ae1_4c63_a058_26bad9ad6f70---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)
|
||||||
|
|
49
src/250a7272-9ae1-4c63-a058-26bad9ad6f70/code.php
Normal file
49
src/250a7272-9ae1-4c63-a058-26bad9ad6f70/code.php
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 4th September, 2022
|
||||||
|
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||||
|
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||||
|
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||||
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace VDM\Joomla\Componentbuilder\Interfaces;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Import Mapper Interface
|
||||||
|
*
|
||||||
|
* @since 3.0.3
|
||||||
|
*/
|
||||||
|
interface ImportMapperInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Set the tables mapper
|
||||||
|
*
|
||||||
|
* @param object $map The import file map.
|
||||||
|
* @param string $parentTable The parent table name.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 4.0.3
|
||||||
|
*/
|
||||||
|
public function set(object $map, string $parentTable): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the parent table keys
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
* @since 4.0.3
|
||||||
|
*/
|
||||||
|
public function getParent(): array;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the join tables keys
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
* @since 4.0.3
|
||||||
|
*/
|
||||||
|
public function getJoin(): array;
|
||||||
|
}
|
||||||
|
|
26
src/250a7272-9ae1-4c63-a058-26bad9ad6f70/code.power
Normal file
26
src/250a7272-9ae1-4c63-a058-26bad9ad6f70/code.power
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
/**
|
||||||
|
* Set the tables mapper
|
||||||
|
*
|
||||||
|
* @param object $map The import file map.
|
||||||
|
* @param string $parentTable The parent table name.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 4.0.3
|
||||||
|
*/
|
||||||
|
public function set(object $map, string $parentTable): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the parent table keys
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
* @since 4.0.3
|
||||||
|
*/
|
||||||
|
public function getParent(): array;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the join tables keys
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
* @since 4.0.3
|
||||||
|
*/
|
||||||
|
public function getJoin(): array;
|
19
src/250a7272-9ae1-4c63-a058-26bad9ad6f70/settings.json
Normal file
19
src/250a7272-9ae1-4c63-a058-26bad9ad6f70/settings.json
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"add_head": "0",
|
||||||
|
"add_licensing_template": "2",
|
||||||
|
"extends": "",
|
||||||
|
"guid": "250a7272-9ae1-4c63-a058-26bad9ad6f70",
|
||||||
|
"implements": null,
|
||||||
|
"load_selection": null,
|
||||||
|
"name": "ImportMapperInterface",
|
||||||
|
"power_version": "1.0.0",
|
||||||
|
"system_name": "VDM.ImportMapperInterface",
|
||||||
|
"type": "interface",
|
||||||
|
"use_selection": null,
|
||||||
|
"extendsinterfaces": null,
|
||||||
|
"namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Interfaces.ImportMapperInterface",
|
||||||
|
"description": "Import Mapper 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 <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/joomla\/Component-Builder>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
|
||||||
|
"head": "",
|
||||||
|
"composer": ""
|
||||||
|
}
|
57
src/57c00d53-5581-4fd1-b3ea-080422710243/README.md
Normal file
57
src/57c00d53-5581-4fd1-b3ea-080422710243/README.md
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
```
|
||||||
|
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||||
|
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||||
|
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||||
|
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||||
|
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||||
|
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||||
|
```
|
||||||
|
# interface ImportAssessorInterface (Details)
|
||||||
|
> namespace: **VDM\Joomla\Componentbuilder\Interfaces**
|
||||||
|
|
||||||
|
```uml
|
||||||
|
@startuml
|
||||||
|
interface ImportAssessorInterface #Lavender {
|
||||||
|
+ evaluate(int $rowCounter, int $successCounter, ...) : void
|
||||||
|
}
|
||||||
|
|
||||||
|
note right of ImportAssessorInterface::evaluate
|
||||||
|
Evaluates the import process and sets the success/error message based on the success rate.
|
||||||
|
|
||||||
|
since: 4.0.3
|
||||||
|
return: void
|
||||||
|
|
||||||
|
arguments:
|
||||||
|
int $rowCounter
|
||||||
|
int $successCounter
|
||||||
|
int $errorCounter
|
||||||
|
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---57c00d53_5581_4fd1_b3ea_080422710243---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)
|
||||||
|
|
34
src/57c00d53-5581-4fd1-b3ea-080422710243/code.php
Normal file
34
src/57c00d53-5581-4fd1-b3ea-080422710243/code.php
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 4th September, 2022
|
||||||
|
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||||
|
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||||
|
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||||
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace VDM\Joomla\Componentbuilder\Interfaces;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Import Assessor Interface
|
||||||
|
*
|
||||||
|
* @since 3.0.3
|
||||||
|
*/
|
||||||
|
interface ImportAssessorInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Evaluates the import process and sets the success/error message based on the success rate.
|
||||||
|
*
|
||||||
|
* @param int $rowCounter Total number of rows processed.
|
||||||
|
* @param int $successCounter Number of successfully processed rows.
|
||||||
|
* @param int $errorCounter Number of rows that failed to process.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 4.0.3
|
||||||
|
*/
|
||||||
|
public function evaluate(int $rowCounter, int $successCounter, int $errorCounter): void;
|
||||||
|
}
|
||||||
|
|
11
src/57c00d53-5581-4fd1-b3ea-080422710243/code.power
Normal file
11
src/57c00d53-5581-4fd1-b3ea-080422710243/code.power
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
/**
|
||||||
|
* Evaluates the import process and sets the success/error message based on the success rate.
|
||||||
|
*
|
||||||
|
* @param int $rowCounter Total number of rows processed.
|
||||||
|
* @param int $successCounter Number of successfully processed rows.
|
||||||
|
* @param int $errorCounter Number of rows that failed to process.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 4.0.3
|
||||||
|
*/
|
||||||
|
public function evaluate(int $rowCounter, int $successCounter, int $errorCounter): void;
|
19
src/57c00d53-5581-4fd1-b3ea-080422710243/settings.json
Normal file
19
src/57c00d53-5581-4fd1-b3ea-080422710243/settings.json
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"add_head": "0",
|
||||||
|
"add_licensing_template": "2",
|
||||||
|
"extends": "",
|
||||||
|
"guid": "57c00d53-5581-4fd1-b3ea-080422710243",
|
||||||
|
"implements": null,
|
||||||
|
"load_selection": null,
|
||||||
|
"name": "ImportAssessorInterface",
|
||||||
|
"power_version": "1.0.0",
|
||||||
|
"system_name": "VDM.ImportAssessorInterface",
|
||||||
|
"type": "interface",
|
||||||
|
"use_selection": null,
|
||||||
|
"extendsinterfaces": null,
|
||||||
|
"namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Interfaces.ImportAssessorInterface",
|
||||||
|
"description": "Import Assessor 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 <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/joomla\/Component-Builder>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
|
||||||
|
"head": "",
|
||||||
|
"composer": ""
|
||||||
|
}
|
86
src/90b48ea8-0930-48d1-869a-bce9c901589c/README.md
Normal file
86
src/90b48ea8-0930-48d1-869a-bce9c901589c/README.md
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
```
|
||||||
|
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||||
|
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||||
|
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||||
|
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||||
|
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||||
|
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||||
|
```
|
||||||
|
# final class Mapper (Details)
|
||||||
|
> namespace: **VDM\Joomla\Componentbuilder\Import**
|
||||||
|
|
||||||
|
```uml
|
||||||
|
@startuml
|
||||||
|
class Mapper << (F,LightGreen) >> #RoyalBlue {
|
||||||
|
# Table $table
|
||||||
|
- array $parent
|
||||||
|
- array $join
|
||||||
|
+ __construct(Table $table)
|
||||||
|
+ set(object $map, string $parentTable) : void
|
||||||
|
+ getParent() : array
|
||||||
|
+ getJoin() : array
|
||||||
|
- getTableField(string $key) : ?object
|
||||||
|
}
|
||||||
|
|
||||||
|
note right of Mapper::__construct
|
||||||
|
Constructor.
|
||||||
|
|
||||||
|
since: 4.0.3
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Mapper::set
|
||||||
|
Set the tables mapper
|
||||||
|
|
||||||
|
since: 4.0.3
|
||||||
|
return: void
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Mapper::getParent
|
||||||
|
Get the parent table keys
|
||||||
|
|
||||||
|
since: 4.0.3
|
||||||
|
return: array
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Mapper::getJoin
|
||||||
|
Get the join tables keys
|
||||||
|
|
||||||
|
since: 4.0.3
|
||||||
|
return: array
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Mapper::getTableField
|
||||||
|
Get the table and field name
|
||||||
|
|
||||||
|
since: 4.0.3
|
||||||
|
return: ?object
|
||||||
|
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---90b48ea8_0930_48d1_869a_bce9c901589c---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)
|
||||||
|
|
154
src/90b48ea8-0930-48d1-869a-bce9c901589c/code.php
Normal file
154
src/90b48ea8-0930-48d1-869a-bce9c901589c/code.php
Normal file
@ -0,0 +1,154 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 4th September, 2022
|
||||||
|
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||||
|
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||||
|
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||||
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace VDM\Joomla\Componentbuilder\Import;
|
||||||
|
|
||||||
|
|
||||||
|
use VDM\Joomla\Interfaces\TableInterface as Table;
|
||||||
|
use VDM\Joomla\Componentbuilder\Interfaces\ImportMapperInterface;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Import Mapper Class
|
||||||
|
*
|
||||||
|
* @since 4.0.3
|
||||||
|
*/
|
||||||
|
final class Mapper implements ImportMapperInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The Table Class.
|
||||||
|
*
|
||||||
|
* @var Table
|
||||||
|
* @since 4.0.3
|
||||||
|
*/
|
||||||
|
protected Table $table;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current parent table map.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @since 4.0.3
|
||||||
|
*/
|
||||||
|
private array $parent = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current join tables map.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @since 4.0.3
|
||||||
|
*/
|
||||||
|
private array $join = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param Table $table The Table Class.
|
||||||
|
*
|
||||||
|
* @since 4.0.3
|
||||||
|
*/
|
||||||
|
public function __construct(Table $table)
|
||||||
|
{
|
||||||
|
$this->table = $table;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the tables mapper
|
||||||
|
*
|
||||||
|
* @param object $map The import file map.
|
||||||
|
* @param string $parentTable The parent table name.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 4.0.3
|
||||||
|
*/
|
||||||
|
public function set(object $map, string $parentTable): void
|
||||||
|
{
|
||||||
|
// always reset these
|
||||||
|
$this->parent = [];
|
||||||
|
$this->join = [];
|
||||||
|
|
||||||
|
foreach ($map as $row)
|
||||||
|
{
|
||||||
|
$target = $row->target ?? null;
|
||||||
|
|
||||||
|
if (empty($target))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (($tm = $this->getTableField($target)) !== null)
|
||||||
|
{
|
||||||
|
$field = $this->table->get($tm->table, $tm->field);
|
||||||
|
if ($tm->table === $parentTable)
|
||||||
|
{
|
||||||
|
$this->parent[$row->column] = $field;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->join[$tm->table][$row->column] = $field;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the parent table keys
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
* @since 4.0.3
|
||||||
|
*/
|
||||||
|
public function getParent(): array
|
||||||
|
{
|
||||||
|
return $this->parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the join tables keys
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
* @since 4.0.3
|
||||||
|
*/
|
||||||
|
public function getJoin(): array
|
||||||
|
{
|
||||||
|
return $this->join;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the table and field name
|
||||||
|
*
|
||||||
|
* @param string $key The import file key.
|
||||||
|
*
|
||||||
|
* @return object|null
|
||||||
|
* @since 4.0.3
|
||||||
|
*/
|
||||||
|
private function getTableField(string $key): ?object
|
||||||
|
{
|
||||||
|
// Find the position of the first dot
|
||||||
|
$dotPosition = strpos($key, '.');
|
||||||
|
|
||||||
|
// If no dot is found, return the whole string
|
||||||
|
if ($dotPosition === false)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extract the table (before the dot) and the field (after the dot)
|
||||||
|
$table = substr($key, 0, $dotPosition);
|
||||||
|
$field = substr($key, $dotPosition + 1);
|
||||||
|
|
||||||
|
if ($this->table->exist($table ?? '_error', $field))
|
||||||
|
{
|
||||||
|
return (object) ['table' => $table, 'field' => $field];
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
127
src/90b48ea8-0930-48d1-869a-bce9c901589c/code.power
Normal file
127
src/90b48ea8-0930-48d1-869a-bce9c901589c/code.power
Normal file
@ -0,0 +1,127 @@
|
|||||||
|
/**
|
||||||
|
* The Table Class.
|
||||||
|
*
|
||||||
|
* @var Table
|
||||||
|
* @since 4.0.3
|
||||||
|
*/
|
||||||
|
protected Table $table;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current parent table map.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @since 4.0.3
|
||||||
|
*/
|
||||||
|
private array $parent = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The current join tables map.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @since 4.0.3
|
||||||
|
*/
|
||||||
|
private array $join = [];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param Table $table The Table Class.
|
||||||
|
*
|
||||||
|
* @since 4.0.3
|
||||||
|
*/
|
||||||
|
public function __construct(Table $table)
|
||||||
|
{
|
||||||
|
$this->table = $table;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the tables mapper
|
||||||
|
*
|
||||||
|
* @param object $map The import file map.
|
||||||
|
* @param string $parentTable The parent table name.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 4.0.3
|
||||||
|
*/
|
||||||
|
public function set(object $map, string $parentTable): void
|
||||||
|
{
|
||||||
|
// always reset these
|
||||||
|
$this->parent = [];
|
||||||
|
$this->join = [];
|
||||||
|
|
||||||
|
foreach ($map as $row)
|
||||||
|
{
|
||||||
|
$target = $row->target ?? null;
|
||||||
|
|
||||||
|
if (empty($target))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (($tm = $this->getTableField($target)) !== null)
|
||||||
|
{
|
||||||
|
$field = $this->table->get($tm->table, $tm->field);
|
||||||
|
if ($tm->table === $parentTable)
|
||||||
|
{
|
||||||
|
$this->parent[$row->column] = $field;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->join[$tm->table][$row->column] = $field;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the parent table keys
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
* @since 4.0.3
|
||||||
|
*/
|
||||||
|
public function getParent(): array
|
||||||
|
{
|
||||||
|
return $this->parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the join tables keys
|
||||||
|
*
|
||||||
|
* @return array
|
||||||
|
* @since 4.0.3
|
||||||
|
*/
|
||||||
|
public function getJoin(): array
|
||||||
|
{
|
||||||
|
return $this->join;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the table and field name
|
||||||
|
*
|
||||||
|
* @param string $key The import file key.
|
||||||
|
*
|
||||||
|
* @return object|null
|
||||||
|
* @since 4.0.3
|
||||||
|
*/
|
||||||
|
private function getTableField(string $key): ?object
|
||||||
|
{
|
||||||
|
// Find the position of the first dot
|
||||||
|
$dotPosition = strpos($key, '.');
|
||||||
|
|
||||||
|
// If no dot is found, return the whole string
|
||||||
|
if ($dotPosition === false)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extract the table (before the dot) and the field (after the dot)
|
||||||
|
$table = substr($key, 0, $dotPosition);
|
||||||
|
$field = substr($key, $dotPosition + 1);
|
||||||
|
|
||||||
|
if ($this->table->exist($table ?? '_error', $field))
|
||||||
|
{
|
||||||
|
return (object) ['table' => $table, 'field' => $field];
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
26
src/90b48ea8-0930-48d1-869a-bce9c901589c/settings.json
Normal file
26
src/90b48ea8-0930-48d1-869a-bce9c901589c/settings.json
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"add_head": "0",
|
||||||
|
"add_licensing_template": "2",
|
||||||
|
"extends": "",
|
||||||
|
"guid": "90b48ea8-0930-48d1-869a-bce9c901589c",
|
||||||
|
"implements": [
|
||||||
|
"250a7272-9ae1-4c63-a058-26bad9ad6f70"
|
||||||
|
],
|
||||||
|
"load_selection": null,
|
||||||
|
"name": "Mapper",
|
||||||
|
"power_version": "1.0.0",
|
||||||
|
"system_name": "JCB.Import.Mapper",
|
||||||
|
"type": "final class",
|
||||||
|
"use_selection": {
|
||||||
|
"use_selection0": {
|
||||||
|
"use": "2da6d6c4-eb29-4d69-8bc2-36d96e916adf",
|
||||||
|
"as": "Table"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"extendsinterfaces": null,
|
||||||
|
"namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Import.Mapper",
|
||||||
|
"description": "Import Mapper Class\r\n\r\n@since 4.0.3",
|
||||||
|
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/joomla\/Component-Builder>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
|
||||||
|
"head": "",
|
||||||
|
"composer": ""
|
||||||
|
}
|
@ -32,6 +32,17 @@
|
|||||||
"spk": "Super---05744dd3_4030_4cf8_8dda_a93ab809b473---Power",
|
"spk": "Super---05744dd3_4030_4cf8_8dda_a93ab809b473---Power",
|
||||||
"guid": "05744dd3-4030-4cf8-8dda-a93ab809b473"
|
"guid": "05744dd3-4030-4cf8-8dda-a93ab809b473"
|
||||||
},
|
},
|
||||||
|
"05f23281-58e3-482e-be42-2dc1355ef4ea": {
|
||||||
|
"name": "Data",
|
||||||
|
"type": "class",
|
||||||
|
"namespace": "VDM\\Joomla\\Componentbuilder\\Import",
|
||||||
|
"code": "src\/05f23281-58e3-482e-be42-2dc1355ef4ea\/code.php",
|
||||||
|
"power": "src\/05f23281-58e3-482e-be42-2dc1355ef4ea\/code.power",
|
||||||
|
"settings": "src\/05f23281-58e3-482e-be42-2dc1355ef4ea\/settings.json",
|
||||||
|
"path": "src\/05f23281-58e3-482e-be42-2dc1355ef4ea",
|
||||||
|
"spk": "Super---05f23281_58e3_482e_be42_2dc1355ef4ea---Power",
|
||||||
|
"guid": "05f23281-58e3-482e-be42-2dc1355ef4ea"
|
||||||
|
},
|
||||||
"06f8eada-d59b-441c-b287-0aea1793da5a": {
|
"06f8eada-d59b-441c-b287-0aea1793da5a": {
|
||||||
"name": "Load",
|
"name": "Load",
|
||||||
"type": "final class",
|
"type": "final class",
|
||||||
@ -153,6 +164,17 @@
|
|||||||
"spk": "Super---17ed2fec_49d6_4731_92c3_f9cd78fb6273---Power",
|
"spk": "Super---17ed2fec_49d6_4731_92c3_f9cd78fb6273---Power",
|
||||||
"guid": "17ed2fec-49d6-4731-92c3-f9cd78fb6273"
|
"guid": "17ed2fec-49d6-4731-92c3-f9cd78fb6273"
|
||||||
},
|
},
|
||||||
|
"19a66b48-620c-439b-ab8a-3c0d43e040c3": {
|
||||||
|
"name": "Assessor",
|
||||||
|
"type": "final class",
|
||||||
|
"namespace": "VDM\\Joomla\\Componentbuilder\\Import",
|
||||||
|
"code": "src\/19a66b48-620c-439b-ab8a-3c0d43e040c3\/code.php",
|
||||||
|
"power": "src\/19a66b48-620c-439b-ab8a-3c0d43e040c3\/code.power",
|
||||||
|
"settings": "src\/19a66b48-620c-439b-ab8a-3c0d43e040c3\/settings.json",
|
||||||
|
"path": "src\/19a66b48-620c-439b-ab8a-3c0d43e040c3",
|
||||||
|
"spk": "Super---19a66b48_620c_439b_ab8a_3c0d43e040c3---Power",
|
||||||
|
"guid": "19a66b48-620c-439b-ab8a-3c0d43e040c3"
|
||||||
|
},
|
||||||
"19b2ba92-1655-4384-acfb-979c80de8b6d": {
|
"19b2ba92-1655-4384-acfb-979c80de8b6d": {
|
||||||
"name": "Table",
|
"name": "Table",
|
||||||
"type": "class",
|
"type": "class",
|
||||||
@ -252,6 +274,17 @@
|
|||||||
"spk": "Super---23ad6e72_1b82_40fb_836c_50da690bb174---Power",
|
"spk": "Super---23ad6e72_1b82_40fb_836c_50da690bb174---Power",
|
||||||
"guid": "23ad6e72-1b82-40fb-836c-50da690bb174"
|
"guid": "23ad6e72-1b82-40fb-836c-50da690bb174"
|
||||||
},
|
},
|
||||||
|
"250a7272-9ae1-4c63-a058-26bad9ad6f70": {
|
||||||
|
"name": "ImportMapperInterface",
|
||||||
|
"type": "interface",
|
||||||
|
"namespace": "VDM\\Joomla\\Componentbuilder\\Interfaces",
|
||||||
|
"code": "src\/250a7272-9ae1-4c63-a058-26bad9ad6f70\/code.php",
|
||||||
|
"power": "src\/250a7272-9ae1-4c63-a058-26bad9ad6f70\/code.power",
|
||||||
|
"settings": "src\/250a7272-9ae1-4c63-a058-26bad9ad6f70\/settings.json",
|
||||||
|
"path": "src\/250a7272-9ae1-4c63-a058-26bad9ad6f70",
|
||||||
|
"spk": "Super---250a7272_9ae1_4c63_a058_26bad9ad6f70---Power",
|
||||||
|
"guid": "250a7272-9ae1-4c63-a058-26bad9ad6f70"
|
||||||
|
},
|
||||||
"2ad31f74-f579-499d-b98b-c4f54fd615dd": {
|
"2ad31f74-f579-499d-b98b-c4f54fd615dd": {
|
||||||
"name": "LoadInterface",
|
"name": "LoadInterface",
|
||||||
"type": "interface",
|
"type": "interface",
|
||||||
@ -505,6 +538,17 @@
|
|||||||
"spk": "Super---576685fd_263c_46bb_9fdc_1f5eb234cbb6---Power",
|
"spk": "Super---576685fd_263c_46bb_9fdc_1f5eb234cbb6---Power",
|
||||||
"guid": "576685fd-263c-46bb-9fdc-1f5eb234cbb6"
|
"guid": "576685fd-263c-46bb-9fdc-1f5eb234cbb6"
|
||||||
},
|
},
|
||||||
|
"57c00d53-5581-4fd1-b3ea-080422710243": {
|
||||||
|
"name": "ImportAssessorInterface",
|
||||||
|
"type": "interface",
|
||||||
|
"namespace": "VDM\\Joomla\\Componentbuilder\\Interfaces",
|
||||||
|
"code": "src\/57c00d53-5581-4fd1-b3ea-080422710243\/code.php",
|
||||||
|
"power": "src\/57c00d53-5581-4fd1-b3ea-080422710243\/code.power",
|
||||||
|
"settings": "src\/57c00d53-5581-4fd1-b3ea-080422710243\/settings.json",
|
||||||
|
"path": "src\/57c00d53-5581-4fd1-b3ea-080422710243",
|
||||||
|
"spk": "Super---57c00d53_5581_4fd1_b3ea_080422710243---Power",
|
||||||
|
"guid": "57c00d53-5581-4fd1-b3ea-080422710243"
|
||||||
|
},
|
||||||
"584747d1-3a86-453d-b7a3-a2219de8d777": {
|
"584747d1-3a86-453d-b7a3-a2219de8d777": {
|
||||||
"name": "Model",
|
"name": "Model",
|
||||||
"type": "abstract class",
|
"type": "abstract class",
|
||||||
@ -813,6 +857,17 @@
|
|||||||
"spk": "Super---900456a2_feb5_48b9_9f05_c5a032a32c59---Power",
|
"spk": "Super---900456a2_feb5_48b9_9f05_c5a032a32c59---Power",
|
||||||
"guid": "900456a2-feb5-48b9-9f05-c5a032a32c59"
|
"guid": "900456a2-feb5-48b9-9f05-c5a032a32c59"
|
||||||
},
|
},
|
||||||
|
"90b48ea8-0930-48d1-869a-bce9c901589c": {
|
||||||
|
"name": "Mapper",
|
||||||
|
"type": "final class",
|
||||||
|
"namespace": "VDM\\Joomla\\Componentbuilder\\Import",
|
||||||
|
"code": "src\/90b48ea8-0930-48d1-869a-bce9c901589c\/code.php",
|
||||||
|
"power": "src\/90b48ea8-0930-48d1-869a-bce9c901589c\/code.power",
|
||||||
|
"settings": "src\/90b48ea8-0930-48d1-869a-bce9c901589c\/settings.json",
|
||||||
|
"path": "src\/90b48ea8-0930-48d1-869a-bce9c901589c",
|
||||||
|
"spk": "Super---90b48ea8_0930_48d1_869a_bce9c901589c---Power",
|
||||||
|
"guid": "90b48ea8-0930-48d1-869a-bce9c901589c"
|
||||||
|
},
|
||||||
"91004529-94a9-4590-b842-e7c6b624ecf5": {
|
"91004529-94a9-4590-b842-e7c6b624ecf5": {
|
||||||
"name": "ObjectHelper",
|
"name": "ObjectHelper",
|
||||||
"type": "abstract class",
|
"type": "abstract class",
|
||||||
|
Loading…
Reference in New Issue
Block a user