Update 2024-10-15 03:29:01
This commit is contained in:
parent
7effb3035a
commit
1a74439a89
@ -98,6 +98,9 @@ This repository contains an index (see below) of all the approved powers within
|
|||||||
- **abstract class SessionHelper** | [Details](src/47a63728-cd5d-4d53-99cf-2409bd1c744c) | [Code](src/47a63728-cd5d-4d53-99cf-2409bd1c744c/code.php) | [Settings](src/47a63728-cd5d-4d53-99cf-2409bd1c744c/settings.json) | SPK: `Super---47a63728_cd5d_4d53_99cf_2409bd1c744c---Power`
|
- **abstract class SessionHelper** | [Details](src/47a63728-cd5d-4d53-99cf-2409bd1c744c) | [Code](src/47a63728-cd5d-4d53-99cf-2409bd1c744c/code.php) | [Settings](src/47a63728-cd5d-4d53-99cf-2409bd1c744c/settings.json) | SPK: `Super---47a63728_cd5d_4d53_99cf_2409bd1c744c---Power`
|
||||||
- **abstract class StringHelper** | [Details](src/1f28cb53-60d9-4db1-b517-3c7dc6b429ef) | [Code](src/1f28cb53-60d9-4db1-b517-3c7dc6b429ef/code.php) | [Settings](src/1f28cb53-60d9-4db1-b517-3c7dc6b429ef/settings.json) | SPK: `Super---1f28cb53_60d9_4db1_b517_3c7dc6b429ef---Power`
|
- **abstract class StringHelper** | [Details](src/1f28cb53-60d9-4db1-b517-3c7dc6b429ef) | [Code](src/1f28cb53-60d9-4db1-b517-3c7dc6b429ef/code.php) | [Settings](src/1f28cb53-60d9-4db1-b517-3c7dc6b429ef/settings.json) | SPK: `Super---1f28cb53_60d9_4db1_b517_3c7dc6b429ef---Power`
|
||||||
- **abstract class UploadHelper** | [Details](src/d7600b43-771a-4747-9f5d-952765721799) | [Code](src/d7600b43-771a-4747-9f5d-952765721799/code.php) | [Settings](src/d7600b43-771a-4747-9f5d-952765721799/settings.json) | SPK: `Super---d7600b43_771a_4747_9f5d_952765721799---Power`
|
- **abstract class UploadHelper** | [Details](src/d7600b43-771a-4747-9f5d-952765721799) | [Code](src/d7600b43-771a-4747-9f5d-952765721799/code.php) | [Settings](src/d7600b43-771a-4747-9f5d-952765721799/settings.json) | SPK: `Super---d7600b43_771a_4747_9f5d_952765721799---Power`
|
||||||
|
- **Namespace**: [VDM\Joomla\Abstraction\Console](#vdm-joomla-abstraction-console)
|
||||||
|
|
||||||
|
- **abstract class Import** | [Details](src/85321deb-5c3a-401b-9ce1-039a746add51) | [Code](src/85321deb-5c3a-401b-9ce1-039a746add51/code.php) | [Settings](src/85321deb-5c3a-401b-9ce1-039a746add51/settings.json) | SPK: `Super---85321deb_5c3a_401b_9ce1_039a746add51---Power`
|
||||||
- **Namespace**: [VDM\Joomla\Abstraction\Remote](#vdm-joomla-abstraction-remote)
|
- **Namespace**: [VDM\Joomla\Abstraction\Remote](#vdm-joomla-abstraction-remote)
|
||||||
|
|
||||||
- **abstract class Get** | [Details](src/728ee726-3f0f-4762-899d-f8c9430cee58) | [Code](src/728ee726-3f0f-4762-899d-f8c9430cee58/code.php) | [Settings](src/728ee726-3f0f-4762-899d-f8c9430cee58/settings.json) | SPK: `Super---728ee726_3f0f_4762_899d_f8c9430cee58---Power`
|
- **abstract class Get** | [Details](src/728ee726-3f0f-4762-899d-f8c9430cee58) | [Code](src/728ee726-3f0f-4762-899d-f8c9430cee58/code.php) | [Settings](src/728ee726-3f0f-4762-899d-f8c9430cee58/settings.json) | SPK: `Super---728ee726_3f0f_4762_899d_f8c9430cee58---Power`
|
||||||
@ -186,6 +189,7 @@ This repository contains an index (see below) of all the approved powers within
|
|||||||
- **Namespace**: [VDM\Joomla\Componentbuilder\Interfaces\Spreadsheet](#vdm-joomla-componentbuilder-interfaces-spreadsheet)
|
- **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`
|
- **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`
|
||||||
|
- **interface ImportCliInterface** | [Details](src/0f3f7188-3e0d-4d1a-8dee-7f8026cb65a9) | [Code](src/0f3f7188-3e0d-4d1a-8dee-7f8026cb65a9/code.php) | [Settings](src/0f3f7188-3e0d-4d1a-8dee-7f8026cb65a9/settings.json) | SPK: `Super---0f3f7188_3e0d_4d1a_8dee_7f8026cb65a9---Power`
|
||||||
- **interface RowDataProcessorInterface** | [Details](src/9ffc54fa-a71e-412f-bc8b-064fc3b69167) | [Code](src/9ffc54fa-a71e-412f-bc8b-064fc3b69167/code.php) | [Settings](src/9ffc54fa-a71e-412f-bc8b-064fc3b69167/settings.json) | SPK: `Super---9ffc54fa_a71e_412f_bc8b_064fc3b69167---Power`
|
- **interface RowDataProcessorInterface** | [Details](src/9ffc54fa-a71e-412f-bc8b-064fc3b69167) | [Code](src/9ffc54fa-a71e-412f-bc8b-064fc3b69167/code.php) | [Settings](src/9ffc54fa-a71e-412f-bc8b-064fc3b69167/settings.json) | SPK: `Super---9ffc54fa_a71e_412f_bc8b_064fc3b69167---Power`
|
||||||
- **Namespace**: [VDM\Joomla\Componentbuilder\Utilities\Exception](#vdm-joomla-componentbuilder-utilities-exception)
|
- **Namespace**: [VDM\Joomla\Componentbuilder\Utilities\Exception](#vdm-joomla-componentbuilder-utilities-exception)
|
||||||
|
|
||||||
|
60
src/0f3f7188-3e0d-4d1a-8dee-7f8026cb65a9/README.md
Normal file
60
src/0f3f7188-3e0d-4d1a-8dee-7f8026cb65a9/README.md
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
```
|
||||||
|
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||||
|
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||||
|
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||||
|
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||||
|
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||||
|
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||||
|
```
|
||||||
|
# interface ImportCliInterface (Details)
|
||||||
|
> namespace: **VDM\Joomla\Componentbuilder\Interfaces\Spreadsheet**
|
||||||
|
|
||||||
|
```uml
|
||||||
|
@startuml
|
||||||
|
interface ImportCliInterface #Lavender {
|
||||||
|
+ data(object $import) : void
|
||||||
|
+ message() : object
|
||||||
|
}
|
||||||
|
|
||||||
|
note right of ImportCliInterface::data
|
||||||
|
The trigger function called from the CLI to start the import on a spreadsheet
|
||||||
|
|
||||||
|
since: 5.0.2
|
||||||
|
return: void
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of ImportCliInterface::message
|
||||||
|
The message of the last import event
|
||||||
|
|
||||||
|
since: 5.0.2
|
||||||
|
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---0f3f7188_3e0d_4d1a_8dee_7f8026cb65a9---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)
|
||||||
|
|
40
src/0f3f7188-3e0d-4d1a-8dee-7f8026cb65a9/code.php
Normal file
40
src/0f3f7188-3e0d-4d1a-8dee-7f8026cb65a9/code.php
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
<?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\Spreadsheet;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Spreadsheet Import Cli Interface
|
||||||
|
*
|
||||||
|
* @since 3.2.2
|
||||||
|
*/
|
||||||
|
interface ImportCliInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The trigger function called from the CLI to start the import on a spreadsheet
|
||||||
|
*
|
||||||
|
* @param object $import The spreadsheet data to import.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 5.0.2
|
||||||
|
*/
|
||||||
|
public function data(object $import): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The message of the last import event
|
||||||
|
*
|
||||||
|
* @return object
|
||||||
|
* @since 5.0.2
|
||||||
|
*/
|
||||||
|
public function message(): object;
|
||||||
|
}
|
||||||
|
|
17
src/0f3f7188-3e0d-4d1a-8dee-7f8026cb65a9/code.power
Normal file
17
src/0f3f7188-3e0d-4d1a-8dee-7f8026cb65a9/code.power
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
/**
|
||||||
|
* The trigger function called from the CLI to start the import on a spreadsheet
|
||||||
|
*
|
||||||
|
* @param object $import The spreadsheet data to import.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 5.0.2
|
||||||
|
*/
|
||||||
|
public function data(object $import): void;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The message of the last import event
|
||||||
|
*
|
||||||
|
* @return object
|
||||||
|
* @since 5.0.2
|
||||||
|
*/
|
||||||
|
public function message(): object;
|
19
src/0f3f7188-3e0d-4d1a-8dee-7f8026cb65a9/settings.json
Normal file
19
src/0f3f7188-3e0d-4d1a-8dee-7f8026cb65a9/settings.json
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"add_head": "0",
|
||||||
|
"add_licensing_template": "2",
|
||||||
|
"extends": "",
|
||||||
|
"guid": "0f3f7188-3e0d-4d1a-8dee-7f8026cb65a9",
|
||||||
|
"implements": null,
|
||||||
|
"load_selection": null,
|
||||||
|
"name": "ImportCliInterface",
|
||||||
|
"power_version": "1.0.0",
|
||||||
|
"system_name": "JCB.Interfaces.Spreadsheet.ImportCliInterface",
|
||||||
|
"type": "interface",
|
||||||
|
"use_selection": null,
|
||||||
|
"extendsinterfaces": null,
|
||||||
|
"namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Interfaces.Spreadsheet.ImportCliInterface",
|
||||||
|
"description": "Spreadsheet Import Cli Interface\r\n\r\n@since 3.2.2",
|
||||||
|
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/joomla\/Component-Builder>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
|
||||||
|
"head": "",
|
||||||
|
"composer": ""
|
||||||
|
}
|
76
src/85321deb-5c3a-401b-9ce1-039a746add51/README.md
Normal file
76
src/85321deb-5c3a-401b-9ce1-039a746add51/README.md
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
```
|
||||||
|
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||||
|
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||||
|
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||||
|
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||||
|
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||||
|
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||||
|
```
|
||||||
|
# abstract class Import (Details)
|
||||||
|
> namespace: **VDM\Joomla\Abstraction\Console**
|
||||||
|
> extends: **AbstractCommand**
|
||||||
|
|
||||||
|
```uml
|
||||||
|
@startuml
|
||||||
|
abstract Import #Orange {
|
||||||
|
# Items $items
|
||||||
|
# Import $import
|
||||||
|
# string $queueTable
|
||||||
|
# string $targetName
|
||||||
|
# string $targetImportClass
|
||||||
|
# static $defaultName
|
||||||
|
+ __construct(?string $name = null)
|
||||||
|
# configure() : void
|
||||||
|
# doExecute(InputInterface $input, OutputInterface $output) : int
|
||||||
|
}
|
||||||
|
|
||||||
|
note right of Import::__construct
|
||||||
|
Constructor.
|
||||||
|
|
||||||
|
since: 5.0.2
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Import::configure
|
||||||
|
Configures the CLI command, setting up the description and help text.
|
||||||
|
This command parses the import queue and imports items that are still in the queue.
|
||||||
|
It is useful for automatically processing pending item imports in the virtual warehouse.
|
||||||
|
|
||||||
|
since: 5.0.2
|
||||||
|
return: void
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Import::doExecute
|
||||||
|
Executes the CLI command, processing each spreadsheet in the import queue.
|
||||||
|
|
||||||
|
since: 5.0.2
|
||||||
|
return: int
|
||||||
|
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---85321deb_5c3a_401b_9ce1_039a746add51---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)
|
||||||
|
|
225
src/85321deb-5c3a-401b-9ce1-039a746add51/code.php
Normal file
225
src/85321deb-5c3a-401b-9ce1-039a746add51/code.php
Normal file
@ -0,0 +1,225 @@
|
|||||||
|
<?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\Abstraction\Console;
|
||||||
|
|
||||||
|
|
||||||
|
use Joomla\CMS\Factory;
|
||||||
|
use Joomla\Console\Command\AbstractCommand;
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
|
use VDM\Joomla\Componentbuilder\Import\Factory as ImportFactory;
|
||||||
|
use VDM\Joomla\Data\Items;
|
||||||
|
use VDM\Joomla\Componentbuilder\Interfaces\Spreadsheet\ImportCliInterface as Import;
|
||||||
|
use VDM\Joomla\Utilities\Component\Helper;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Console Import
|
||||||
|
*
|
||||||
|
* @since 5.0.2
|
||||||
|
*/
|
||||||
|
abstract class Import extends AbstractCommand
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The Items Class.
|
||||||
|
*
|
||||||
|
* @var Items
|
||||||
|
* @since 5.0.2
|
||||||
|
*/
|
||||||
|
protected Items $items;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Import Class.
|
||||||
|
*
|
||||||
|
* @var Import
|
||||||
|
* @since 5.0.2
|
||||||
|
*/
|
||||||
|
protected Import $import;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The queue table name.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 5.0.2
|
||||||
|
*/
|
||||||
|
protected string $queueTable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The main import target name.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 5.0.2
|
||||||
|
*/
|
||||||
|
protected string $targetName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The target import class.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 5.0.2
|
||||||
|
*/
|
||||||
|
protected string $targetImportClass;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default command name.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 5.0.2
|
||||||
|
*/
|
||||||
|
protected static $defaultName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param string|null $name The name of the command; if the name is empty and no default is set, a name must be set in the configure() method
|
||||||
|
*
|
||||||
|
* @since 5.0.2
|
||||||
|
*/
|
||||||
|
public function __construct(?string $name = null)
|
||||||
|
{
|
||||||
|
// make sure we know what component we are working with
|
||||||
|
Helper::setOption('com_componentbuilder');
|
||||||
|
|
||||||
|
// Load administrator language file for backend
|
||||||
|
$lang = Factory::getLanguage();
|
||||||
|
$lang->load('com_componentbuilder', JPATH_ADMINISTRATOR);
|
||||||
|
|
||||||
|
$this->items = ImportFactory::_('Data.Items');
|
||||||
|
$this->import = ImportFactory::_($this->targetImportClass);
|
||||||
|
|
||||||
|
parent::__construct($name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configures the CLI command, setting up the description and help text.
|
||||||
|
*
|
||||||
|
* This command parses the import queue and imports items that are still in the queue.
|
||||||
|
* It is useful for automatically processing pending item imports in the virtual warehouse.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 5.0.2
|
||||||
|
*/
|
||||||
|
protected function configure(): void
|
||||||
|
{
|
||||||
|
$this->setDescription("Processes the import queue and {$this->targetName} imports all spreadsheets that are still in the queue.");
|
||||||
|
$this->setHelp(
|
||||||
|
<<<EOF
|
||||||
|
The <info>%command.name%</info> command parses the import queue and processes all {$this->targetName} spreadsheets that are still pending import.
|
||||||
|
This is useful for keeping the system up-to-date with incoming data.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
<info>php joomla.php %command.name%</info>
|
||||||
|
EOF);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executes the CLI command, processing each spreadsheet in the import queue.
|
||||||
|
*
|
||||||
|
* @param InputInterface $input The input to inject into the command.
|
||||||
|
* @param OutputInterface $output The output to inject into the command.
|
||||||
|
*
|
||||||
|
* @return int The command exit code (0 for success).
|
||||||
|
* @since 5.0.2
|
||||||
|
*/
|
||||||
|
protected function doExecute(InputInterface $input, OutputInterface $output): int
|
||||||
|
{
|
||||||
|
$io = new SymfonyStyle($input, $output);
|
||||||
|
|
||||||
|
// Output the title for the task
|
||||||
|
$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)
|
||||||
|
{
|
||||||
|
// Get the current date and time
|
||||||
|
$timestamp = date('Y-m-d H:i:s');
|
||||||
|
|
||||||
|
// Output the notice of no imports to be done
|
||||||
|
$io->info("No {$this->targetName} imports found in the queue. Idle at {$timestamp}.");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$numberSteps = count((array) $queue);
|
||||||
|
|
||||||
|
// Output initial task information
|
||||||
|
$io->info("Initiating import for {$numberSteps} {$this->targetName} spreadsheet(s) in the queue.");
|
||||||
|
$io->newLine(2);
|
||||||
|
|
||||||
|
// Create a progress bar for the overall import process
|
||||||
|
$progressBar = $io->createProgressBar($numberSteps);
|
||||||
|
$progressBar->start();
|
||||||
|
|
||||||
|
// Track success and failure counts
|
||||||
|
$successCount = 0;
|
||||||
|
$failureCount = 0;
|
||||||
|
|
||||||
|
// Import one spreadsheet at a time
|
||||||
|
foreach ($queue as $spreadsheet)
|
||||||
|
{
|
||||||
|
$io->newLine(2);
|
||||||
|
|
||||||
|
// Output the current spreadsheet being processed
|
||||||
|
$io->section("Processing spreadsheet #{$spreadsheet->guid}...");
|
||||||
|
|
||||||
|
// Import the data found in the spreadsheet
|
||||||
|
$this->import->data($spreadsheet);
|
||||||
|
|
||||||
|
// Get the completion message
|
||||||
|
$completion = $this->import->message();
|
||||||
|
|
||||||
|
// Track success based on completion message
|
||||||
|
if ($completion->message_success)
|
||||||
|
{
|
||||||
|
$successCount++;
|
||||||
|
|
||||||
|
// Output the success message for this spreadsheet
|
||||||
|
$io->success($completion->message_success);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Track failure based on completion message
|
||||||
|
if ($completion->message_error)
|
||||||
|
{
|
||||||
|
$failureCount++;
|
||||||
|
|
||||||
|
// Output the error message for this spreadsheet
|
||||||
|
$io->error($completion->message_error);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Advance the main progress bar by one step
|
||||||
|
sleep(1);
|
||||||
|
$progressBar->advance();
|
||||||
|
$io->newLine(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Finish the main progress bar
|
||||||
|
$progressBar->finish();
|
||||||
|
$io->newLine(2);
|
||||||
|
|
||||||
|
// Calculate the success and failure percentages
|
||||||
|
$totalProcessed = $successCount + $failureCount;
|
||||||
|
$successRate = ($totalProcessed > 0) ? round(($successCount / $totalProcessed) * 100) : 0;
|
||||||
|
$failureRate = ($totalProcessed > 0) ? round(($failureCount / $totalProcessed) * 100) : 0;
|
||||||
|
|
||||||
|
// Get the current date and time
|
||||||
|
$timestamp = date('Y-m-d H:i:s');
|
||||||
|
|
||||||
|
// Output the success and failure summary with the timestamp
|
||||||
|
$io->info("The {$this->targetName} import finished: {$successRate}% success, {$failureRate}% failure. Completed at {$timestamp}.");
|
||||||
|
|
||||||
|
$io->newLine(1);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
191
src/85321deb-5c3a-401b-9ce1-039a746add51/code.power
Normal file
191
src/85321deb-5c3a-401b-9ce1-039a746add51/code.power
Normal file
@ -0,0 +1,191 @@
|
|||||||
|
/**
|
||||||
|
* The Items Class.
|
||||||
|
*
|
||||||
|
* @var Items
|
||||||
|
* @since 5.0.2
|
||||||
|
*/
|
||||||
|
protected Items $items;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The Import Class.
|
||||||
|
*
|
||||||
|
* @var Import
|
||||||
|
* @since 5.0.2
|
||||||
|
*/
|
||||||
|
protected Import $import;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The queue table name.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 5.0.2
|
||||||
|
*/
|
||||||
|
protected string $queueTable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The main import target name.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 5.0.2
|
||||||
|
*/
|
||||||
|
protected string $targetName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The target import class.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 5.0.2
|
||||||
|
*/
|
||||||
|
protected string $targetImportClass;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The default command name.
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 5.0.2
|
||||||
|
*/
|
||||||
|
protected static $defaultName;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param string|null $name The name of the command; if the name is empty and no default is set, a name must be set in the configure() method
|
||||||
|
*
|
||||||
|
* @since 5.0.2
|
||||||
|
*/
|
||||||
|
public function __construct(?string $name = null)
|
||||||
|
{
|
||||||
|
// make sure we know what component we are working with
|
||||||
|
Helper::setOption('com_[[[component]]]');
|
||||||
|
|
||||||
|
// Load administrator language file for backend
|
||||||
|
$lang = Factory::getLanguage();
|
||||||
|
$lang->load('com_[[[component]]]', JPATH_ADMINISTRATOR);
|
||||||
|
|
||||||
|
$this->items = ImportFactory::_('Data.Items');
|
||||||
|
$this->import = ImportFactory::_($this->targetImportClass);
|
||||||
|
|
||||||
|
parent::__construct($name);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Configures the CLI command, setting up the description and help text.
|
||||||
|
*
|
||||||
|
* This command parses the import queue and imports items that are still in the queue.
|
||||||
|
* It is useful for automatically processing pending item imports in the virtual warehouse.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 5.0.2
|
||||||
|
*/
|
||||||
|
protected function configure(): void
|
||||||
|
{
|
||||||
|
$this->setDescription("Processes the import queue and {$this->targetName} imports all spreadsheets that are still in the queue.");
|
||||||
|
$this->setHelp(
|
||||||
|
<<<EOF
|
||||||
|
The <info>%command.name%</info> command parses the import queue and processes all {$this->targetName} spreadsheets that are still pending import.
|
||||||
|
This is useful for keeping the system up-to-date with incoming data.
|
||||||
|
|
||||||
|
Usage:
|
||||||
|
<info>php joomla.php %command.name%</info>
|
||||||
|
EOF);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executes the CLI command, processing each spreadsheet in the import queue.
|
||||||
|
*
|
||||||
|
* @param InputInterface $input The input to inject into the command.
|
||||||
|
* @param OutputInterface $output The output to inject into the command.
|
||||||
|
*
|
||||||
|
* @return int The command exit code (0 for success).
|
||||||
|
* @since 5.0.2
|
||||||
|
*/
|
||||||
|
protected function doExecute(InputInterface $input, OutputInterface $output): int
|
||||||
|
{
|
||||||
|
$io = new SymfonyStyle($input, $output);
|
||||||
|
|
||||||
|
// Output the title for the task
|
||||||
|
$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)
|
||||||
|
{
|
||||||
|
// Get the current date and time
|
||||||
|
$timestamp = date('Y-m-d H:i:s');
|
||||||
|
|
||||||
|
// Output the notice of no imports to be done
|
||||||
|
$io->info("No {$this->targetName} imports found in the queue. Idle at {$timestamp}.");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
$numberSteps = count((array) $queue);
|
||||||
|
|
||||||
|
// Output initial task information
|
||||||
|
$io->info("Initiating import for {$numberSteps} {$this->targetName} spreadsheet(s) in the queue.");
|
||||||
|
$io->newLine(2);
|
||||||
|
|
||||||
|
// Create a progress bar for the overall import process
|
||||||
|
$progressBar = $io->createProgressBar($numberSteps);
|
||||||
|
$progressBar->start();
|
||||||
|
|
||||||
|
// Track success and failure counts
|
||||||
|
$successCount = 0;
|
||||||
|
$failureCount = 0;
|
||||||
|
|
||||||
|
// Import one spreadsheet at a time
|
||||||
|
foreach ($queue as $spreadsheet)
|
||||||
|
{
|
||||||
|
$io->newLine(2);
|
||||||
|
|
||||||
|
// Output the current spreadsheet being processed
|
||||||
|
$io->section("Processing spreadsheet #{$spreadsheet->guid}...");
|
||||||
|
|
||||||
|
// Import the data found in the spreadsheet
|
||||||
|
$this->import->data($spreadsheet);
|
||||||
|
|
||||||
|
// Get the completion message
|
||||||
|
$completion = $this->import->message();
|
||||||
|
|
||||||
|
// Track success based on completion message
|
||||||
|
if ($completion->message_success)
|
||||||
|
{
|
||||||
|
$successCount++;
|
||||||
|
|
||||||
|
// Output the success message for this spreadsheet
|
||||||
|
$io->success($completion->message_success);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Track failure based on completion message
|
||||||
|
if ($completion->message_error)
|
||||||
|
{
|
||||||
|
$failureCount++;
|
||||||
|
|
||||||
|
// Output the error message for this spreadsheet
|
||||||
|
$io->error($completion->message_error);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Advance the main progress bar by one step
|
||||||
|
sleep(1);
|
||||||
|
$progressBar->advance();
|
||||||
|
$io->newLine(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Finish the main progress bar
|
||||||
|
$progressBar->finish();
|
||||||
|
$io->newLine(2);
|
||||||
|
|
||||||
|
// Calculate the success and failure percentages
|
||||||
|
$totalProcessed = $successCount + $failureCount;
|
||||||
|
$successRate = ($totalProcessed > 0) ? round(($successCount / $totalProcessed) * 100) : 0;
|
||||||
|
$failureRate = ($totalProcessed > 0) ? round(($failureCount / $totalProcessed) * 100) : 0;
|
||||||
|
|
||||||
|
// Get the current date and time
|
||||||
|
$timestamp = date('Y-m-d H:i:s');
|
||||||
|
|
||||||
|
// Output the success and failure summary with the timestamp
|
||||||
|
$io->info("The {$this->targetName} import finished: {$successRate}% success, {$failureRate}% failure. Completed at {$timestamp}.");
|
||||||
|
|
||||||
|
$io->newLine(1);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
37
src/85321deb-5c3a-401b-9ce1-039a746add51/settings.json
Normal file
37
src/85321deb-5c3a-401b-9ce1-039a746add51/settings.json
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
{
|
||||||
|
"add_head": "1",
|
||||||
|
"add_licensing_template": "2",
|
||||||
|
"extends": "-1",
|
||||||
|
"guid": "85321deb-5c3a-401b-9ce1-039a746add51",
|
||||||
|
"implements": null,
|
||||||
|
"load_selection": null,
|
||||||
|
"name": "Import",
|
||||||
|
"power_version": "1.0.0",
|
||||||
|
"system_name": "VDM.Abstraction.Console.Import",
|
||||||
|
"type": "abstract class",
|
||||||
|
"use_selection": {
|
||||||
|
"use_selection0": {
|
||||||
|
"use": "ff8d5fdb-2d1f-4178-bd18-a43b8efd1068",
|
||||||
|
"as": "ImportFactory"
|
||||||
|
},
|
||||||
|
"use_selection1": {
|
||||||
|
"use": "21bca8a4-5b28-41c4-843e-8097f0ba7cca",
|
||||||
|
"as": "default"
|
||||||
|
},
|
||||||
|
"use_selection2": {
|
||||||
|
"use": "0f3f7188-3e0d-4d1a-8dee-7f8026cb65a9",
|
||||||
|
"as": "Import"
|
||||||
|
},
|
||||||
|
"use_selection3": {
|
||||||
|
"use": "640b5352-fb09-425f-a26e-cd44eda03f15",
|
||||||
|
"as": "default"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"extendsinterfaces": null,
|
||||||
|
"namespace": "[[[NamespacePrefix]]]\\Joomla\\Abstraction.Console.Import",
|
||||||
|
"description": "Console Import\r\n\r\n@since 5.0.2",
|
||||||
|
"extends_custom": "AbstractCommand",
|
||||||
|
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/joomla\/Component-Builder>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
|
||||||
|
"head": "use Joomla\\CMS\\Factory;\r\nuse Joomla\\Console\\Command\\AbstractCommand;\r\nuse Symfony\\Component\\Console\\Input\\InputInterface;\r\nuse Symfony\\Component\\Console\\Output\\OutputInterface;\r\nuse Symfony\\Component\\Console\\Style\\SymfonyStyle;",
|
||||||
|
"composer": ""
|
||||||
|
}
|
@ -14,7 +14,6 @@ namespace VDM\Joomla\Componentbuilder\Spreadsheet;
|
|||||||
|
|
||||||
use VDM\Joomla\Componentbuilder\Interfaces\Spreadsheet\FileReaderInterface as FileReader;
|
use VDM\Joomla\Componentbuilder\Interfaces\Spreadsheet\FileReaderInterface as FileReader;
|
||||||
use VDM\Joomla\Componentbuilder\Interfaces\Spreadsheet\RowDataProcessorInterface as RowDataProcessor;
|
use VDM\Joomla\Componentbuilder\Interfaces\Spreadsheet\RowDataProcessorInterface as RowDataProcessor;
|
||||||
use VDM\Joomla\Abstraction\Console\Import;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -24,11 +23,6 @@ use VDM\Joomla\Abstraction\Console\Import;
|
|||||||
*/
|
*/
|
||||||
final class Importer
|
final class Importer
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* To add the cli import abstract class into super powers
|
|
||||||
* Import
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The FileReader Class.
|
* The FileReader Class.
|
||||||
*
|
*
|
||||||
|
@ -1,8 +1,3 @@
|
|||||||
/**
|
|
||||||
* To add the cli import abstract class into super powers
|
|
||||||
* Import
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The FileReader Class.
|
* The FileReader Class.
|
||||||
*
|
*
|
||||||
|
@ -54,6 +54,17 @@
|
|||||||
"spk": "Super---0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a---Power",
|
"spk": "Super---0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a---Power",
|
||||||
"guid": "0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a"
|
"guid": "0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a"
|
||||||
},
|
},
|
||||||
|
"0f3f7188-3e0d-4d1a-8dee-7f8026cb65a9": {
|
||||||
|
"name": "ImportCliInterface",
|
||||||
|
"type": "interface",
|
||||||
|
"namespace": "VDM\\Joomla\\Componentbuilder\\Interfaces\\Spreadsheet",
|
||||||
|
"code": "src\/0f3f7188-3e0d-4d1a-8dee-7f8026cb65a9\/code.php",
|
||||||
|
"power": "src\/0f3f7188-3e0d-4d1a-8dee-7f8026cb65a9\/code.power",
|
||||||
|
"settings": "src\/0f3f7188-3e0d-4d1a-8dee-7f8026cb65a9\/settings.json",
|
||||||
|
"path": "src\/0f3f7188-3e0d-4d1a-8dee-7f8026cb65a9",
|
||||||
|
"spk": "Super---0f3f7188_3e0d_4d1a_8dee_7f8026cb65a9---Power",
|
||||||
|
"guid": "0f3f7188-3e0d-4d1a-8dee-7f8026cb65a9"
|
||||||
|
},
|
||||||
"11572d9b-e3d5-4b29-904c-9618d8f2bfd8": {
|
"11572d9b-e3d5-4b29-904c-9618d8f2bfd8": {
|
||||||
"name": "Count",
|
"name": "Count",
|
||||||
"type": "trait",
|
"type": "trait",
|
||||||
@ -659,6 +670,17 @@
|
|||||||
"spk": "Super---7e822c03_1b20_41d1_9427_f5b8d5836af7---Power",
|
"spk": "Super---7e822c03_1b20_41d1_9427_f5b8d5836af7---Power",
|
||||||
"guid": "7e822c03-1b20-41d1-9427-f5b8d5836af7"
|
"guid": "7e822c03-1b20-41d1-9427-f5b8d5836af7"
|
||||||
},
|
},
|
||||||
|
"85321deb-5c3a-401b-9ce1-039a746add51": {
|
||||||
|
"name": "Import",
|
||||||
|
"type": "abstract class",
|
||||||
|
"namespace": "VDM\\Joomla\\Abstraction\\Console",
|
||||||
|
"code": "src\/85321deb-5c3a-401b-9ce1-039a746add51\/code.php",
|
||||||
|
"power": "src\/85321deb-5c3a-401b-9ce1-039a746add51\/code.power",
|
||||||
|
"settings": "src\/85321deb-5c3a-401b-9ce1-039a746add51\/settings.json",
|
||||||
|
"path": "src\/85321deb-5c3a-401b-9ce1-039a746add51",
|
||||||
|
"spk": "Super---85321deb_5c3a_401b_9ce1_039a746add51---Power",
|
||||||
|
"guid": "85321deb-5c3a-401b-9ce1-039a746add51"
|
||||||
|
},
|
||||||
"85785701-07b2-4f81-bc1e-0f423700c254": {
|
"85785701-07b2-4f81-bc1e-0f423700c254": {
|
||||||
"name": "Subform",
|
"name": "Subform",
|
||||||
"type": "final class",
|
"type": "final class",
|
||||||
|
Loading…
Reference in New Issue
Block a user