Update 2024-12-16 18:27:10
This commit is contained in:
parent
293e6f9979
commit
3adb5fab05
18
README.md
18
README.md
@ -25,7 +25,10 @@ This repository contains an index (see below) of all the approved powers within
|
||||
|
||||
- **Namespace**: [VDM\Joomla\Componentbuilder\Abstraction](#vdm-joomla-componentbuilder-abstraction)
|
||||
|
||||
- **abstract class BaseConfig** | [Details](src/9769f3b2-17bf-4f20-b54b-3a4ebe572b36) | [Code](src/9769f3b2-17bf-4f20-b54b-3a4ebe572b36/code.php) | [Settings](src/9769f3b2-17bf-4f20-b54b-3a4ebe572b36/settings.json) | SPK: `Super---9769f3b2_17bf_4f20_b54b_3a4ebe572b36---Power`
|
||||
- **abstract class Api** | [Details](src/85e0b652-21b9-4ff7-ba27-dbd72256f0f2) | [Code](src/85e0b652-21b9-4ff7-ba27-dbd72256f0f2/code.php) | [Settings](src/85e0b652-21b9-4ff7-ba27-dbd72256f0f2/settings.json) | SPK: `Super---85e0b652_21b9_4ff7_ba27_dbd72256f0f2---Power`
|
||||
- **Namespace**: [VDM\Joomla\Componentbuilder\Api](#vdm-joomla-componentbuilder-api)
|
||||
|
||||
- **final class Network** | [Details](src/07ca003e-368c-451d-a3d3-ba24e50c7287) | [Code](src/07ca003e-368c-451d-a3d3-ba24e50c7287/code.php) | [Settings](src/07ca003e-368c-451d-a3d3-ba24e50c7287/settings.json) | SPK: `Super---07ca003e_368c_451d_a3d3_ba24e50c7287---Power`
|
||||
- **Namespace**: [VDM\Joomla\Componentbuilder\Compiler](#vdm-joomla-componentbuilder-compiler)
|
||||
|
||||
- **abstract class Factory** | [Details](src/d910d8b8-4c23-4f3e-8cda-438f2d2bd7ac) | [Code](src/d910d8b8-4c23-4f3e-8cda-438f2d2bd7ac/code.php) | [Settings](src/d910d8b8-4c23-4f3e-8cda-438f2d2bd7ac/settings.json) | SPK: `Super---d910d8b8_4c23_4f3e_8cda_438f2d2bd7ac---Power`
|
||||
@ -52,6 +55,13 @@ This repository contains an index (see below) of all the approved powers within
|
||||
- **abstract class Factory** | [Details](src/6ee3dc9e-1949-4da5-a74f-d9eb7f14e400) | [Code](src/6ee3dc9e-1949-4da5-a74f-d9eb7f14e400/code.php) | [Settings](src/6ee3dc9e-1949-4da5-a74f-d9eb7f14e400/settings.json) | SPK: `Super---6ee3dc9e_1949_4da5_a74f_d9eb7f14e400---Power`
|
||||
- **final class Grep** | [Details](src/355bf21a-f859-4528-9110-bcd2c6d05ea7) | [Code](src/355bf21a-f859-4528-9110-bcd2c6d05ea7/code.php) | [Settings](src/355bf21a-f859-4528-9110-bcd2c6d05ea7/settings.json) | SPK: `Super---355bf21a_f859_4528_9110_bcd2c6d05ea7---Power`
|
||||
- **class Config** | [Details](src/0b821bba-7503-4448-90e7-f3c1bd51dfd6) | [Code](src/0b821bba-7503-4448-90e7-f3c1bd51dfd6/code.php) | [Settings](src/0b821bba-7503-4448-90e7-f3c1bd51dfd6/settings.json) | SPK: `Super---0b821bba_7503_4448_90e7_f3c1bd51dfd6---Power`
|
||||
- **Namespace**: [VDM\Joomla\Componentbuilder\Network](#vdm-joomla-componentbuilder-network)
|
||||
|
||||
- **final class Core** | [Details](src/825ecce9-72ef-4257-bc32-4b05a4c226e9) | [Code](src/825ecce9-72ef-4257-bc32-4b05a4c226e9/code.php) | [Settings](src/825ecce9-72ef-4257-bc32-4b05a4c226e9/settings.json) | SPK: `Super---825ecce9_72ef_4257_bc32_4b05a4c226e9---Power`
|
||||
- **final class ParsedUrls** | [Details](src/fd3b25c3-cd49-404c-ae82-b6a125863f10) | [Code](src/fd3b25c3-cd49-404c-ae82-b6a125863f10/code.php) | [Settings](src/fd3b25c3-cd49-404c-ae82-b6a125863f10/settings.json) | SPK: `Super---fd3b25c3_cd49_404c_ae82_b6a125863f10---Power`
|
||||
- **final class Resolve** | [Details](src/a0c143af-3d7d-4c19-91c4-f72060b4c361) | [Code](src/a0c143af-3d7d-4c19-91c4-f72060b4c361/code.php) | [Settings](src/a0c143af-3d7d-4c19-91c4-f72060b4c361/settings.json) | SPK: `Super---a0c143af_3d7d_4c19_91c4_f72060b4c361---Power`
|
||||
- **final class Status** | [Details](src/809d3077-c105-4e9c-8ac5-8fbee10cf9fc) | [Code](src/809d3077-c105-4e9c-8ac5-8fbee10cf9fc/code.php) | [Settings](src/809d3077-c105-4e9c-8ac5-8fbee10cf9fc/settings.json) | SPK: `Super---809d3077_c105_4e9c_8ac5_8fbee10cf9fc---Power`
|
||||
- **final class Url** | [Details](src/286f7550-9c22-401c-9e5a-2f9426888133) | [Code](src/286f7550-9c22-401c-9e5a-2f9426888133/code.php) | [Settings](src/286f7550-9c22-401c-9e5a-2f9426888133/settings.json) | SPK: `Super---286f7550_9c22_401c_9e5a_2f9426888133---Power`
|
||||
- **Namespace**: [VDM\Joomla\Componentbuilder\Power](#vdm-joomla-componentbuilder-power)
|
||||
|
||||
- **abstract class Factory** | [Details](src/a5734b9e-a72d-494c-bc72-c3bc7506015f) | [Code](src/a5734b9e-a72d-494c-bc72-c3bc7506015f/code.php) | [Settings](src/a5734b9e-a72d-494c-bc72-c3bc7506015f/settings.json) | SPK: `Super---a5734b9e_a72d_494c_bc72_c3bc7506015f---Power`
|
||||
@ -62,11 +72,17 @@ This repository contains an index (see below) of all the approved powers within
|
||||
- **class Plantuml** | [Details](src/ff5e9e63-86d0-4691-ab59-d4b9d9154096) | [Code](src/ff5e9e63-86d0-4691-ab59-d4b9d9154096/code.php) | [Settings](src/ff5e9e63-86d0-4691-ab59-d4b9d9154096/settings.json) | SPK: `Super---ff5e9e63_86d0_4691_ab59_d4b9d9154096---Power`
|
||||
- **Namespace**: [VDM\Joomla\Componentbuilder\Service](#vdm-joomla-componentbuilder-service)
|
||||
|
||||
- **class Api** | [Details](src/3c7567d7-b079-4910-b325-7ed5c30cabff) | [Code](src/3c7567d7-b079-4910-b325-7ed5c30cabff/code.php) | [Settings](src/3c7567d7-b079-4910-b325-7ed5c30cabff/settings.json) | SPK: `Super---3c7567d7_b079_4910_b325_7ed5c30cabff---Power`
|
||||
- **class CoreRules** | [Details](src/f65b52c2-593a-4c35-89d1-4a8e57a1adf0) | [Code](src/f65b52c2-593a-4c35-89d1-4a8e57a1adf0/code.php) | [Settings](src/f65b52c2-593a-4c35-89d1-4a8e57a1adf0/settings.json) | SPK: `Super---f65b52c2_593a_4c35_89d1_4a8e57a1adf0---Power`
|
||||
- **class Network** | [Details](src/156f449b-ca6c-4a57-a925-be345e751614) | [Code](src/156f449b-ca6c-4a57-a925-be345e751614/code.php) | [Settings](src/156f449b-ca6c-4a57-a925-be345e751614/settings.json) | SPK: `Super---156f449b_ca6c_4a57_a925_be345e751614---Power`
|
||||
- **class Utilities** | [Details](src/facd1e1c-ff2f-4520-b735-075c45aa55ed) | [Code](src/facd1e1c-ff2f-4520-b735-075c45aa55ed/code.php) | [Settings](src/facd1e1c-ff2f-4520-b735-075c45aa55ed/settings.json) | SPK: `Super---facd1e1c_ff2f_4520_b735_075c45aa55ed---Power`
|
||||
- **Namespace**: [VDM\Joomla\Componentbuilder\Utilities](#vdm-joomla-componentbuilder-utilities)
|
||||
|
||||
- **abstract class FilterHelper** | [Details](src/cddcac51-9a46-47c4-ba59-105c70453bd6) | [Code](src/cddcac51-9a46-47c4-ba59-105c70453bd6/code.php) | [Settings](src/cddcac51-9a46-47c4-ba59-105c70453bd6/settings.json) | SPK: `Super---cddcac51_9a46_47c4_ba59_105c70453bd6---Power`
|
||||
- **abstract class RepoHelper** | [Details](src/c6619b00-261c-473b-8094-d4fe9e6bab39) | [Code](src/c6619b00-261c-473b-8094-d4fe9e6bab39/code.php) | [Settings](src/c6619b00-261c-473b-8094-d4fe9e6bab39/settings.json) | SPK: `Super---c6619b00_261c_473b_8094_d4fe9e6bab39---Power`
|
||||
- **final class Http** | [Details](src/d9ee00d6-eeed-4fc4-af8a-7b5547f508ba) | [Code](src/d9ee00d6-eeed-4fc4-af8a-7b5547f508ba/code.php) | [Settings](src/d9ee00d6-eeed-4fc4-af8a-7b5547f508ba/settings.json) | SPK: `Super---d9ee00d6_eeed_4fc4_af8a_7b5547f508ba---Power`
|
||||
- **final class Response** | [Details](src/c99e85a0-d120-4f25-bcbf-0940dd7b773b) | [Code](src/c99e85a0-d120-4f25-bcbf-0940dd7b773b/code.php) | [Settings](src/c99e85a0-d120-4f25-bcbf-0940dd7b773b/settings.json) | SPK: `Super---c99e85a0_d120_4f25_bcbf_0940dd7b773b---Power`
|
||||
- **final class Uri** | [Details](src/1c5bf656-f73a-46ec-bb9d-aa3932d5b3de) | [Code](src/1c5bf656-f73a-46ec-bb9d-aa3932d5b3de/code.php) | [Settings](src/1c5bf656-f73a-46ec-bb9d-aa3932d5b3de/settings.json) | SPK: `Super---1c5bf656_f73a_46ec_bb9d_aa3932d5b3de---Power`
|
||||
- **class Constantpaths** | [Details](src/e0c8c931-52a0-4171-9909-e8769505bb1f) | [Code](src/e0c8c931-52a0-4171-9909-e8769505bb1f/code.php) | [Settings](src/e0c8c931-52a0-4171-9909-e8769505bb1f/settings.json) | SPK: `Super---e0c8c931_52a0_4171_9909_e8769505bb1f---Power`
|
||||
- **Namespace**: [VDM\Joomla\Componentbuilder\Compiler\Adminview](#vdm-joomla-componentbuilder-compiler-adminview)
|
||||
|
||||
|
@ -108,6 +108,7 @@ class Power implements ServiceProviderInterface
|
||||
{
|
||||
return new Grep(
|
||||
$container->get('Gitea.Repository.Contents'),
|
||||
$container->get('Network.Resolve'),
|
||||
$container->get('Config')->approved_paths,
|
||||
$container->get('Config')->local_powers_repository_path
|
||||
);
|
||||
|
@ -74,6 +74,7 @@
|
||||
{
|
||||
return new Grep(
|
||||
$container->get('Gitea.Repository.Contents'),
|
||||
$container->get('Network.Resolve'),
|
||||
$container->get('Config')->approved_paths,
|
||||
$container->get('Config')->local_powers_repository_path
|
||||
);
|
||||
|
59
src/07ca003e-368c-451d-a3d3-ba24e50c7287/README.md
Normal file
59
src/07ca003e-368c-451d-a3d3-ba24e50c7287/README.md
Normal file
@ -0,0 +1,59 @@
|
||||
```
|
||||
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||
```
|
||||
# final class Network (Details)
|
||||
> namespace: **VDM\Joomla\Componentbuilder\Api**
|
||||
> extends: **Api**
|
||||
|
||||
```uml
|
||||
@startuml
|
||||
class Network << (F,LightGreen) >> #RoyalBlue {
|
||||
+ get(?string $target = null, ?int $status = null, ...) : ?object
|
||||
}
|
||||
|
||||
note right of Network::get
|
||||
Get the network repository statuses
|
||||
|
||||
since: 5.0.4
|
||||
return: ?object
|
||||
|
||||
arguments:
|
||||
?string $target = null
|
||||
?int $status = null
|
||||
string $project = 'jcb'
|
||||
string $system = 'community'
|
||||
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---07ca003e_368c_451d_a3d3_ba24e50c7287---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)
|
||||
|
59
src/07ca003e-368c-451d-a3d3-ba24e50c7287/code.php
Normal file
59
src/07ca003e-368c-451d-a3d3-ba24e50c7287/code.php
Normal file
@ -0,0 +1,59 @@
|
||||
<?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\Api;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Abstraction\Api;
|
||||
|
||||
|
||||
/**
|
||||
* The Joomla Component Builder Network Api
|
||||
*
|
||||
* @since 5.0.4
|
||||
*/
|
||||
final class Network extends Api
|
||||
{
|
||||
/**
|
||||
* Get the network repository statuses
|
||||
*
|
||||
* @param string|null $target The target repositories.
|
||||
* @param int|null $status The repository status.
|
||||
* @param string $project The network project. (default: jcb)
|
||||
* @param string $system The network system. (default: community)
|
||||
*
|
||||
* @return object|null The set of status values
|
||||
* @since 5.0.4
|
||||
**/
|
||||
public function get(?string $target = null, ?int $status = null, string $project = 'jcb', string $system = 'community'): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/network/{$system}/{$project}";
|
||||
|
||||
if (!empty($target))
|
||||
{
|
||||
$path .= "/{$target}";
|
||||
}
|
||||
|
||||
if (!empty($status))
|
||||
{
|
||||
$path .= "/{$status}";
|
||||
}
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
33
src/07ca003e-368c-451d-a3d3-ba24e50c7287/code.power
Normal file
33
src/07ca003e-368c-451d-a3d3-ba24e50c7287/code.power
Normal file
@ -0,0 +1,33 @@
|
||||
/**
|
||||
* Get the network repository statuses
|
||||
*
|
||||
* @param string|null $target The target repositories.
|
||||
* @param int|null $status The repository status.
|
||||
* @param string $project The network project. (default: jcb)
|
||||
* @param string $system The network system. (default: community)
|
||||
*
|
||||
* @return object|null The set of status values
|
||||
* @since 5.0.4
|
||||
**/
|
||||
public function get(?string $target = null, ?int $status = null, string $project = 'jcb', string $system = 'community'): ?object
|
||||
{
|
||||
// Build the request path.
|
||||
$path = "/network/{$system}/{$project}";
|
||||
|
||||
if (!empty($target))
|
||||
{
|
||||
$path .= "/{$target}";
|
||||
}
|
||||
|
||||
if (!empty($status))
|
||||
{
|
||||
$path .= "/{$status}";
|
||||
}
|
||||
|
||||
// Send the get request.
|
||||
return $this->response->get(
|
||||
$this->http->get(
|
||||
$this->uri->get($path)
|
||||
)
|
||||
);
|
||||
}
|
19
src/07ca003e-368c-451d-a3d3-ba24e50c7287/settings.json
Normal file
19
src/07ca003e-368c-451d-a3d3-ba24e50c7287/settings.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"add_head": "0",
|
||||
"add_licensing_template": "2",
|
||||
"extends": "85e0b652-21b9-4ff7-ba27-dbd72256f0f2",
|
||||
"guid": "07ca003e-368c-451d-a3d3-ba24e50c7287",
|
||||
"implements": null,
|
||||
"load_selection": null,
|
||||
"name": "Network",
|
||||
"power_version": "1.0.0",
|
||||
"system_name": "Joomla.JCB.Api.Network",
|
||||
"type": "final class",
|
||||
"use_selection": null,
|
||||
"extendsinterfaces": null,
|
||||
"namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Api.Network",
|
||||
"description": "The Joomla Component Builder Network Api\r\n\r\n@since 5.0.4",
|
||||
"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": ""
|
||||
}
|
@ -12,7 +12,7 @@
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Builder;
|
||||
|
||||
|
||||
use VDM\Joomla\Abstraction\Registry\Traits\ToString;
|
||||
use VDM\Joomla\Abstraction\Registry\Traits\PathToString;
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
@ -25,10 +25,10 @@ use VDM\Joomla\Abstraction\Registry;
|
||||
final class HiddenFields extends Registry implements Registryinterface
|
||||
{
|
||||
/**
|
||||
* To String Values
|
||||
* Path To String Values
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
use ToString;
|
||||
use PathToString;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/**
|
||||
* To String Values
|
||||
* Path To String Values
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
use ToString;
|
||||
use PathToString;
|
@ -8,7 +8,7 @@
|
||||
```
|
||||
# class Config (Details)
|
||||
> namespace: **VDM\Joomla\Componentbuilder\JoomlaPower**
|
||||
> extends: **BaseConfig**
|
||||
> extends: **ComponentConfig**
|
||||
|
||||
```uml
|
||||
@startuml
|
||||
|
@ -17,7 +17,7 @@ use Joomla\CMS\Factory as JoomlaFactory;
|
||||
use VDM\Joomla\Utilities\GetHelper;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Componentbuilder\Utilities\RepoHelper;
|
||||
use VDM\Joomla\Componentbuilder\Abstraction\BaseConfig;
|
||||
use VDM\Joomla\Componentbuilder\Abstraction\ComponentConfig;
|
||||
|
||||
|
||||
/**
|
||||
@ -31,7 +31,7 @@ use VDM\Joomla\Componentbuilder\Abstraction\BaseConfig;
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Config extends BaseConfig
|
||||
class Config extends ComponentConfig
|
||||
{
|
||||
/**
|
||||
* The Global Joomla Configuration
|
||||
|
@ -12,7 +12,7 @@
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Builder;
|
||||
|
||||
|
||||
use VDM\Joomla\Abstraction\Registry\Traits\Count;
|
||||
use VDM\Joomla\Abstraction\Registry\Traits\PathCount;
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
@ -25,10 +25,10 @@ use VDM\Joomla\Abstraction\Registry;
|
||||
final class NewPublishingFields extends Registry implements Registryinterface
|
||||
{
|
||||
/**
|
||||
* Count Values
|
||||
* Path Count Values
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
use Count;
|
||||
use PathCount;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Count Values
|
||||
* Path Count Values
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
use Count;
|
||||
use PathCount;
|
92
src/156f449b-ca6c-4a57-a925-be345e751614/README.md
Normal file
92
src/156f449b-ca6c-4a57-a925-be345e751614/README.md
Normal file
@ -0,0 +1,92 @@
|
||||
```
|
||||
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||
```
|
||||
# class Network (Details)
|
||||
> namespace: **VDM\Joomla\Componentbuilder\Service**
|
||||
|
||||
```uml
|
||||
@startuml
|
||||
class Network #Gold {
|
||||
+ register(Container $container) : void
|
||||
+ getResolve(Container $container) : Resolve
|
||||
+ getStatus(Container $container) : Status
|
||||
+ getUrl(Container $container) : Url
|
||||
+ getCore(Container $container) : Core
|
||||
+ getParsedUrls(Container $container) : ParsedUrls
|
||||
}
|
||||
|
||||
note right of Network::register
|
||||
Registers the service provider with a DI container.
|
||||
|
||||
since: 5.0.4
|
||||
return: void
|
||||
end note
|
||||
|
||||
note right of Network::getResolve
|
||||
Get The Resolve Class.
|
||||
|
||||
since: 5.0.4
|
||||
return: Resolve
|
||||
end note
|
||||
|
||||
note right of Network::getStatus
|
||||
Get The Status Class.
|
||||
|
||||
since: 5.0.4
|
||||
return: Status
|
||||
end note
|
||||
|
||||
note right of Network::getUrl
|
||||
Get The Url Class.
|
||||
|
||||
since: 5.0.4
|
||||
return: Url
|
||||
end note
|
||||
|
||||
note right of Network::getCore
|
||||
Get The Core Class.
|
||||
|
||||
since: 5.0.4
|
||||
return: Core
|
||||
end note
|
||||
|
||||
note right of Network::getParsedUrls
|
||||
Get The ParsedUrls Class.
|
||||
|
||||
since: 5.0.4
|
||||
return: ParsedUrls
|
||||
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---156f449b_ca6c_4a57_a925_be345e751614---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)
|
||||
|
131
src/156f449b-ca6c-4a57-a925-be345e751614/code.php
Normal file
131
src/156f449b-ca6c-4a57-a925-be345e751614/code.php
Normal file
@ -0,0 +1,131 @@
|
||||
<?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\Service;
|
||||
|
||||
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use VDM\Joomla\Componentbuilder\Network\Resolve;
|
||||
use VDM\Joomla\Componentbuilder\Network\Status;
|
||||
use VDM\Joomla\Componentbuilder\Network\Url;
|
||||
use VDM\Joomla\Componentbuilder\Network\Core;
|
||||
use VDM\Joomla\Componentbuilder\Network\ParsedUrls;
|
||||
|
||||
|
||||
/**
|
||||
* The Joomla Component Builder Network Service
|
||||
*
|
||||
* @since 5.0.4
|
||||
*/
|
||||
class Network implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->alias(Resolve::class, 'Network.Resolve')
|
||||
->share('Network.Resolve', [$this, 'getResolve'], true);
|
||||
|
||||
$container->alias(Status::class, 'Network.Status')
|
||||
->share('Network.Status', [$this, 'getStatus'], true);
|
||||
|
||||
$container->alias(Url::class, 'Network.Url')
|
||||
->share('Network.Url', [$this, 'getUrl'], true);
|
||||
|
||||
$container->alias(Core::class, 'Network.Core')
|
||||
->share('Network.Core', [$this, 'getCore'], true);
|
||||
|
||||
$container->alias(ParsedUrls::class, 'Network.Parsed.Urls')
|
||||
->share('Network.Parsed.Urls', [$this, 'getParsedUrls'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Resolve Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Resolve
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function getResolve(Container $container): Resolve
|
||||
{
|
||||
return new Resolve(
|
||||
$container->get('Network.Url'),
|
||||
$container->get('Network.Status')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Status Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Status
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function getStatus(Container $container): Status
|
||||
{
|
||||
return new Status(
|
||||
$container->get('Api.Network'),
|
||||
$container->get('Network.Core'),
|
||||
$container->get('Network.Url')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Url Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Url
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function getUrl(Container $container): Url
|
||||
{
|
||||
return new Url(
|
||||
$container->get('Network.Parsed.Urls')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Core Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Core
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function getCore(Container $container): Core
|
||||
{
|
||||
return new Core();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The ParsedUrls Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return ParsedUrls
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function getParsedUrls(Container $container): ParsedUrls
|
||||
{
|
||||
return new ParsedUrls();
|
||||
}
|
||||
}
|
||||
|
99
src/156f449b-ca6c-4a57-a925-be345e751614/code.power
Normal file
99
src/156f449b-ca6c-4a57-a925-be345e751614/code.power
Normal file
@ -0,0 +1,99 @@
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->alias(Resolve::class, 'Network.Resolve')
|
||||
->share('Network.Resolve', [$this, 'getResolve'], true);
|
||||
|
||||
$container->alias(Status::class, 'Network.Status')
|
||||
->share('Network.Status', [$this, 'getStatus'], true);
|
||||
|
||||
$container->alias(Url::class, 'Network.Url')
|
||||
->share('Network.Url', [$this, 'getUrl'], true);
|
||||
|
||||
$container->alias(Core::class, 'Network.Core')
|
||||
->share('Network.Core', [$this, 'getCore'], true);
|
||||
|
||||
$container->alias(ParsedUrls::class, 'Network.Parsed.Urls')
|
||||
->share('Network.Parsed.Urls', [$this, 'getParsedUrls'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Resolve Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Resolve
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function getResolve(Container $container): Resolve
|
||||
{
|
||||
return new Resolve(
|
||||
$container->get('Network.Url'),
|
||||
$container->get('Network.Status')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Status Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Status
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function getStatus(Container $container): Status
|
||||
{
|
||||
return new Status(
|
||||
$container->get('Api.Network'),
|
||||
$container->get('Network.Core'),
|
||||
$container->get('Network.Url')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Url Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Url
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function getUrl(Container $container): Url
|
||||
{
|
||||
return new Url(
|
||||
$container->get('Network.Parsed.Urls')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Core Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Core
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function getCore(Container $container): Core
|
||||
{
|
||||
return new Core();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The ParsedUrls Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return ParsedUrls
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function getParsedUrls(Container $container): ParsedUrls
|
||||
{
|
||||
return new ParsedUrls();
|
||||
}
|
43
src/156f449b-ca6c-4a57-a925-be345e751614/settings.json
Normal file
43
src/156f449b-ca6c-4a57-a925-be345e751614/settings.json
Normal file
@ -0,0 +1,43 @@
|
||||
{
|
||||
"add_head": "1",
|
||||
"add_licensing_template": "2",
|
||||
"extends": "",
|
||||
"guid": "156f449b-ca6c-4a57-a925-be345e751614",
|
||||
"implements": [
|
||||
"-1"
|
||||
],
|
||||
"load_selection": null,
|
||||
"name": "Network",
|
||||
"power_version": "1.0.0",
|
||||
"system_name": "Joomla.JCB.Service.Network",
|
||||
"type": "class",
|
||||
"use_selection": {
|
||||
"use_selection0": {
|
||||
"use": "a0c143af-3d7d-4c19-91c4-f72060b4c361",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection1": {
|
||||
"use": "809d3077-c105-4e9c-8ac5-8fbee10cf9fc",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection2": {
|
||||
"use": "286f7550-9c22-401c-9e5a-2f9426888133",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection3": {
|
||||
"use": "825ecce9-72ef-4257-bc32-4b05a4c226e9",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection4": {
|
||||
"use": "fd3b25c3-cd49-404c-ae82-b6a125863f10",
|
||||
"as": "default"
|
||||
}
|
||||
},
|
||||
"extendsinterfaces": null,
|
||||
"namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Service.Network",
|
||||
"description": "The Joomla Component Builder Network Service\r\n\r\n@since 5.0.4",
|
||||
"implements_custom": "ServiceProviderInterface",
|
||||
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe <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\\DI\\Container;\r\nuse Joomla\\DI\\ServiceProviderInterface;",
|
||||
"composer": ""
|
||||
}
|
@ -12,7 +12,7 @@
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Builder;
|
||||
|
||||
|
||||
use VDM\Joomla\Abstraction\Registry\Traits\ToString;
|
||||
use VDM\Joomla\Abstraction\Registry\Traits\PathToString;
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
@ -25,10 +25,10 @@ use VDM\Joomla\Abstraction\Registry;
|
||||
final class DynamicFields extends Registry implements Registryinterface
|
||||
{
|
||||
/**
|
||||
* To String Values
|
||||
* Path To String Values
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
use ToString;
|
||||
use PathToString;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/**
|
||||
* To String Values
|
||||
* Path To String Values
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
use ToString;
|
||||
use PathToString;
|
97
src/1c5bf656-f73a-46ec-bb9d-aa3932d5b3de/README.md
Normal file
97
src/1c5bf656-f73a-46ec-bb9d-aa3932d5b3de/README.md
Normal file
@ -0,0 +1,97 @@
|
||||
```
|
||||
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||
```
|
||||
# final class Uri (Details)
|
||||
> namespace: **VDM\Joomla\Componentbuilder\Utilities**
|
||||
|
||||
```uml
|
||||
@startuml
|
||||
class Uri << (F,LightGreen) >> #RoyalBlue {
|
||||
- string $version
|
||||
- string $url
|
||||
+ __construct(string $url = 'https://api.joomlacomponentbuilder.com', string $version = 'v1')
|
||||
+ get(string $path) : JoomlaUri
|
||||
+ api() : string
|
||||
+ setUrl(string $url) : void
|
||||
+ getUrl() : ?string
|
||||
- setVersion(string $version) : void
|
||||
}
|
||||
|
||||
note right of Uri::__construct
|
||||
Constructor
|
||||
example: https://api.joomlacomponentbuilder.com
|
||||
|
||||
since: 3.2.0
|
||||
end note
|
||||
|
||||
note right of Uri::get
|
||||
Method to build and return a full request URL for the request. This method will
|
||||
add appropriate pagination details if necessary and also prepend the API url
|
||||
to have a complete URL for the request.
|
||||
|
||||
since: 3.2.0
|
||||
return: JoomlaUri
|
||||
end note
|
||||
|
||||
note right of Uri::api
|
||||
Get the full API URL
|
||||
|
||||
since: 3.2.0
|
||||
return: string
|
||||
end note
|
||||
|
||||
note right of Uri::setUrl
|
||||
Set the URL of the API
|
||||
example: https://api.joomlacomponentbuilder.com
|
||||
|
||||
since: 3.2.0
|
||||
return: void
|
||||
end note
|
||||
|
||||
note right of Uri::getUrl
|
||||
Get the URL of the API
|
||||
|
||||
since: 3.2.0
|
||||
return: ?string
|
||||
end note
|
||||
|
||||
note right of Uri::setVersion
|
||||
Set the version of the API
|
||||
|
||||
since: 3.2.0
|
||||
return: void
|
||||
end note
|
||||
|
||||
@enduml
|
||||
```
|
||||
|
||||
The Power feature in JCB allows you to write PHP classes and their implementations, making it easy to include them in your Joomla project. JCB handles linking, autoloading, namespacing, and folder structure creation for you.
|
||||
|
||||
By using the SPK (Super Power Key) in your custom code (replacing the class name in your code with the SPK), JCB will automatically pull the power from the repository into your project. This makes it available in your JCB instance, allowing you to edit it and include the class in your generated Joomla component.
|
||||
|
||||
JCB uses placeholders like [[[`NamespacePrefix`]]] and [[[`ComponentNamespace`]]] in namespacing to prevent collisions and improve reusability across different JCB systems. You can also set the **JCB powers path** globally or per component under the **Dynamic Integration** tab, providing flexibility and easy maintainability.
|
||||
|
||||
To add this specific Power to your project in JCB:
|
||||
|
||||
> simply use this SPK
|
||||
```
|
||||
Super---1c5bf656_f73a_46ec_bb9d_aa3932d5b3de---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)
|
||||
|
127
src/1c5bf656-f73a-46ec-bb9d-aa3932d5b3de/code.php
Normal file
127
src/1c5bf656-f73a-46ec-bb9d-aa3932d5b3de/code.php
Normal file
@ -0,0 +1,127 @@
|
||||
<?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\Utilities;
|
||||
|
||||
|
||||
use Joomla\Uri\Uri as JoomlaUri;
|
||||
|
||||
|
||||
/**
|
||||
* The Joomla Component Builder Uri
|
||||
*
|
||||
* @since 5.0.4
|
||||
*/
|
||||
final class Uri
|
||||
{
|
||||
/**
|
||||
* The api version
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private string $version;
|
||||
|
||||
/**
|
||||
* The api URL
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private string $url;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $url URL to the api system
|
||||
* example: https://api.joomlacomponentbuilder.com
|
||||
* @param string $endpoint Endpoint to the gitea system
|
||||
* @param string $version Version to the gitea system
|
||||
*
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function __construct(
|
||||
string $url = 'https://api.joomlacomponentbuilder.com',
|
||||
string $version = 'v1')
|
||||
{
|
||||
// set the API details
|
||||
$this->setUrl($url);
|
||||
$this->setVersion($version);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to build and return a full request URL for the request. This method will
|
||||
* add appropriate pagination details if necessary and also prepend the API url
|
||||
* to have a complete URL for the request.
|
||||
*
|
||||
* @param string $path URL to inflect
|
||||
*
|
||||
* @return JoomlaUri
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(string $path): JoomlaUri
|
||||
{
|
||||
// Get a new Uri object focusing the api url and given path.
|
||||
$uri = new JoomlaUri($this->api() . $path);
|
||||
|
||||
return $uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the full API URL
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function api(): string
|
||||
{
|
||||
return $this->url . '/' . $this->version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the URL of the API
|
||||
*
|
||||
* @param string $url URL to your gitea system
|
||||
* example: https://api.joomlacomponentbuilder.com
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function setUrl(string $url)
|
||||
{
|
||||
$this->url = $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the URL of the API
|
||||
*
|
||||
* @return string|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function getUrl(): ?string
|
||||
{
|
||||
return $this->url ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the version of the API
|
||||
*
|
||||
* @param string $version version to your gitea API
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
**/
|
||||
private function setVersion($version)
|
||||
{
|
||||
$this->version = $version;
|
||||
}
|
||||
}
|
||||
|
101
src/1c5bf656-f73a-46ec-bb9d-aa3932d5b3de/code.power
Normal file
101
src/1c5bf656-f73a-46ec-bb9d-aa3932d5b3de/code.power
Normal file
@ -0,0 +1,101 @@
|
||||
/**
|
||||
* The api version
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private string $version;
|
||||
|
||||
/**
|
||||
* The api URL
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private string $url;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param string $url URL to the api system
|
||||
* example: https://api.joomlacomponentbuilder.com
|
||||
* @param string $endpoint Endpoint to the gitea system
|
||||
* @param string $version Version to the gitea system
|
||||
*
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function __construct(
|
||||
string $url = 'https://api.joomlacomponentbuilder.com',
|
||||
string $version = 'v1')
|
||||
{
|
||||
// set the API details
|
||||
$this->setUrl($url);
|
||||
$this->setVersion($version);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to build and return a full request URL for the request. This method will
|
||||
* add appropriate pagination details if necessary and also prepend the API url
|
||||
* to have a complete URL for the request.
|
||||
*
|
||||
* @param string $path URL to inflect
|
||||
*
|
||||
* @return JoomlaUri
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function get(string $path): JoomlaUri
|
||||
{
|
||||
// Get a new Uri object focusing the api url and given path.
|
||||
$uri = new JoomlaUri($this->api() . $path);
|
||||
|
||||
return $uri;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the full API URL
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function api(): string
|
||||
{
|
||||
return $this->url . '/' . $this->version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the URL of the API
|
||||
*
|
||||
* @param string $url URL to your gitea system
|
||||
* example: https://api.joomlacomponentbuilder.com
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function setUrl(string $url)
|
||||
{
|
||||
$this->url = $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the URL of the API
|
||||
*
|
||||
* @return string|null
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function getUrl(): ?string
|
||||
{
|
||||
return $this->url ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the version of the API
|
||||
*
|
||||
* @param string $version version to your gitea API
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
**/
|
||||
private function setVersion($version)
|
||||
{
|
||||
$this->version = $version;
|
||||
}
|
19
src/1c5bf656-f73a-46ec-bb9d-aa3932d5b3de/settings.json
Normal file
19
src/1c5bf656-f73a-46ec-bb9d-aa3932d5b3de/settings.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"add_head": "1",
|
||||
"add_licensing_template": "2",
|
||||
"extends": "",
|
||||
"guid": "1c5bf656-f73a-46ec-bb9d-aa3932d5b3de",
|
||||
"implements": null,
|
||||
"load_selection": null,
|
||||
"name": "Uri",
|
||||
"power_version": "1.0.0",
|
||||
"system_name": "Joomla.JCB.Utilities.Uri",
|
||||
"type": "final class",
|
||||
"use_selection": null,
|
||||
"extendsinterfaces": null,
|
||||
"namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Utilities.Uri",
|
||||
"description": "The Joomla Component Builder Uri\r\n\r\n@since 5.0.4",
|
||||
"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\\Uri\\Uri as JoomlaUri;",
|
||||
"composer": ""
|
||||
}
|
113
src/286f7550-9c22-401c-9e5a-2f9426888133/README.md
Normal file
113
src/286f7550-9c22-401c-9e5a-2f9426888133/README.md
Normal file
@ -0,0 +1,113 @@
|
||||
```
|
||||
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||
```
|
||||
# final class Url (Details)
|
||||
> namespace: **VDM\Joomla\Componentbuilder\Network**
|
||||
|
||||
```uml
|
||||
@startuml
|
||||
class Url << (F,LightGreen) >> #RoyalBlue {
|
||||
# ParsedUrls $parsedurls
|
||||
+ __construct(ParsedUrls $parsedurls)
|
||||
+ parse(string $url) : object
|
||||
+ base(string $url) : string
|
||||
+ equal(string $url1, string $url2) : bool
|
||||
+ equalStrict(string $url1, string $url2) : bool
|
||||
+ equalRepo(string $url1, string $url2) : bool
|
||||
- compare(string $url1, string $url2, ...) : bool
|
||||
}
|
||||
|
||||
note right of Url::__construct
|
||||
Constructor.
|
||||
|
||||
since: 5.0.4
|
||||
end note
|
||||
|
||||
note right of Url::parse
|
||||
Parses a URL and extracts the domain, organization, and repository.
|
||||
This method takes a URL of the format 'https://[domain]/[organization]/[repository]'
|
||||
and returns an associative array with keys 'domain', 'organization', and 'repository'.
|
||||
|
||||
since: 5.0.4
|
||||
return: object
|
||||
end note
|
||||
|
||||
note right of Url::base
|
||||
Extract the base domain from a given URL or domain string.
|
||||
|
||||
since: 5.0.4
|
||||
return: string
|
||||
end note
|
||||
|
||||
note right of Url::equal
|
||||
Compares two URLs and checks if their domain and repository are the same.
|
||||
This method returns true if both the domain and repository are identical in both URLs.
|
||||
|
||||
since: 5.0.4
|
||||
return: bool
|
||||
end note
|
||||
|
||||
note right of Url::equalStrict
|
||||
Compares two URLs strictly and checks if their domain, organization, and repository are the same.
|
||||
This method returns true if the domain, organization, and repository are identical in both URLs.
|
||||
|
||||
since: 5.0.4
|
||||
return: bool
|
||||
end note
|
||||
|
||||
note right of Url::equalRepo
|
||||
Compares two URLs and checks if their repositories are the same.
|
||||
This method returns true if the repository names are identical in both URLs, regardless of domain and organization.
|
||||
|
||||
since: 5.0.4
|
||||
return: bool
|
||||
end note
|
||||
|
||||
note right of Url::compare
|
||||
Compares two URLs based on specified fields.
|
||||
This method allows you to compare specific components of two URLs, such as 'domain',
|
||||
'organization', and 'repository'. It returns true if all specified fields are equal.
|
||||
or if an invalid field is specified.
|
||||
|
||||
since: 5.0.4
|
||||
return: bool
|
||||
|
||||
arguments:
|
||||
string $url1
|
||||
string $url2
|
||||
array $fields
|
||||
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---286f7550_9c22_401c_9e5a_2f9426888133---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)
|
||||
|
237
src/286f7550-9c22-401c-9e5a-2f9426888133/code.php
Normal file
237
src/286f7550-9c22-401c-9e5a-2f9426888133/code.php
Normal file
@ -0,0 +1,237 @@
|
||||
<?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\Network;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Network\ParsedUrls;
|
||||
|
||||
|
||||
/**
|
||||
* The Network Url
|
||||
*
|
||||
* @since 5.0.4
|
||||
*/
|
||||
final class Url
|
||||
{
|
||||
/**
|
||||
* The ParsedUrls Class.
|
||||
*
|
||||
* @var ParsedUrls
|
||||
* @since 5.0.4
|
||||
*/
|
||||
protected ParsedUrls $parsedurls;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param ParsedUrls $parsedurls The ParsedUrls Class.
|
||||
*
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function __construct(ParsedUrls $parsedurls)
|
||||
{
|
||||
$this->parsedurls = $parsedurls;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a URL and extracts the domain, organization, and repository.
|
||||
*
|
||||
* This method takes a URL of the format 'https://[domain]/[organization]/[repository]'
|
||||
* and returns an associative array with keys 'domain', 'organization', and 'repository'.
|
||||
*
|
||||
* @param string $url The URL to parse.
|
||||
*
|
||||
* @return object An object with keys 'domain', 'organization', and 'repository'.
|
||||
* @throws \InvalidArgumentException If the URL is invalid or lacks required components.
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function parse(string $url): object
|
||||
{
|
||||
// Check if the URL has already been parsed and is present in the cache
|
||||
if (($parsed = $this->parsedurls->get($url)) !== null)
|
||||
{
|
||||
return (object) $parsed;
|
||||
}
|
||||
|
||||
// Validate the URL format
|
||||
if (!filter_var($url, FILTER_VALIDATE_URL))
|
||||
{
|
||||
throw new \InvalidArgumentException("Invalid URL format: $url");
|
||||
}
|
||||
|
||||
// Parse the URL and extract its components
|
||||
$parsedUrl = parse_url($url);
|
||||
|
||||
if ($parsedUrl === false)
|
||||
{
|
||||
throw new \InvalidArgumentException("Invalid URL provided: $url");
|
||||
}
|
||||
|
||||
// Ensure the URL contains a host (domain)
|
||||
if (empty($parsedUrl['host']))
|
||||
{
|
||||
throw new \InvalidArgumentException("The URL does not contain a valid domain: $url");
|
||||
}
|
||||
$domain = $parsedUrl['host'];
|
||||
|
||||
// Set the scheme
|
||||
$scheme = $parsedUrl['scheme'] ?? 'https';
|
||||
|
||||
// Ensure the URL contains a path
|
||||
if (empty($parsedUrl['path']))
|
||||
{
|
||||
throw new \InvalidArgumentException("The URL does not contain a valid path: $url");
|
||||
}
|
||||
|
||||
// Remove leading and trailing slashes from the path
|
||||
$path = trim($parsedUrl['path'], '/');
|
||||
|
||||
// Split the path into components
|
||||
$pathParts = explode('/', $path);
|
||||
|
||||
// Ensure the path contains at least two components: organization and repository
|
||||
if (count($pathParts) < 2)
|
||||
{
|
||||
throw new \InvalidArgumentException("The URL must contain both an organization and a repository: $url");
|
||||
}
|
||||
|
||||
$organization = $pathParts[0];
|
||||
$repository = $pathParts[1];
|
||||
|
||||
// Create a new Parsed Url array
|
||||
$parsed = [
|
||||
'scheme' => $scheme,
|
||||
'domain' => $domain,
|
||||
'organization' => $organization,
|
||||
'repository' => $repository
|
||||
];
|
||||
|
||||
// Store the parsed URL in the cache
|
||||
$this->parsedurls->set($url, $parsed);
|
||||
|
||||
// Return the parsed URL object
|
||||
return (object) $parsed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the base domain from a given URL or domain string.
|
||||
*
|
||||
* @param string $url The input URL or domain string.
|
||||
*
|
||||
* @return string The core domain (e.g., domain.com).
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function base(string $url): string
|
||||
{
|
||||
// Parse the URL to extract host
|
||||
$parsedUrl = parse_url($url, PHP_URL_HOST);
|
||||
|
||||
// If no host is found, check if the input itself is a domain without protocol
|
||||
if (!$parsedUrl)
|
||||
{
|
||||
$parsedUrl = $url;
|
||||
}
|
||||
|
||||
// Remove any trailing slashes or unnecessary characters
|
||||
$parsedUrl = rtrim($parsedUrl, '/');
|
||||
|
||||
return $parsedUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares two URLs and checks if their domain and repository are the same.
|
||||
*
|
||||
* This method returns true if both the domain and repository are identical in both URLs.
|
||||
*
|
||||
* @param string $url1 The first URL to compare.
|
||||
* @param string $url2 The second URL to compare.
|
||||
*
|
||||
* @return bool Returns true if the domain and repository are the same; false otherwise.
|
||||
* @throws InvalidArgumentException If any of the URLs are invalid or lack required components.
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function equal(string $url1, string $url2): bool
|
||||
{
|
||||
return $this->compare($url1, $url2, ['domain', 'repository']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares two URLs strictly and checks if their domain, organization, and repository are the same.
|
||||
*
|
||||
* This method returns true if the domain, organization, and repository are identical in both URLs.
|
||||
*
|
||||
* @param string $url1 The first URL to compare.
|
||||
* @param string $url2 The second URL to compare.
|
||||
*
|
||||
* @return bool Returns true if the domain, organization, and repository are the same; false otherwise.
|
||||
* @throws \InvalidArgumentException If any of the URLs are invalid or lack required components.
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function equalStrict(string $url1, string $url2): bool
|
||||
{
|
||||
return $this->compare($url1, $url2, ['domain', 'organization', 'repository']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares two URLs and checks if their repositories are the same.
|
||||
*
|
||||
* This method returns true if the repository names are identical in both URLs, regardless of domain and organization.
|
||||
*
|
||||
* @param string $url1 The first URL to compare.
|
||||
* @param string $url2 The second URL to compare.
|
||||
*
|
||||
* @return bool Returns true if the repositories are the same; false otherwise.
|
||||
* @throws \InvalidArgumentException If any of the URLs are invalid or lack required components.
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function equalRepo(string $url1, string $url2): bool
|
||||
{
|
||||
return $this->compare($url1, $url2, ['repository']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares two URLs based on specified fields.
|
||||
*
|
||||
* This method allows you to compare specific components of two URLs, such as 'domain',
|
||||
* 'organization', and 'repository'. It returns true if all specified fields are equal.
|
||||
*
|
||||
* @param string $url1 The first URL to compare.
|
||||
* @param string $url2 The second URL to compare.
|
||||
* @param string[] $fields The fields to compare ('domain', 'organization', 'repository').
|
||||
*
|
||||
* @return bool Returns true if all specified fields are equal; false otherwise.
|
||||
* @throws \InvalidArgumentException If any of the URLs are invalid or lack required components,
|
||||
* or if an invalid field is specified.
|
||||
* @since 5.0.4
|
||||
*/
|
||||
private function compare(string $url1, string $url2, array $fields): bool
|
||||
{
|
||||
$parsedUrl1 = $this->parse($url1);
|
||||
$parsedUrl2 = $this->parse($url2);
|
||||
|
||||
foreach ($fields as $field)
|
||||
{
|
||||
if (!property_exists($parsedUrl1, $field) || !property_exists($parsedUrl2, $field))
|
||||
{
|
||||
throw new \InvalidArgumentException("Invalid field specified for comparison: $field");
|
||||
}
|
||||
|
||||
if ($parsedUrl1->$field !== $parsedUrl2->$field)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
211
src/286f7550-9c22-401c-9e5a-2f9426888133/code.power
Normal file
211
src/286f7550-9c22-401c-9e5a-2f9426888133/code.power
Normal file
@ -0,0 +1,211 @@
|
||||
/**
|
||||
* The ParsedUrls Class.
|
||||
*
|
||||
* @var ParsedUrls
|
||||
* @since 5.0.4
|
||||
*/
|
||||
protected ParsedUrls $parsedurls;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param ParsedUrls $parsedurls The ParsedUrls Class.
|
||||
*
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function __construct(ParsedUrls $parsedurls)
|
||||
{
|
||||
$this->parsedurls = $parsedurls;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a URL and extracts the domain, organization, and repository.
|
||||
*
|
||||
* This method takes a URL of the format 'https://[domain]/[organization]/[repository]'
|
||||
* and returns an associative array with keys 'domain', 'organization', and 'repository'.
|
||||
*
|
||||
* @param string $url The URL to parse.
|
||||
*
|
||||
* @return object An object with keys 'domain', 'organization', and 'repository'.
|
||||
* @throws \InvalidArgumentException If the URL is invalid or lacks required components.
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function parse(string $url): object
|
||||
{
|
||||
// Check if the URL has already been parsed and is present in the cache
|
||||
if (($parsed = $this->parsedurls->get($url)) !== null)
|
||||
{
|
||||
return (object) $parsed;
|
||||
}
|
||||
|
||||
// Validate the URL format
|
||||
if (!filter_var($url, FILTER_VALIDATE_URL))
|
||||
{
|
||||
throw new \InvalidArgumentException("Invalid URL format: $url");
|
||||
}
|
||||
|
||||
// Parse the URL and extract its components
|
||||
$parsedUrl = parse_url($url);
|
||||
|
||||
if ($parsedUrl === false)
|
||||
{
|
||||
throw new \InvalidArgumentException("Invalid URL provided: $url");
|
||||
}
|
||||
|
||||
// Ensure the URL contains a host (domain)
|
||||
if (empty($parsedUrl['host']))
|
||||
{
|
||||
throw new \InvalidArgumentException("The URL does not contain a valid domain: $url");
|
||||
}
|
||||
$domain = $parsedUrl['host'];
|
||||
|
||||
// Set the scheme
|
||||
$scheme = $parsedUrl['scheme'] ?? 'https';
|
||||
|
||||
// Ensure the URL contains a path
|
||||
if (empty($parsedUrl['path']))
|
||||
{
|
||||
throw new \InvalidArgumentException("The URL does not contain a valid path: $url");
|
||||
}
|
||||
|
||||
// Remove leading and trailing slashes from the path
|
||||
$path = trim($parsedUrl['path'], '/');
|
||||
|
||||
// Split the path into components
|
||||
$pathParts = explode('/', $path);
|
||||
|
||||
// Ensure the path contains at least two components: organization and repository
|
||||
if (count($pathParts) < 2)
|
||||
{
|
||||
throw new \InvalidArgumentException("The URL must contain both an organization and a repository: $url");
|
||||
}
|
||||
|
||||
$organization = $pathParts[0];
|
||||
$repository = $pathParts[1];
|
||||
|
||||
// Create a new Parsed Url array
|
||||
$parsed = [
|
||||
'scheme' => $scheme,
|
||||
'domain' => $domain,
|
||||
'organization' => $organization,
|
||||
'repository' => $repository
|
||||
];
|
||||
|
||||
// Store the parsed URL in the cache
|
||||
$this->parsedurls->set($url, $parsed);
|
||||
|
||||
// Return the parsed URL object
|
||||
return (object) $parsed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the base domain from a given URL or domain string.
|
||||
*
|
||||
* @param string $url The input URL or domain string.
|
||||
*
|
||||
* @return string The core domain (e.g., domain.com).
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function base(string $url): string
|
||||
{
|
||||
// Parse the URL to extract host
|
||||
$parsedUrl = parse_url($url, PHP_URL_HOST);
|
||||
|
||||
// If no host is found, check if the input itself is a domain without protocol
|
||||
if (!$parsedUrl)
|
||||
{
|
||||
$parsedUrl = $url;
|
||||
}
|
||||
|
||||
// Remove any trailing slashes or unnecessary characters
|
||||
$parsedUrl = rtrim($parsedUrl, '/');
|
||||
|
||||
return $parsedUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares two URLs and checks if their domain and repository are the same.
|
||||
*
|
||||
* This method returns true if both the domain and repository are identical in both URLs.
|
||||
*
|
||||
* @param string $url1 The first URL to compare.
|
||||
* @param string $url2 The second URL to compare.
|
||||
*
|
||||
* @return bool Returns true if the domain and repository are the same; false otherwise.
|
||||
* @throws InvalidArgumentException If any of the URLs are invalid or lack required components.
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function equal(string $url1, string $url2): bool
|
||||
{
|
||||
return $this->compare($url1, $url2, ['domain', 'repository']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares two URLs strictly and checks if their domain, organization, and repository are the same.
|
||||
*
|
||||
* This method returns true if the domain, organization, and repository are identical in both URLs.
|
||||
*
|
||||
* @param string $url1 The first URL to compare.
|
||||
* @param string $url2 The second URL to compare.
|
||||
*
|
||||
* @return bool Returns true if the domain, organization, and repository are the same; false otherwise.
|
||||
* @throws \InvalidArgumentException If any of the URLs are invalid or lack required components.
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function equalStrict(string $url1, string $url2): bool
|
||||
{
|
||||
return $this->compare($url1, $url2, ['domain', 'organization', 'repository']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares two URLs and checks if their repositories are the same.
|
||||
*
|
||||
* This method returns true if the repository names are identical in both URLs, regardless of domain and organization.
|
||||
*
|
||||
* @param string $url1 The first URL to compare.
|
||||
* @param string $url2 The second URL to compare.
|
||||
*
|
||||
* @return bool Returns true if the repositories are the same; false otherwise.
|
||||
* @throws \InvalidArgumentException If any of the URLs are invalid or lack required components.
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function equalRepo(string $url1, string $url2): bool
|
||||
{
|
||||
return $this->compare($url1, $url2, ['repository']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares two URLs based on specified fields.
|
||||
*
|
||||
* This method allows you to compare specific components of two URLs, such as 'domain',
|
||||
* 'organization', and 'repository'. It returns true if all specified fields are equal.
|
||||
*
|
||||
* @param string $url1 The first URL to compare.
|
||||
* @param string $url2 The second URL to compare.
|
||||
* @param string[] $fields The fields to compare ('domain', 'organization', 'repository').
|
||||
*
|
||||
* @return bool Returns true if all specified fields are equal; false otherwise.
|
||||
* @throws \InvalidArgumentException If any of the URLs are invalid or lack required components,
|
||||
* or if an invalid field is specified.
|
||||
* @since 5.0.4
|
||||
*/
|
||||
private function compare(string $url1, string $url2, array $fields): bool
|
||||
{
|
||||
$parsedUrl1 = $this->parse($url1);
|
||||
$parsedUrl2 = $this->parse($url2);
|
||||
|
||||
foreach ($fields as $field)
|
||||
{
|
||||
if (!property_exists($parsedUrl1, $field) || !property_exists($parsedUrl2, $field))
|
||||
{
|
||||
throw new \InvalidArgumentException("Invalid field specified for comparison: $field");
|
||||
}
|
||||
|
||||
if ($parsedUrl1->$field !== $parsedUrl2->$field)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
24
src/286f7550-9c22-401c-9e5a-2f9426888133/settings.json
Normal file
24
src/286f7550-9c22-401c-9e5a-2f9426888133/settings.json
Normal file
@ -0,0 +1,24 @@
|
||||
{
|
||||
"add_head": "0",
|
||||
"add_licensing_template": "2",
|
||||
"extends": "",
|
||||
"guid": "286f7550-9c22-401c-9e5a-2f9426888133",
|
||||
"implements": null,
|
||||
"load_selection": null,
|
||||
"name": "Url",
|
||||
"power_version": "1.0.0",
|
||||
"system_name": "Joomla.JCB.Network.Url",
|
||||
"type": "final class",
|
||||
"use_selection": {
|
||||
"use_selection0": {
|
||||
"use": "fd3b25c3-cd49-404c-ae82-b6a125863f10",
|
||||
"as": "default"
|
||||
}
|
||||
},
|
||||
"extendsinterfaces": null,
|
||||
"namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Network.Url",
|
||||
"description": "The Network Url\r\n\r\n@since 5.0.4",
|
||||
"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": ""
|
||||
}
|
@ -181,7 +181,7 @@ final class InputButton implements InputButtonInterface
|
||||
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
|
||||
. " get the return value.";
|
||||
$addButton[] = Indent::_(4)
|
||||
. "\$_uri = (string) \Joomla\CMS\Uri\Uri::getInstance();";
|
||||
. "\$_uri = (string) Joomla__"."_eecc143e_b5cf_4c33_ba4d_97da1df61422___Power::getInstance();";
|
||||
$addButton[] = Indent::_(4)
|
||||
. "\$_return = urlencode(base64_encode(\$_uri));";
|
||||
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
|
||||
@ -206,7 +206,7 @@ final class InputButton implements InputButtonInterface
|
||||
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
|
||||
. " get the return value.";
|
||||
$addButton[] = Indent::_(4)
|
||||
. "\$_uri = (string) \Joomla\CMS\Uri\Uri::getInstance();";
|
||||
. "\$_uri = (string) Joomla__"."_eecc143e_b5cf_4c33_ba4d_97da1df61422___Power::getInstance();";
|
||||
$addButton[] = Indent::_(4)
|
||||
. "\$_return = urlencode(base64_encode(\$_uri));";
|
||||
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
|
||||
|
@ -150,7 +150,7 @@
|
||||
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
|
||||
. " get the return value.";
|
||||
$addButton[] = Indent::_(4)
|
||||
. "\$_uri = (string) \Joomla\CMS\Uri\Uri::getInstance();";
|
||||
. "\$_uri = (string) Joomla__"."_eecc143e_b5cf_4c33_ba4d_97da1df61422___Power::getInstance();";
|
||||
$addButton[] = Indent::_(4)
|
||||
. "\$_return = urlencode(base64_encode(\$_uri));";
|
||||
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
|
||||
@ -175,7 +175,7 @@
|
||||
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
|
||||
. " get the return value.";
|
||||
$addButton[] = Indent::_(4)
|
||||
. "\$_uri = (string) \Joomla\CMS\Uri\Uri::getInstance();";
|
||||
. "\$_uri = (string) Joomla__"."_eecc143e_b5cf_4c33_ba4d_97da1df61422___Power::getInstance();";
|
||||
$addButton[] = Indent::_(4)
|
||||
. "\$_return = urlencode(base64_encode(\$_uri));";
|
||||
$addButton[] = Indent::_(4) . "//" . Line::_(__Line__, __Class__)
|
||||
|
@ -13,6 +13,7 @@
|
||||
```uml
|
||||
@startuml
|
||||
class Grep << (F,LightGreen) >> #RoyalBlue {
|
||||
# ?string $target
|
||||
# array $order
|
||||
# searchRemote(string $guid) : ?object
|
||||
# getRemote(object $path, string $guid) : ?object
|
||||
|
@ -29,6 +29,14 @@ use VDM\Joomla\Abstraction\Grep as ExtendingGrep;
|
||||
*/
|
||||
final class Grep extends ExtendingGrep implements GrepInterface
|
||||
{
|
||||
/**
|
||||
* The Grep target [network]
|
||||
*
|
||||
* @var string
|
||||
* @since 5.0.4
|
||||
**/
|
||||
protected ?string $target = 'joomla-powers';
|
||||
|
||||
/**
|
||||
* Order of global search
|
||||
*
|
||||
@ -77,7 +85,7 @@ final class Grep extends ExtendingGrep implements GrepInterface
|
||||
$branch = $this->getBranchName($path);
|
||||
|
||||
// load the base and token if set
|
||||
$this->contents->load_($path->base ?? null, $path->token ?? null);
|
||||
$this->loadApi($this->contents, $path->base ?? null, $path->token ?? null);
|
||||
|
||||
// get the settings
|
||||
if (($power = $this->loadRemoteFile($path->organisation, $path->repository, $path->index->{$guid}->path . '/item.json', $branch)) !== null &&
|
||||
|
@ -1,3 +1,11 @@
|
||||
/**
|
||||
* The Grep target [network]
|
||||
*
|
||||
* @var string
|
||||
* @since 5.0.4
|
||||
**/
|
||||
protected ?string $target = 'joomla-powers';
|
||||
|
||||
/**
|
||||
* Order of global search
|
||||
*
|
||||
@ -46,7 +54,7 @@
|
||||
$branch = $this->getBranchName($path);
|
||||
|
||||
// load the base and token if set
|
||||
$this->contents->load_($path->base ?? null, $path->token ?? null);
|
||||
$this->loadApi($this->contents, $path->base ?? null, $path->token ?? null);
|
||||
|
||||
// get the settings
|
||||
if (($power = $this->loadRemoteFile($path->organisation, $path->repository, $path->index->{$guid}->path . '/item.json', $branch)) !== null &&
|
||||
|
@ -100,6 +100,7 @@ class JoomlaPower implements ServiceProviderInterface
|
||||
{
|
||||
return new Grep(
|
||||
$container->get('Gitea.Repository.Contents'),
|
||||
$container->get('Network.Resolve'),
|
||||
$container->get('Config')->approved_joomla_paths
|
||||
);
|
||||
}
|
||||
|
@ -68,6 +68,7 @@
|
||||
{
|
||||
return new Grep(
|
||||
$container->get('Gitea.Repository.Contents'),
|
||||
$container->get('Network.Resolve'),
|
||||
$container->get('Config')->approved_joomla_paths
|
||||
);
|
||||
}
|
||||
|
60
src/3c7567d7-b079-4910-b325-7ed5c30cabff/README.md
Normal file
60
src/3c7567d7-b079-4910-b325-7ed5c30cabff/README.md
Normal file
@ -0,0 +1,60 @@
|
||||
```
|
||||
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||
```
|
||||
# class Api (Details)
|
||||
> namespace: **VDM\Joomla\Componentbuilder\Service**
|
||||
|
||||
```uml
|
||||
@startuml
|
||||
class Api #Gold {
|
||||
+ register(Container $container) : void
|
||||
+ getNetwork(Container $container) : Network
|
||||
}
|
||||
|
||||
note right of Api::register
|
||||
Registers the service provider with a DI container.
|
||||
|
||||
since: 5.0.4
|
||||
return: void
|
||||
end note
|
||||
|
||||
note right of Api::getNetwork
|
||||
Get The Network Class.
|
||||
|
||||
since: 5.0.4
|
||||
return: Network
|
||||
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---3c7567d7_b079_4910_b325_7ed5c30cabff---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)
|
||||
|
58
src/3c7567d7-b079-4910-b325-7ed5c30cabff/code.php
Normal file
58
src/3c7567d7-b079-4910-b325-7ed5c30cabff/code.php
Normal file
@ -0,0 +1,58 @@
|
||||
<?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\Service;
|
||||
|
||||
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use VDM\Joomla\Componentbuilder\Api\Network;
|
||||
|
||||
|
||||
/**
|
||||
* The Joomla Component Builder Api Service
|
||||
*
|
||||
* @since 5.0.4
|
||||
*/
|
||||
class Api implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->alias(Network::class, 'Api.Network')
|
||||
->share('Api.Network', [$this, 'getNetwork'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Network Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Network
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function getNetwork(Container $container): Network
|
||||
{
|
||||
return new Network(
|
||||
$container->get('Utilities.Http'),
|
||||
$container->get('Utilities.Uri'),
|
||||
$container->get('Utilities.Response')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
30
src/3c7567d7-b079-4910-b325-7ed5c30cabff/code.power
Normal file
30
src/3c7567d7-b079-4910-b325-7ed5c30cabff/code.power
Normal file
@ -0,0 +1,30 @@
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->alias(Network::class, 'Api.Network')
|
||||
->share('Api.Network', [$this, 'getNetwork'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Network Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Network
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function getNetwork(Container $container): Network
|
||||
{
|
||||
return new Network(
|
||||
$container->get('Utilities.Http'),
|
||||
$container->get('Utilities.Uri'),
|
||||
$container->get('Utilities.Response')
|
||||
);
|
||||
}
|
27
src/3c7567d7-b079-4910-b325-7ed5c30cabff/settings.json
Normal file
27
src/3c7567d7-b079-4910-b325-7ed5c30cabff/settings.json
Normal file
@ -0,0 +1,27 @@
|
||||
{
|
||||
"add_head": "1",
|
||||
"add_licensing_template": "2",
|
||||
"extends": "",
|
||||
"guid": "3c7567d7-b079-4910-b325-7ed5c30cabff",
|
||||
"implements": [
|
||||
"-1"
|
||||
],
|
||||
"load_selection": null,
|
||||
"name": "Api",
|
||||
"power_version": "1.0.0",
|
||||
"system_name": "Joomla.JCB.Service.Api",
|
||||
"type": "class",
|
||||
"use_selection": {
|
||||
"use_selection0": {
|
||||
"use": "07ca003e-368c-451d-a3d3-ba24e50c7287",
|
||||
"as": "default"
|
||||
}
|
||||
},
|
||||
"extendsinterfaces": null,
|
||||
"namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Service.Api",
|
||||
"description": "The Joomla Component Builder Api Service\r\n\r\n@since 5.0.4",
|
||||
"implements_custom": "ServiceProviderInterface",
|
||||
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe <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\\DI\\Container;\r\nuse Joomla\\DI\\ServiceProviderInterface;",
|
||||
"composer": ""
|
||||
}
|
@ -20,6 +20,9 @@ use VDM\Joomla\Service\Data;
|
||||
use VDM\Joomla\Componentbuilder\Service\Gitea;
|
||||
use VDM\Joomla\Componentbuilder\Power\Service\Gitea as GiteaPower;
|
||||
use VDM\Joomla\Gitea\Service\Utilities as GiteaUtilities;
|
||||
use VDM\Joomla\Componentbuilder\Service\Api;
|
||||
use VDM\Joomla\Componentbuilder\Service\Network;
|
||||
use VDM\Joomla\Componentbuilder\Service\Utilities;
|
||||
use VDM\Joomla\Interfaces\FactoryInterface;
|
||||
use VDM\Joomla\Abstraction\Factory as ExtendingFactory;
|
||||
|
||||
@ -54,7 +57,10 @@ abstract class Factory extends ExtendingFactory implements FactoryInterface
|
||||
->registerServiceProvider(new Data())
|
||||
->registerServiceProvider(new Gitea())
|
||||
->registerServiceProvider(new GiteaPower())
|
||||
->registerServiceProvider(new GiteaUtilities());
|
||||
->registerServiceProvider(new GiteaUtilities())
|
||||
->registerServiceProvider(new Api())
|
||||
->registerServiceProvider(new Network())
|
||||
->registerServiceProvider(new Utilities());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,5 +21,8 @@
|
||||
->registerServiceProvider(new Data())
|
||||
->registerServiceProvider(new Gitea())
|
||||
->registerServiceProvider(new GiteaPower())
|
||||
->registerServiceProvider(new GiteaUtilities());
|
||||
->registerServiceProvider(new GiteaUtilities())
|
||||
->registerServiceProvider(new Api())
|
||||
->registerServiceProvider(new Network())
|
||||
->registerServiceProvider(new Utilities());
|
||||
}
|
@ -39,6 +39,18 @@
|
||||
"use_selection6": {
|
||||
"use": "6edf0cf3-c2b0-45c9-84d2-c6ef1c5d434c",
|
||||
"as": "GiteaUtilities"
|
||||
},
|
||||
"use_selection9": {
|
||||
"use": "3c7567d7-b079-4910-b325-7ed5c30cabff",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection8": {
|
||||
"use": "156f449b-ca6c-4a57-a925-be345e751614",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection7": {
|
||||
"use": "facd1e1c-ff2f-4520-b735-075c45aa55ed",
|
||||
"as": "default"
|
||||
}
|
||||
},
|
||||
"extendsinterfaces": null,
|
||||
|
@ -100,6 +100,7 @@ class Fieldtype implements ServiceProviderInterface
|
||||
{
|
||||
return new Grep(
|
||||
$container->get('Gitea.Repository.Contents'),
|
||||
$container->get('Network.Resolve'),
|
||||
$container->get('Config')->approved_joomla_paths
|
||||
);
|
||||
}
|
||||
|
@ -68,6 +68,7 @@
|
||||
{
|
||||
return new Grep(
|
||||
$container->get('Gitea.Repository.Contents'),
|
||||
$container->get('Network.Resolve'),
|
||||
$container->get('Config')->approved_joomla_paths
|
||||
);
|
||||
}
|
||||
|
@ -19,11 +19,14 @@ class Utilities #Gold {
|
||||
+ getCounter(Container $container) : Counter
|
||||
+ getPaths(Container $container) : Paths
|
||||
+ getFiles(Container $container) : Files
|
||||
+ getConstantpaths(Container $container) : Constantpaths
|
||||
+ getDynamicpath(Container $container) : Dynamicpath
|
||||
+ getPathfix(Container $container) : Pathfix
|
||||
+ getStructure(Container $container) : Structure
|
||||
+ getXml(Container $container) : Xml
|
||||
+ getConstantpaths(Container $container) : Constantpaths
|
||||
+ getUri(Container $container) : Uri
|
||||
+ getHttp(Container $container) : Http
|
||||
+ getResponse(Container $container) : Response
|
||||
}
|
||||
|
||||
note right of Utilities::register
|
||||
@ -75,6 +78,34 @@ note right of Utilities::getFiles
|
||||
return: Files
|
||||
end note
|
||||
|
||||
note left of Utilities::getDynamicpath
|
||||
Get the Compiler Dynamic Path
|
||||
|
||||
since: 3.2.0
|
||||
return: Dynamicpath
|
||||
end note
|
||||
|
||||
note right of Utilities::getPathfix
|
||||
Get the Compiler Path Fixer
|
||||
|
||||
since: 3.2.0
|
||||
return: Pathfix
|
||||
end note
|
||||
|
||||
note left of Utilities::getStructure
|
||||
Get the Compiler Structure Dynamic Builder
|
||||
|
||||
since: 3.2.0
|
||||
return: Structure
|
||||
end note
|
||||
|
||||
note right of Utilities::getXml
|
||||
Get the Compiler Xml Helper
|
||||
|
||||
since: 3.2.0
|
||||
return: Xml
|
||||
end note
|
||||
|
||||
note left of Utilities::getConstantpaths
|
||||
Get the Constant Paths
|
||||
|
||||
@ -82,32 +113,25 @@ note left of Utilities::getConstantpaths
|
||||
return: Constantpaths
|
||||
end note
|
||||
|
||||
note right of Utilities::getDynamicpath
|
||||
Get the Compiler Dynamic Path
|
||||
note right of Utilities::getUri
|
||||
Get The Uri Class.
|
||||
|
||||
since: 3.2.0
|
||||
return: Dynamicpath
|
||||
since: 5.0.4
|
||||
return: Uri
|
||||
end note
|
||||
|
||||
note left of Utilities::getPathfix
|
||||
Get the Compiler Path Fixer
|
||||
note left of Utilities::getHttp
|
||||
Get The Http Class.
|
||||
|
||||
since: 3.2.0
|
||||
return: Pathfix
|
||||
since: 5.0.4
|
||||
return: Http
|
||||
end note
|
||||
|
||||
note right of Utilities::getStructure
|
||||
Get the Compiler Structure Dynamic Builder
|
||||
note right of Utilities::getResponse
|
||||
Get The Response Class.
|
||||
|
||||
since: 3.2.0
|
||||
return: Structure
|
||||
end note
|
||||
|
||||
note left of Utilities::getXml
|
||||
Get the Compiler Xml Helper
|
||||
|
||||
since: 3.2.0
|
||||
return: Xml
|
||||
since: 5.0.4
|
||||
return: Response
|
||||
end note
|
||||
|
||||
@enduml
|
||||
|
@ -21,11 +21,14 @@ use VDM\Joomla\Componentbuilder\Compiler\Utilities\FileInjector;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Paths;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Counter;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Files;
|
||||
use VDM\Joomla\Componentbuilder\Utilities\Constantpaths;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Dynamicpath;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Pathfix;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Structure;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Xml;
|
||||
use VDM\Joomla\Componentbuilder\Utilities\Constantpaths;
|
||||
use VDM\Joomla\Componentbuilder\Utilities\Uri;
|
||||
use VDM\Joomla\Componentbuilder\Utilities\Http;
|
||||
use VDM\Joomla\Componentbuilder\Utilities\Response;
|
||||
|
||||
|
||||
/**
|
||||
@ -41,7 +44,7 @@ class Utilities implements ServiceProviderInterface
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
@ -63,9 +66,6 @@ class Utilities implements ServiceProviderInterface
|
||||
$container->alias(Files::class, 'Utilities.Files')
|
||||
->share('Utilities.Files', [$this, 'getFiles'], true);
|
||||
|
||||
$container->alias(Constantpaths::class, 'Utilities.Constantpaths')
|
||||
->share('Utilities.Constantpaths', [$this, 'getConstantpaths'], true);
|
||||
|
||||
$container->alias(Dynamicpath::class, 'Utilities.Dynamicpath')
|
||||
->share('Utilities.Dynamicpath', [$this, 'getDynamicpath'], true);
|
||||
|
||||
@ -77,6 +77,18 @@ class Utilities implements ServiceProviderInterface
|
||||
|
||||
$container->alias(Xml::class, 'Utilities.Xml')
|
||||
->share('Utilities.Xml', [$this, 'getXml'], true);
|
||||
|
||||
$container->alias(Constantpaths::class, 'Utilities.Constantpaths')
|
||||
->share('Utilities.Constantpaths', [$this, 'getConstantpaths'], true);
|
||||
|
||||
$container->alias(Uri::class, 'Utilities.Uri')
|
||||
->share('Utilities.Uri', [$this, 'getUri'], true);
|
||||
|
||||
$container->alias(Http::class, 'Utilities.Http')
|
||||
->share('Utilities.Http', [$this, 'getHttp'], true);
|
||||
|
||||
$container->alias(Response::class, 'Utilities.Response')
|
||||
->share('Utilities.Response', [$this, 'getResponse'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -85,7 +97,7 @@ class Utilities implements ServiceProviderInterface
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Folder
|
||||
* @since 3.2.0
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getFolder(Container $container): Folder
|
||||
{
|
||||
@ -101,7 +113,7 @@ class Utilities implements ServiceProviderInterface
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return File
|
||||
* @since 3.2.0
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getFile(Container $container): File
|
||||
{
|
||||
@ -116,7 +128,7 @@ class Utilities implements ServiceProviderInterface
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return FileInjector
|
||||
* @since 3.2.0
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getFileInjector(Container $container): FileInjector
|
||||
{
|
||||
@ -132,7 +144,7 @@ class Utilities implements ServiceProviderInterface
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Counter
|
||||
* @since 3.2.0
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getCounter(Container $container): Counter
|
||||
{
|
||||
@ -147,7 +159,7 @@ class Utilities implements ServiceProviderInterface
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Paths
|
||||
* @since 3.2.0
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getPaths(Container $container): Paths
|
||||
{
|
||||
@ -163,33 +175,20 @@ class Utilities implements ServiceProviderInterface
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Files
|
||||
* @since 3.2.0
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getFiles(Container $container): Files
|
||||
{
|
||||
return new Files();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Constant Paths
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Constantpaths
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getConstantpaths(Container $container): Constantpaths
|
||||
{
|
||||
return new Constantpaths();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Compiler Dynamic Path
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Dynamicpath
|
||||
* @since 3.2.0
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getDynamicpath(Container $container): Dynamicpath
|
||||
{
|
||||
@ -205,7 +204,7 @@ class Utilities implements ServiceProviderInterface
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Pathfix
|
||||
* @since 3.2.0
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getPathfix(Container $container): Pathfix
|
||||
{
|
||||
@ -218,7 +217,7 @@ class Utilities implements ServiceProviderInterface
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Structure
|
||||
* @since 3.2.0
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getStructure(Container $container): Structure
|
||||
{
|
||||
@ -238,13 +237,65 @@ class Utilities implements ServiceProviderInterface
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Xml
|
||||
* @since 3.2.0
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getXml(Container $container): Xml
|
||||
{
|
||||
return new Xml(
|
||||
$container->get('Config')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Constant Paths
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Constantpaths
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getConstantpaths(Container $container): Constantpaths
|
||||
{
|
||||
return new Constantpaths();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Uri Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Uri
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function getUri(Container $container): Uri
|
||||
{
|
||||
return new Uri();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Http Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Http
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function getHttp(Container $container): Http
|
||||
{
|
||||
return new Http();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Response Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Response
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function getResponse(Container $container): Response
|
||||
{
|
||||
return new Response();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
@ -26,9 +26,6 @@
|
||||
$container->alias(Files::class, 'Utilities.Files')
|
||||
->share('Utilities.Files', [$this, 'getFiles'], true);
|
||||
|
||||
$container->alias(Constantpaths::class, 'Utilities.Constantpaths')
|
||||
->share('Utilities.Constantpaths', [$this, 'getConstantpaths'], true);
|
||||
|
||||
$container->alias(Dynamicpath::class, 'Utilities.Dynamicpath')
|
||||
->share('Utilities.Dynamicpath', [$this, 'getDynamicpath'], true);
|
||||
|
||||
@ -40,6 +37,18 @@
|
||||
|
||||
$container->alias(Xml::class, 'Utilities.Xml')
|
||||
->share('Utilities.Xml', [$this, 'getXml'], true);
|
||||
|
||||
$container->alias(Constantpaths::class, 'Utilities.Constantpaths')
|
||||
->share('Utilities.Constantpaths', [$this, 'getConstantpaths'], true);
|
||||
|
||||
$container->alias(Uri::class, 'Utilities.Uri')
|
||||
->share('Utilities.Uri', [$this, 'getUri'], true);
|
||||
|
||||
$container->alias(Http::class, 'Utilities.Http')
|
||||
->share('Utilities.Http', [$this, 'getHttp'], true);
|
||||
|
||||
$container->alias(Response::class, 'Utilities.Response')
|
||||
->share('Utilities.Response', [$this, 'getResponse'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -48,7 +57,7 @@
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Folder
|
||||
* @since 3.2.0
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getFolder(Container $container): Folder
|
||||
{
|
||||
@ -64,7 +73,7 @@
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return File
|
||||
* @since 3.2.0
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getFile(Container $container): File
|
||||
{
|
||||
@ -79,7 +88,7 @@
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return FileInjector
|
||||
* @since 3.2.0
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getFileInjector(Container $container): FileInjector
|
||||
{
|
||||
@ -95,7 +104,7 @@
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Counter
|
||||
* @since 3.2.0
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getCounter(Container $container): Counter
|
||||
{
|
||||
@ -110,7 +119,7 @@
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Paths
|
||||
* @since 3.2.0
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getPaths(Container $container): Paths
|
||||
{
|
||||
@ -126,33 +135,20 @@
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Files
|
||||
* @since 3.2.0
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getFiles(Container $container): Files
|
||||
{
|
||||
return new Files();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Constant Paths
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Constantpaths
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getConstantpaths(Container $container): Constantpaths
|
||||
{
|
||||
return new Constantpaths();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Compiler Dynamic Path
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Dynamicpath
|
||||
* @since 3.2.0
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getDynamicpath(Container $container): Dynamicpath
|
||||
{
|
||||
@ -168,7 +164,7 @@
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Pathfix
|
||||
* @since 3.2.0
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getPathfix(Container $container): Pathfix
|
||||
{
|
||||
@ -181,7 +177,7 @@
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Structure
|
||||
* @since 3.2.0
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getStructure(Container $container): Structure
|
||||
{
|
||||
@ -201,11 +197,63 @@
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Xml
|
||||
* @since 3.2.0
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getXml(Container $container): Xml
|
||||
{
|
||||
return new Xml(
|
||||
$container->get('Config')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Constant Paths
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Constantpaths
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getConstantpaths(Container $container): Constantpaths
|
||||
{
|
||||
return new Constantpaths();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Uri Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Uri
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function getUri(Container $container): Uri
|
||||
{
|
||||
return new Uri();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Http Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Http
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function getHttp(Container $container): Http
|
||||
{
|
||||
return new Http();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Response Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Response
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function getResponse(Container $container): Response
|
||||
{
|
||||
return new Response();
|
||||
}
|
@ -41,24 +41,36 @@
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection7": {
|
||||
"use": "e0c8c931-52a0-4171-9909-e8769505bb1f",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection8": {
|
||||
"use": "268b85ef-49f3-4c39-8187-bb12e38d19ee",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection9": {
|
||||
"use_selection8": {
|
||||
"use": "cdc9b06d-8333-4fa7-ab4d-b810dd90f95f",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection10": {
|
||||
"use_selection9": {
|
||||
"use": "1efdded5-d6c8-452c-8f37-0374483a7b3f",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection11": {
|
||||
"use_selection10": {
|
||||
"use": "f6ba34a2-0cd7-4dc1-ab67-75e962a5045b",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection11": {
|
||||
"use": "e0c8c931-52a0-4171-9909-e8769505bb1f",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection12": {
|
||||
"use": "1c5bf656-f73a-46ec-bb9d-aa3932d5b3de",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection13": {
|
||||
"use": "d9ee00d6-eeed-4fc4-af8a-7b5547f508ba",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection14": {
|
||||
"use": "c99e85a0-d120-4f25-bcbf-0940dd7b773b",
|
||||
"as": "default"
|
||||
}
|
||||
},
|
||||
"extendsinterfaces": null,
|
||||
|
@ -63,6 +63,7 @@ class Builders << (F,LightGreen) >> #RoyalBlue {
|
||||
+ __construct(Config $config, Power $power, ...)
|
||||
+ set(string $langLabel, string $langView, ...) : void
|
||||
- normalizeDatabaseValues(string $nameSingleCode, string $name, ...) : ?array
|
||||
- setLinkerRelations(array $link) : ?array
|
||||
}
|
||||
|
||||
note right of Builders::__construct
|
||||
@ -155,6 +156,16 @@ to types based on the 'length' field. It removes unnecessary fields from the res
|
||||
string $uniquekey
|
||||
string $iskey
|
||||
end note
|
||||
|
||||
note right of Builders::setLinkerRelations
|
||||
Sets the linker relations for a field based on the provided link data.
|
||||
The method determines the type of link relation based on the presence of a table.
|
||||
If no table is provided, it assigns a type 2 with a null table, otherwise it assigns type 1.
|
||||
It also extracts additional values from the input array, such as component, entity, value, and key.
|
||||
|
||||
since: 5.0.3
|
||||
return: ?array
|
||||
end note
|
||||
|
||||
@enduml
|
||||
```
|
||||
|
@ -1306,7 +1306,8 @@ final class Builders
|
||||
'list' => $nameListCode,
|
||||
'store' => (isset($field['store'])) ? $field['store'] : null,
|
||||
'tab_name' => $tabName,
|
||||
'db' => $this->normalizeDatabaseValues($nameSingleCode, $name, $databaseuniquekey, $databasekey)
|
||||
'db' => $this->normalizeDatabaseValues($nameSingleCode, $name, $databaseuniquekey, $databasekey),
|
||||
'link' => $this->setLinkerRelations($custom ?? [])
|
||||
]
|
||||
);
|
||||
}
|
||||
@ -1360,6 +1361,37 @@ final class Builders
|
||||
unset($db_values['ID'], $db_values['lenght'], $db_values['lenght_other'], $db_values['other']);
|
||||
|
||||
return $db_values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the linker relations for a field based on the provided link data.
|
||||
*
|
||||
* The method determines the type of link relation based on the presence of a table.
|
||||
* If no table is provided, it assigns a type 2 with a null table, otherwise it assigns type 1.
|
||||
* It also extracts additional values from the input array, such as component, entity, value, and key.
|
||||
*
|
||||
* @param array $link The link data which may contain 'table', 'component', 'view', 'text', and 'id'.
|
||||
*
|
||||
* @return array|null The structured linker relation array, or null if input is an empty array.
|
||||
* @since 5.0.3
|
||||
*/
|
||||
private function setLinkerRelations(array $link): ?array
|
||||
{
|
||||
if ($link === [])
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
$linker = [
|
||||
'type' => empty($link['table']) ? 2 : 1,
|
||||
'table' => $link['table'] ?? null,
|
||||
'component' => $link['component'] ?? null,
|
||||
'entity' => $link['view'] ?? null,
|
||||
'value' => $link['text'] ?? null,
|
||||
'key' => $link['id'] ?? null
|
||||
];
|
||||
|
||||
return $linker;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1229,7 +1229,8 @@
|
||||
'list' => $nameListCode,
|
||||
'store' => (isset($field['store'])) ? $field['store'] : null,
|
||||
'tab_name' => $tabName,
|
||||
'db' => $this->normalizeDatabaseValues($nameSingleCode, $name, $databaseuniquekey, $databasekey)
|
||||
'db' => $this->normalizeDatabaseValues($nameSingleCode, $name, $databaseuniquekey, $databasekey),
|
||||
'link' => $this->setLinkerRelations($custom ?? [])
|
||||
]
|
||||
);
|
||||
}
|
||||
@ -1283,4 +1284,35 @@
|
||||
unset($db_values['ID'], $db_values['lenght'], $db_values['lenght_other'], $db_values['other']);
|
||||
|
||||
return $db_values;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the linker relations for a field based on the provided link data.
|
||||
*
|
||||
* The method determines the type of link relation based on the presence of a table.
|
||||
* If no table is provided, it assigns a type 2 with a null table, otherwise it assigns type 1.
|
||||
* It also extracts additional values from the input array, such as component, entity, value, and key.
|
||||
*
|
||||
* @param array $link The link data which may contain 'table', 'component', 'view', 'text', and 'id'.
|
||||
*
|
||||
* @return array|null The structured linker relation array, or null if input is an empty array.
|
||||
* @since 5.0.3
|
||||
*/
|
||||
private function setLinkerRelations(array $link): ?array
|
||||
{
|
||||
if ($link === [])
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
$linker = [
|
||||
'type' => empty($link['table']) ? 2 : 1,
|
||||
'table' => $link['table'] ?? null,
|
||||
'component' => $link['component'] ?? null,
|
||||
'entity' => $link['view'] ?? null,
|
||||
'value' => $link['text'] ?? null,
|
||||
'key' => $link['id'] ?? null
|
||||
];
|
||||
|
||||
return $linker;
|
||||
}
|
@ -101,6 +101,7 @@ class JoomlaPower implements ServiceProviderInterface
|
||||
{
|
||||
return new Grep(
|
||||
$container->get('Gitea.Repository.Contents'),
|
||||
$container->get('Network.Resolve'),
|
||||
$container->get('Config')->approved_joomla_paths
|
||||
);
|
||||
}
|
||||
|
@ -71,6 +71,7 @@
|
||||
{
|
||||
return new Grep(
|
||||
$container->get('Gitea.Repository.Contents'),
|
||||
$container->get('Network.Resolve'),
|
||||
$container->get('Config')->approved_joomla_paths
|
||||
);
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ final class Grep extends ExtendingGrep implements GrepInterface
|
||||
$branch = $this->getBranchName($path);
|
||||
|
||||
// load the base and token if set
|
||||
$this->contents->load_($path->base ?? null, $path->token ?? null);
|
||||
$this->loadApi($this->contents, $path->base ?? null, $path->token ?? null);
|
||||
|
||||
// get the settings
|
||||
if (($power = $this->loadRemoteFile($path->organisation, $path->repository, $path->index->{$guid}->settings, $branch)) !== null &&
|
||||
|
@ -98,7 +98,7 @@
|
||||
$branch = $this->getBranchName($path);
|
||||
|
||||
// load the base and token if set
|
||||
$this->contents->load_($path->base ?? null, $path->token ?? null);
|
||||
$this->loadApi($this->contents, $path->base ?? null, $path->token ?? null);
|
||||
|
||||
// get the settings
|
||||
if (($power = $this->loadRemoteFile($path->organisation, $path->repository, $path->index->{$guid}->settings, $branch)) !== null &&
|
||||
|
@ -20,6 +20,9 @@ use VDM\Joomla\Service\Data;
|
||||
use VDM\Joomla\Componentbuilder\Service\Gitea;
|
||||
use VDM\Joomla\Componentbuilder\Power\Service\Gitea as GiteaPower;
|
||||
use VDM\Joomla\Gitea\Service\Utilities as GiteaUtilities;
|
||||
use VDM\Joomla\Componentbuilder\Service\Network;
|
||||
use VDM\Joomla\Componentbuilder\Service\Api;
|
||||
use VDM\Joomla\Componentbuilder\Service\Utilities;
|
||||
use VDM\Joomla\Interfaces\FactoryInterface;
|
||||
use VDM\Joomla\Abstraction\Factory as ExtendingFactory;
|
||||
|
||||
@ -54,7 +57,10 @@ abstract class Factory extends ExtendingFactory implements FactoryInterface
|
||||
->registerServiceProvider(new Data())
|
||||
->registerServiceProvider(new Gitea())
|
||||
->registerServiceProvider(new GiteaPower())
|
||||
->registerServiceProvider(new GiteaUtilities());
|
||||
->registerServiceProvider(new GiteaUtilities())
|
||||
->registerServiceProvider(new Network())
|
||||
->registerServiceProvider(new Api())
|
||||
->registerServiceProvider(new Utilities());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,5 +21,8 @@
|
||||
->registerServiceProvider(new Data())
|
||||
->registerServiceProvider(new Gitea())
|
||||
->registerServiceProvider(new GiteaPower())
|
||||
->registerServiceProvider(new GiteaUtilities());
|
||||
->registerServiceProvider(new GiteaUtilities())
|
||||
->registerServiceProvider(new Network())
|
||||
->registerServiceProvider(new Api())
|
||||
->registerServiceProvider(new Utilities());
|
||||
}
|
@ -39,6 +39,18 @@
|
||||
"use_selection6": {
|
||||
"use": "6edf0cf3-c2b0-45c9-84d2-c6ef1c5d434c",
|
||||
"as": "GiteaUtilities"
|
||||
},
|
||||
"use_selection7": {
|
||||
"use": "156f449b-ca6c-4a57-a925-be345e751614",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection8": {
|
||||
"use": "3c7567d7-b079-4910-b325-7ed5c30cabff",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection9": {
|
||||
"use": "facd1e1c-ff2f-4520-b735-075c45aa55ed",
|
||||
"as": "default"
|
||||
}
|
||||
},
|
||||
"extendsinterfaces": null,
|
||||
|
@ -75,13 +75,13 @@ class Paths extends Registry
|
||||
/**
|
||||
* getting any valid paths
|
||||
*
|
||||
* @param string $key The value's key/path name
|
||||
* @param string $key The value's key/path name
|
||||
*
|
||||
* @return string The path found as a string
|
||||
* @since 3.2.0
|
||||
* @throws \InvalidArgumentException If $key is not a valid function name.
|
||||
*/
|
||||
public function __get(string $key): string
|
||||
public function __get($key)
|
||||
{
|
||||
// check if it has been set
|
||||
if ($this->exists($key))
|
||||
|
@ -49,13 +49,13 @@
|
||||
/**
|
||||
* getting any valid paths
|
||||
*
|
||||
* @param string $key The value's key/path name
|
||||
* @param string $key The value's key/path name
|
||||
*
|
||||
* @return string The path found as a string
|
||||
* @since 3.2.0
|
||||
* @throws \InvalidArgumentException If $key is not a valid function name.
|
||||
*/
|
||||
public function __get(string $key): string
|
||||
public function __get($key)
|
||||
{
|
||||
// check if it has been set
|
||||
if ($this->exists($key))
|
||||
|
119
src/809d3077-c105-4e9c-8ac5-8fbee10cf9fc/README.md
Normal file
119
src/809d3077-c105-4e9c-8ac5-8fbee10cf9fc/README.md
Normal file
@ -0,0 +1,119 @@
|
||||
```
|
||||
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||
```
|
||||
# final class Status (Details)
|
||||
> namespace: **VDM\Joomla\Componentbuilder\Network**
|
||||
|
||||
```uml
|
||||
@startuml
|
||||
class Status << (F,LightGreen) >> #RoyalBlue {
|
||||
# Network $network
|
||||
# Core $core
|
||||
# Url $url
|
||||
+ __construct(Network $network, Core $core, ...)
|
||||
+ get(string $target, string $domain, ...) : int
|
||||
+ active(string $target, ?array $excludeDomains = ['git.vdm.dev']) : ?object
|
||||
+ network(string $target, ?string $domain = null, ...) : ?object
|
||||
- getDomainData(array $network, string $domain, ...) : ?object
|
||||
- fetchNetworkData(string $target) : object
|
||||
}
|
||||
|
||||
note right of Status::__construct
|
||||
Constructor.
|
||||
|
||||
since: 5.0.4
|
||||
|
||||
arguments:
|
||||
Network $network
|
||||
Core $core
|
||||
Url $url
|
||||
end note
|
||||
|
||||
note right of Status::get
|
||||
Retrieves the status for the given network target, utilizing caching via the Core registry.
|
||||
|
||||
since: 5.0.4
|
||||
return: int
|
||||
|
||||
arguments:
|
||||
string $target
|
||||
string $domain
|
||||
string $repository
|
||||
string $organization = 'joomla'
|
||||
end note
|
||||
|
||||
note right of Status::active
|
||||
Retrieves a random active repository target, excluding the specified domain.
|
||||
|
||||
since: 5.0.4
|
||||
return: ?object
|
||||
end note
|
||||
|
||||
note right of Status::network
|
||||
Retrieves the data for the given network target, utilizing caching via the Core registry.
|
||||
If the data for the target is already cached in the Core registry, it returns that data.
|
||||
Otherwise, it fetches the data from the Network, caches it, and returns it.
|
||||
|
||||
since: 5.0.4
|
||||
return: ?object
|
||||
|
||||
arguments:
|
||||
string $target
|
||||
?string $domain = null
|
||||
?string $organization = null
|
||||
?string $repository
|
||||
end note
|
||||
|
||||
note right of Status::getDomainData
|
||||
Retrieves the data filtered by domain, organization, and optionally repository.
|
||||
|
||||
since: 5.0.4
|
||||
return: ?object
|
||||
|
||||
arguments:
|
||||
array $network
|
||||
string $domain
|
||||
?string $organization = null
|
||||
?string $repository = null
|
||||
end note
|
||||
|
||||
note right of Status::fetchNetworkData
|
||||
Fetches and caches the network data for a given target.
|
||||
|
||||
since: 5.0.4
|
||||
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---809d3077_c105_4e9c_8ac5_8fbee10cf9fc---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)
|
||||
|
258
src/809d3077-c105-4e9c-8ac5-8fbee10cf9fc/code.php
Normal file
258
src/809d3077-c105-4e9c-8ac5-8fbee10cf9fc/code.php
Normal file
@ -0,0 +1,258 @@
|
||||
<?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\Network;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Api\Network;
|
||||
use VDM\Joomla\Componentbuilder\Network\Core;
|
||||
use VDM\Joomla\Componentbuilder\Network\Url;
|
||||
|
||||
|
||||
/**
|
||||
* The Network Status
|
||||
*
|
||||
* @since 5.0.4
|
||||
*/
|
||||
final class Status
|
||||
{
|
||||
/**
|
||||
* The Network Class.
|
||||
*
|
||||
* @var Network
|
||||
* @since 5.0.4
|
||||
*/
|
||||
protected Network $network;
|
||||
|
||||
/**
|
||||
* The Core Class.
|
||||
*
|
||||
* @var Core
|
||||
* @since 5.0.4
|
||||
*/
|
||||
protected Core $core;
|
||||
|
||||
/**
|
||||
* The Url Class.
|
||||
*
|
||||
* @var Url
|
||||
* @since 5.0.4
|
||||
*/
|
||||
protected Url $url;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Network $network The Network Class.
|
||||
* @param Core $core The Core Class.
|
||||
* @param Url $url The Url Class.
|
||||
*
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function __construct(Network $network, Core $core, Url $url)
|
||||
{
|
||||
$this->network = $network;
|
||||
$this->core = $core;
|
||||
$this->url = $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the status for the given network target, utilizing caching via the Core registry.
|
||||
*
|
||||
* @param string $target The target network.
|
||||
* @param string $domain The domain to retrieve [example: codeberg.org].
|
||||
* @param string $repository The repository name.
|
||||
* @param string $organization The target repository organization. (default: joomla)
|
||||
*
|
||||
* @return int Will return 1 if active, 0 if not, and -1 if not part of the core.
|
||||
*
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function get(string $target, string $domain, string $repository, string $organization = 'joomla'): int
|
||||
{
|
||||
try {
|
||||
$repo = $this->network($target, $repository, $organization, $domain);
|
||||
|
||||
if ($repo === null)
|
||||
{
|
||||
// Domain not found in the network data
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Check if the repository is active
|
||||
if (isset($repo->status) && is_numeric($repo->status))
|
||||
{
|
||||
return (int) $repo->status;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 'status' property not found or not numeric
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
// In case of any exception, return -1
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a random active repository target, excluding the specified domain.
|
||||
*
|
||||
* @param string $target The target network name.
|
||||
* @param array|null $excludeDomains The domain to exclude [default: ['git.vdm.dev']].
|
||||
*
|
||||
* @return object|null The randomly selected active repository, or null if none found.
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function active(string $target, ?array $excludeDomains = ['git.vdm.dev']): ?object
|
||||
{
|
||||
try {
|
||||
// Get the network data for the target
|
||||
$data = $this->network($target);
|
||||
|
||||
// Filter active repositories excluding the specified domain
|
||||
$activeRepos = array_filter($data->network, function ($repo) use ($excludeDomains) {
|
||||
$parsed = $this->url->parse($repo->url);
|
||||
return isset($repo->status) &&
|
||||
$repo->status == 1 &&
|
||||
!in_array($parsed->domain, $excludeDomains);
|
||||
});
|
||||
|
||||
// Reindex the array to ensure array_rand works correctly
|
||||
$activeRepos = array_values($activeRepos);
|
||||
|
||||
// If there are active repositories, select one at random
|
||||
if (!empty($activeRepos))
|
||||
{
|
||||
return $activeRepos[array_rand($activeRepos)];
|
||||
}
|
||||
else
|
||||
{
|
||||
// No active repositories found excluding the specified domain
|
||||
return null;
|
||||
}
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
// In case of any exception, return null
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the data for the given network target, utilizing caching via the Core registry.
|
||||
*
|
||||
* If the data for the target is already cached in the Core registry, it returns that data.
|
||||
* Otherwise, it fetches the data from the Network, caches it, and returns it.
|
||||
*
|
||||
* @param string $target The target network name.
|
||||
* @param string|null $domain The domain to retrieve [example: codeberg.org].
|
||||
* @param string|null $organization The target repository organization.
|
||||
* @param string|null $repository The repository name.
|
||||
*
|
||||
* @return object|null The data retrieved for the target.
|
||||
* @throws \Exception If an error occurs during the network call or if the result contains an 'error' key.
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function network(string $target, ?string $domain = null, ?string $organization = null, ?string $repository): ?object
|
||||
{
|
||||
$networkData = $this->fetchNetworkData($target);
|
||||
|
||||
if ($domain !== null)
|
||||
{
|
||||
return $this->getDomainData($networkData->network, $domain, $organization, $repository);
|
||||
}
|
||||
|
||||
return $networkData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the data filtered by domain, organization, and optionally repository.
|
||||
*
|
||||
* @param array $network The network data array.
|
||||
* @param string $domain The domain to filter by.
|
||||
* @param string|null $organization The organization to filter by.
|
||||
* @param string|null $repository The repository to filter by.
|
||||
*
|
||||
* @return object|null The filtered data, or null if no match is found.
|
||||
* @since 5.0.4
|
||||
*/
|
||||
private function getDomainData(array $network, string $domain, ?string $organization = null, ?string $repository = null): ?object
|
||||
{
|
||||
$domainBase = $this->url->base($domain);
|
||||
|
||||
foreach ($network as $repo)
|
||||
{
|
||||
$parsedUrl = $this->url->parse($repo->url);
|
||||
|
||||
if ($parsedUrl->domain === $domainBase)
|
||||
{
|
||||
if ($organization !== null && $parsedUrl->organization !== $organization)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($repository !== null && $parsedUrl->repository !== $repository)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
return $repo;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches and caches the network data for a given target.
|
||||
*
|
||||
* @param string $target The target network name.
|
||||
*
|
||||
* @return object The cached or freshly fetched network data.
|
||||
* @throws \Exception If an error occurs during the network call.
|
||||
* @since 5.0.4
|
||||
*/
|
||||
private function fetchNetworkData(string $target): object
|
||||
{
|
||||
// Check if data is cached
|
||||
if (($cachedData = $this->core->get($target)) !== null)
|
||||
{
|
||||
return $cachedData;
|
||||
}
|
||||
|
||||
try {
|
||||
// Fetch data from the network
|
||||
$networkData = $this->network->get($target);
|
||||
} catch (\Exception $e) {
|
||||
throw new \Exception('Network error: ' . $e->getMessage(), 0, $e);
|
||||
}
|
||||
|
||||
// Validate the fetched data
|
||||
if (!is_object($networkData) || !property_exists($networkData, 'network'))
|
||||
{
|
||||
throw new \Exception('Invalid network data: Missing "network" property.');
|
||||
}
|
||||
|
||||
if (property_exists($networkData, 'error'))
|
||||
{
|
||||
throw new \Exception('Network error: ' . $networkData->error);
|
||||
}
|
||||
|
||||
// Cache the result
|
||||
$this->core->set($target, $networkData);
|
||||
|
||||
return $networkData;
|
||||
}
|
||||
}
|
||||
|
230
src/809d3077-c105-4e9c-8ac5-8fbee10cf9fc/code.power
Normal file
230
src/809d3077-c105-4e9c-8ac5-8fbee10cf9fc/code.power
Normal file
@ -0,0 +1,230 @@
|
||||
/**
|
||||
* The Network Class.
|
||||
*
|
||||
* @var Network
|
||||
* @since 5.0.4
|
||||
*/
|
||||
protected Network $network;
|
||||
|
||||
/**
|
||||
* The Core Class.
|
||||
*
|
||||
* @var Core
|
||||
* @since 5.0.4
|
||||
*/
|
||||
protected Core $core;
|
||||
|
||||
/**
|
||||
* The Url Class.
|
||||
*
|
||||
* @var Url
|
||||
* @since 5.0.4
|
||||
*/
|
||||
protected Url $url;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Network $network The Network Class.
|
||||
* @param Core $core The Core Class.
|
||||
* @param Url $url The Url Class.
|
||||
*
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function __construct(Network $network, Core $core, Url $url)
|
||||
{
|
||||
$this->network = $network;
|
||||
$this->core = $core;
|
||||
$this->url = $url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the status for the given network target, utilizing caching via the Core registry.
|
||||
*
|
||||
* @param string $target The target network.
|
||||
* @param string $domain The domain to retrieve [example: codeberg.org].
|
||||
* @param string $repository The repository name.
|
||||
* @param string $organization The target repository organization. (default: joomla)
|
||||
*
|
||||
* @return int Will return 1 if active, 0 if not, and -1 if not part of the core.
|
||||
*
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function get(string $target, string $domain, string $repository, string $organization = 'joomla'): int
|
||||
{
|
||||
try {
|
||||
$repo = $this->network($target, $repository, $organization, $domain);
|
||||
|
||||
if ($repo === null)
|
||||
{
|
||||
// Domain not found in the network data
|
||||
return -1;
|
||||
}
|
||||
|
||||
// Check if the repository is active
|
||||
if (isset($repo->status) && is_numeric($repo->status))
|
||||
{
|
||||
return (int) $repo->status;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 'status' property not found or not numeric
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
// In case of any exception, return -1
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a random active repository target, excluding the specified domain.
|
||||
*
|
||||
* @param string $target The target network name.
|
||||
* @param array|null $excludeDomains The domain to exclude [default: ['git.vdm.dev']].
|
||||
*
|
||||
* @return object|null The randomly selected active repository, or null if none found.
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function active(string $target, ?array $excludeDomains = ['git.vdm.dev']): ?object
|
||||
{
|
||||
try {
|
||||
// Get the network data for the target
|
||||
$data = $this->network($target);
|
||||
|
||||
// Filter active repositories excluding the specified domain
|
||||
$activeRepos = array_filter($data->network, function ($repo) use ($excludeDomains) {
|
||||
$parsed = $this->url->parse($repo->url);
|
||||
return isset($repo->status) &&
|
||||
$repo->status == 1 &&
|
||||
!in_array($parsed->domain, $excludeDomains);
|
||||
});
|
||||
|
||||
// Reindex the array to ensure array_rand works correctly
|
||||
$activeRepos = array_values($activeRepos);
|
||||
|
||||
// If there are active repositories, select one at random
|
||||
if (!empty($activeRepos))
|
||||
{
|
||||
return $activeRepos[array_rand($activeRepos)];
|
||||
}
|
||||
else
|
||||
{
|
||||
// No active repositories found excluding the specified domain
|
||||
return null;
|
||||
}
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
// In case of any exception, return null
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the data for the given network target, utilizing caching via the Core registry.
|
||||
*
|
||||
* If the data for the target is already cached in the Core registry, it returns that data.
|
||||
* Otherwise, it fetches the data from the Network, caches it, and returns it.
|
||||
*
|
||||
* @param string $target The target network name.
|
||||
* @param string|null $domain The domain to retrieve [example: codeberg.org].
|
||||
* @param string|null $organization The target repository organization.
|
||||
* @param string|null $repository The repository name.
|
||||
*
|
||||
* @return object|null The data retrieved for the target.
|
||||
* @throws \Exception If an error occurs during the network call or if the result contains an 'error' key.
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function network(string $target, ?string $domain = null, ?string $organization = null, ?string $repository): ?object
|
||||
{
|
||||
$networkData = $this->fetchNetworkData($target);
|
||||
|
||||
if ($domain !== null)
|
||||
{
|
||||
return $this->getDomainData($networkData->network, $domain, $organization, $repository);
|
||||
}
|
||||
|
||||
return $networkData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the data filtered by domain, organization, and optionally repository.
|
||||
*
|
||||
* @param array $network The network data array.
|
||||
* @param string $domain The domain to filter by.
|
||||
* @param string|null $organization The organization to filter by.
|
||||
* @param string|null $repository The repository to filter by.
|
||||
*
|
||||
* @return object|null The filtered data, or null if no match is found.
|
||||
* @since 5.0.4
|
||||
*/
|
||||
private function getDomainData(array $network, string $domain, ?string $organization = null, ?string $repository = null): ?object
|
||||
{
|
||||
$domainBase = $this->url->base($domain);
|
||||
|
||||
foreach ($network as $repo)
|
||||
{
|
||||
$parsedUrl = $this->url->parse($repo->url);
|
||||
|
||||
if ($parsedUrl->domain === $domainBase)
|
||||
{
|
||||
if ($organization !== null && $parsedUrl->organization !== $organization)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($repository !== null && $parsedUrl->repository !== $repository)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
return $repo;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches and caches the network data for a given target.
|
||||
*
|
||||
* @param string $target The target network name.
|
||||
*
|
||||
* @return object The cached or freshly fetched network data.
|
||||
* @throws \Exception If an error occurs during the network call.
|
||||
* @since 5.0.4
|
||||
*/
|
||||
private function fetchNetworkData(string $target): object
|
||||
{
|
||||
// Check if data is cached
|
||||
if (($cachedData = $this->core->get($target)) !== null)
|
||||
{
|
||||
return $cachedData;
|
||||
}
|
||||
|
||||
try {
|
||||
// Fetch data from the network
|
||||
$networkData = $this->network->get($target);
|
||||
} catch (\Exception $e) {
|
||||
throw new \Exception('Network error: ' . $e->getMessage(), 0, $e);
|
||||
}
|
||||
|
||||
// Validate the fetched data
|
||||
if (!is_object($networkData) || !property_exists($networkData, 'network'))
|
||||
{
|
||||
throw new \Exception('Invalid network data: Missing "network" property.');
|
||||
}
|
||||
|
||||
if (property_exists($networkData, 'error'))
|
||||
{
|
||||
throw new \Exception('Network error: ' . $networkData->error);
|
||||
}
|
||||
|
||||
// Cache the result
|
||||
$this->core->set($target, $networkData);
|
||||
|
||||
return $networkData;
|
||||
}
|
32
src/809d3077-c105-4e9c-8ac5-8fbee10cf9fc/settings.json
Normal file
32
src/809d3077-c105-4e9c-8ac5-8fbee10cf9fc/settings.json
Normal file
@ -0,0 +1,32 @@
|
||||
{
|
||||
"add_head": "0",
|
||||
"add_licensing_template": "2",
|
||||
"extends": "",
|
||||
"guid": "809d3077-c105-4e9c-8ac5-8fbee10cf9fc",
|
||||
"implements": null,
|
||||
"load_selection": null,
|
||||
"name": "Status",
|
||||
"power_version": "1.0.0",
|
||||
"system_name": "Joomla.JCB.Network.Status",
|
||||
"type": "final class",
|
||||
"use_selection": {
|
||||
"use_selection0": {
|
||||
"use": "07ca003e-368c-451d-a3d3-ba24e50c7287",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection1": {
|
||||
"use": "825ecce9-72ef-4257-bc32-4b05a4c226e9",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection2": {
|
||||
"use": "286f7550-9c22-401c-9e5a-2f9426888133",
|
||||
"as": "default"
|
||||
}
|
||||
},
|
||||
"extendsinterfaces": null,
|
||||
"namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Network.Status",
|
||||
"description": "The Network Status\r\n\r\n@since 5.0.4",
|
||||
"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": ""
|
||||
}
|
46
src/825ecce9-72ef-4257-bc32-4b05a4c226e9/README.md
Normal file
46
src/825ecce9-72ef-4257-bc32-4b05a4c226e9/README.md
Normal file
@ -0,0 +1,46 @@
|
||||
```
|
||||
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||
```
|
||||
# final class Core (Details)
|
||||
> namespace: **VDM\Joomla\Componentbuilder\Network**
|
||||
> extends: **Registry**
|
||||
|
||||
```uml
|
||||
@startuml
|
||||
class Core << (F,LightGreen) >> #RoyalBlue {
|
||||
# ?string $separator
|
||||
}
|
||||
|
||||
@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---825ecce9_72ef_4257_bc32_4b05a4c226e9---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)
|
||||
|
33
src/825ecce9-72ef-4257-bc32-4b05a4c226e9/code.php
Normal file
33
src/825ecce9-72ef-4257-bc32-4b05a4c226e9/code.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?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\Network;
|
||||
|
||||
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
|
||||
/**
|
||||
* The Network Core
|
||||
*
|
||||
* @since 5.0.4
|
||||
*/
|
||||
final class Core extends Registry
|
||||
{
|
||||
/**
|
||||
* Path separator
|
||||
*
|
||||
* @var string|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected ?string $separator = '|';
|
||||
}
|
||||
|
7
src/825ecce9-72ef-4257-bc32-4b05a4c226e9/code.power
Normal file
7
src/825ecce9-72ef-4257-bc32-4b05a4c226e9/code.power
Normal file
@ -0,0 +1,7 @@
|
||||
/**
|
||||
* Path separator
|
||||
*
|
||||
* @var string|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected ?string $separator = '|';
|
19
src/825ecce9-72ef-4257-bc32-4b05a4c226e9/settings.json
Normal file
19
src/825ecce9-72ef-4257-bc32-4b05a4c226e9/settings.json
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"add_head": "0",
|
||||
"add_licensing_template": "2",
|
||||
"extends": "7e822c03-1b20-41d1-9427-f5b8d5836af7",
|
||||
"guid": "825ecce9-72ef-4257-bc32-4b05a4c226e9",
|
||||
"implements": null,
|
||||
"load_selection": null,
|
||||
"name": "Core",
|
||||
"power_version": "1.0.0",
|
||||
"system_name": "Joomla.JCB.Network.Core",
|
||||
"type": "final class",
|
||||
"use_selection": null,
|
||||
"extendsinterfaces": null,
|
||||
"namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Network.Core",
|
||||
"description": "The Network Core\r\n\r\n@since 5.0.4",
|
||||
"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": ""
|
||||
}
|
@ -6,22 +6,27 @@
|
||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||
```
|
||||
# abstract class BaseConfig (Details)
|
||||
# abstract class Api (Details)
|
||||
> namespace: **VDM\Joomla\Componentbuilder\Abstraction**
|
||||
> extends: **ExtendingBaseConfig**
|
||||
|
||||
```uml
|
||||
@startuml
|
||||
abstract BaseConfig #Orange {
|
||||
# Input $input
|
||||
# JoomlaRegistry $params
|
||||
+ __construct(?Input $input = null, ?JoomlaRegistry $params = null)
|
||||
abstract Api #Orange {
|
||||
# Http $http
|
||||
# Uri $uri
|
||||
# Response $response
|
||||
+ __construct(Http $http, Uri $uri, ...)
|
||||
}
|
||||
|
||||
note right of BaseConfig::__construct
|
||||
Constructor
|
||||
note right of Api::__construct
|
||||
Constructor.
|
||||
|
||||
since: 3.2.0
|
||||
since: 5.0.4
|
||||
|
||||
arguments:
|
||||
Http $http
|
||||
Uri $uri
|
||||
Response $response
|
||||
end note
|
||||
|
||||
@enduml
|
||||
@ -37,7 +42,7 @@ To add this specific Power to your project in JCB:
|
||||
|
||||
> simply use this SPK
|
||||
```
|
||||
Super---9769f3b2_17bf_4f20_b54b_3a4ebe572b36---Power
|
||||
Super---85e0b652_21b9_4ff7_ba27_dbd72256f0f2---Power
|
||||
```
|
||||
> remember to replace the `---` with `___` to activate this Power in your code
|
||||
|
67
src/85e0b652-21b9-4ff7-ba27-dbd72256f0f2/code.php
Normal file
67
src/85e0b652-21b9-4ff7-ba27-dbd72256f0f2/code.php
Normal file
@ -0,0 +1,67 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Abstraction;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Utilities\Http;
|
||||
use VDM\Joomla\Componentbuilder\Utilities\Uri;
|
||||
use VDM\Joomla\Componentbuilder\Utilities\Response;
|
||||
|
||||
|
||||
/**
|
||||
* The Joomla Component Builder Api
|
||||
*
|
||||
* @since 5.0.4
|
||||
*/
|
||||
abstract class Api
|
||||
{
|
||||
/**
|
||||
* The Http Class.
|
||||
*
|
||||
* @var Http
|
||||
* @since 5.0.4
|
||||
*/
|
||||
protected Http $http;
|
||||
|
||||
/**
|
||||
* The Uri Class.
|
||||
*
|
||||
* @var Uri
|
||||
* @since 5.0.4
|
||||
*/
|
||||
protected Uri $uri;
|
||||
|
||||
/**
|
||||
* The Response Class.
|
||||
*
|
||||
* @var Response
|
||||
* @since 5.0.4
|
||||
*/
|
||||
protected Response $response;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Http $http The Http Class.
|
||||
* @param Uri $uri The Uri Class.
|
||||
* @param Response $response The Response Class.
|
||||
*
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function __construct(Http $http, Uri $uri, Response $response)
|
||||
{
|
||||
$this->http = $http;
|
||||
$this->uri = $uri;
|
||||
$this->response = $response;
|
||||
}
|
||||
}
|
||||
|
39
src/85e0b652-21b9-4ff7-ba27-dbd72256f0f2/code.power
Normal file
39
src/85e0b652-21b9-4ff7-ba27-dbd72256f0f2/code.power
Normal file
@ -0,0 +1,39 @@
|
||||
/**
|
||||
* The Http Class.
|
||||
*
|
||||
* @var Http
|
||||
* @since 5.0.4
|
||||
*/
|
||||
protected Http $http;
|
||||
|
||||
/**
|
||||
* The Uri Class.
|
||||
*
|
||||
* @var Uri
|
||||
* @since 5.0.4
|
||||
*/
|
||||
protected Uri $uri;
|
||||
|
||||
/**
|
||||
* The Response Class.
|
||||
*
|
||||
* @var Response
|
||||
* @since 5.0.4
|
||||
*/
|
||||
protected Response $response;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Http $http The Http Class.
|
||||
* @param Uri $uri The Uri Class.
|
||||
* @param Response $response The Response Class.
|
||||
*
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function __construct(Http $http, Uri $uri, Response $response)
|
||||
{
|
||||
$this->http = $http;
|
||||
$this->uri = $uri;
|
||||
$this->response = $response;
|
||||
}
|
@ -1,28 +1,32 @@
|
||||
{
|
||||
"add_head": "1",
|
||||
"add_head": "0",
|
||||
"add_licensing_template": "2",
|
||||
"extends": "ffbd4e1f-a342-4080-ab7d-1de3741bf319",
|
||||
"guid": "9769f3b2-17bf-4f20-b54b-3a4ebe572b36",
|
||||
"extends": "",
|
||||
"guid": "85e0b652-21b9-4ff7-ba27-dbd72256f0f2",
|
||||
"implements": null,
|
||||
"load_selection": null,
|
||||
"name": "BaseConfig",
|
||||
"name": "Api",
|
||||
"power_version": "1.0.0",
|
||||
"system_name": "JCB.Abstraction.BaseConfig",
|
||||
"system_name": "Joomla.JCB.Abstraction.Api",
|
||||
"type": "abstract class",
|
||||
"use_selection": {
|
||||
"use_selection0": {
|
||||
"use": "d9ee00d6-eeed-4fc4-af8a-7b5547f508ba",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection1": {
|
||||
"use": "640b5352-fb09-425f-a26e-cd44eda03f15",
|
||||
"use": "1c5bf656-f73a-46ec-bb9d-aa3932d5b3de",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection2": {
|
||||
"use": "30c5b4c2-f75f-4d15-869a-f8bfedd87358",
|
||||
"use": "c99e85a0-d120-4f25-bcbf-0940dd7b773b",
|
||||
"as": "default"
|
||||
}
|
||||
},
|
||||
"extendsinterfaces": null,
|
||||
"namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Abstraction.BaseConfig",
|
||||
"description": "Config\r\n\r\n@since 3.2.0",
|
||||
"namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Abstraction.Api",
|
||||
"description": "The Joomla Component Builder Api\r\n\r\n@since 5.0.4",
|
||||
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/joomla\/Component-Builder>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
|
||||
"head": "use Joomla\\Registry\\Registry as JoomlaRegistry;\r\nuse Joomla\\CMS\\Factory;\r\nuse Joomla\\Input\\Input;",
|
||||
"head": "",
|
||||
"composer": ""
|
||||
}
|
@ -12,7 +12,7 @@
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Builder;
|
||||
|
||||
|
||||
use VDM\Joomla\Abstraction\Registry\Traits\ToString;
|
||||
use VDM\Joomla\Abstraction\Registry\Traits\PathToString;
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
@ -25,10 +25,10 @@ use VDM\Joomla\Abstraction\Registry;
|
||||
final class IntegerFields extends Registry implements Registryinterface
|
||||
{
|
||||
/**
|
||||
* To String Values
|
||||
* Path To String Values
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
use ToString;
|
||||
use PathToString;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/**
|
||||
* To String Values
|
||||
* Path To String Values
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
use ToString;
|
||||
use PathToString;
|
@ -1,64 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Abstraction;
|
||||
|
||||
|
||||
use Joomla\Registry\Registry as JoomlaRegistry;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\Input\Input;
|
||||
use VDM\Joomla\Utilities\Component\Helper;
|
||||
use VDM\Joomla\Utilities\String\ClassfunctionHelper;
|
||||
use VDM\Joomla\Abstraction\BaseConfig as ExtendingBaseConfig;
|
||||
|
||||
|
||||
/**
|
||||
* Config
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
abstract class BaseConfig extends ExtendingBaseConfig
|
||||
{
|
||||
/**
|
||||
* Hold a JInput object for easier access to the input variables.
|
||||
*
|
||||
* @var Input
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Input $input;
|
||||
|
||||
/**
|
||||
* The Params
|
||||
*
|
||||
* @var JoomlaRegistry
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected JoomlaRegistry $params;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Input|null $input Input
|
||||
* @param Registry|null $params The component parameters
|
||||
*
|
||||
* @throws \Exception
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(?Input $input = null, ?JoomlaRegistry $params = null)
|
||||
{
|
||||
$this->input = $input ?: Factory::getApplication()->input;
|
||||
$this->params = $params ?: Helper::getParams('com_componentbuilder');
|
||||
|
||||
// run parent constructor
|
||||
parent::__construct();
|
||||
}
|
||||
}
|
||||
|
@ -1,33 +0,0 @@
|
||||
/**
|
||||
* Hold a JInput object for easier access to the input variables.
|
||||
*
|
||||
* @var Input
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Input $input;
|
||||
|
||||
/**
|
||||
* The Params
|
||||
*
|
||||
* @var JoomlaRegistry
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected JoomlaRegistry $params;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Input|null $input Input
|
||||
* @param Registry|null $params The component parameters
|
||||
*
|
||||
* @throws \Exception
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(?Input $input = null, ?JoomlaRegistry $params = null)
|
||||
{
|
||||
$this->input = $input ?: Factory::getApplication()->input;
|
||||
$this->params = $params ?: Helper::getParams('com_componentbuilder');
|
||||
|
||||
// run parent constructor
|
||||
parent::__construct();
|
||||
}
|
108
src/a0c143af-3d7d-4c19-91c4-f72060b4c361/README.md
Normal file
108
src/a0c143af-3d7d-4c19-91c4-f72060b4c361/README.md
Normal file
@ -0,0 +1,108 @@
|
||||
```
|
||||
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||
```
|
||||
# final class Resolve (Details)
|
||||
> namespace: **VDM\Joomla\Componentbuilder\Network**
|
||||
|
||||
```uml
|
||||
@startuml
|
||||
class Resolve << (F,LightGreen) >> #RoyalBlue {
|
||||
# Url $url
|
||||
# Status $status
|
||||
+ __construct(Url $url, Status $status)
|
||||
+ api(string $target, $domain, ...) : void
|
||||
- resolve(string $target, $domain, ...) : void
|
||||
- active(string $target) : ?object
|
||||
- logInfo(string $message) : void
|
||||
- logError(\Exception $exception, string $message) : void
|
||||
}
|
||||
|
||||
note right of Resolve::__construct
|
||||
Constructor.
|
||||
|
||||
since: 5.0.4
|
||||
end note
|
||||
|
||||
note right of Resolve::api
|
||||
Resolves the API for a repository if it is part of the core network.
|
||||
This method attempts to verify the status of the API and resolve an active URL if the current one is inactive.
|
||||
|
||||
since: 5.0.4
|
||||
return: void
|
||||
|
||||
arguments:
|
||||
string $target
|
||||
$domain
|
||||
$organisation
|
||||
$repository
|
||||
end note
|
||||
|
||||
note right of Resolve::resolve
|
||||
Resolves an active API URL if the current API is inactive.
|
||||
Updates the `$domain`, `$organisation`, and `$repository` parameters to point to an active API URL.
|
||||
|
||||
since: 5.0.4
|
||||
return: void
|
||||
|
||||
arguments:
|
||||
string $target
|
||||
$domain
|
||||
$organisation
|
||||
$repository
|
||||
end note
|
||||
|
||||
note right of Resolve::active
|
||||
Retrieves a random active repository target, excluding the specified domain.
|
||||
|
||||
since: 5.0.4
|
||||
return: ?object
|
||||
end note
|
||||
|
||||
note right of Resolve::logInfo
|
||||
Logs an info custom message.
|
||||
|
||||
since: 5.0.4
|
||||
return: void
|
||||
end note
|
||||
|
||||
note right of Resolve::logError
|
||||
Logs an error with a custom message.
|
||||
This method is a placeholder for your actual logging mechanism.
|
||||
|
||||
since: 5.0.4
|
||||
return: void
|
||||
end note
|
||||
|
||||
@enduml
|
||||
```
|
||||
|
||||
The Power feature in JCB allows you to write PHP classes and their implementations, making it easy to include them in your Joomla project. JCB handles linking, autoloading, namespacing, and folder structure creation for you.
|
||||
|
||||
By using the SPK (Super Power Key) in your custom code (replacing the class name in your code with the SPK), JCB will automatically pull the power from the repository into your project. This makes it available in your JCB instance, allowing you to edit it and include the class in your generated Joomla component.
|
||||
|
||||
JCB uses placeholders like [[[`NamespacePrefix`]]] and [[[`ComponentNamespace`]]] in namespacing to prevent collisions and improve reusability across different JCB systems. You can also set the **JCB powers path** globally or per component under the **Dynamic Integration** tab, providing flexibility and easy maintainability.
|
||||
|
||||
To add this specific Power to your project in JCB:
|
||||
|
||||
> simply use this SPK
|
||||
```
|
||||
Super---a0c143af_3d7d_4c19_91c4_f72060b4c361---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)
|
||||
|
178
src/a0c143af-3d7d-4c19-91c4-f72060b4c361/code.php
Normal file
178
src/a0c143af-3d7d-4c19-91c4-f72060b4c361/code.php
Normal file
@ -0,0 +1,178 @@
|
||||
<?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\Network;
|
||||
|
||||
|
||||
use Joomla\CMS\Log\Log;
|
||||
use VDM\Joomla\Componentbuilder\Network\Url;
|
||||
use VDM\Joomla\Componentbuilder\Network\Status;
|
||||
|
||||
|
||||
/**
|
||||
* The Network Resolver
|
||||
*
|
||||
* @since 5.0.4
|
||||
*/
|
||||
final class Resolve
|
||||
{
|
||||
/**
|
||||
* The Url Class.
|
||||
*
|
||||
* @var Url
|
||||
* @since 5.0.4
|
||||
*/
|
||||
protected Url $url;
|
||||
|
||||
/**
|
||||
* The Status Class.
|
||||
*
|
||||
* @var Status
|
||||
* @since 5.0.4
|
||||
*/
|
||||
protected Status $status;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Url $url The Url Class.
|
||||
* @param Status $status The Status Class.
|
||||
*
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function __construct(Url $url, Status $status)
|
||||
{
|
||||
$this->url = $url;
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves the API for a repository if it is part of the core network.
|
||||
*
|
||||
* This method attempts to verify the status of the API and resolve an active URL if the current one is inactive.
|
||||
*
|
||||
* @param string $target The target network.
|
||||
* @param string &$domain The API base domain (passed by reference).
|
||||
* @param string &$organisation The repository organisation (passed by reference).
|
||||
* @param string &$repository The repository name (passed by reference).
|
||||
*
|
||||
* @return void
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function api(string $target, string &$domain, string &$organisation, string &$repository): void
|
||||
{
|
||||
try {
|
||||
// Check the status of the current API
|
||||
$status = $this->status->get($target, $domain, $repository, $organisation);
|
||||
|
||||
// If the API is inactive, attempt to find another active URL
|
||||
if ($status === 0)
|
||||
{
|
||||
$this->resolve($target, $domain, $organisation, $repository);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
// ignore any none [in]active urls
|
||||
$this->logError($e, 'Failed to resolve API status.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves an active API URL if the current API is inactive.
|
||||
*
|
||||
* Updates the `$domain`, `$organisation`, and `$repository` parameters to point to an active API URL.
|
||||
*
|
||||
* @param string $target The target network.
|
||||
* @param string &$domain The API base domain (passed by reference).
|
||||
* @param string &$organisation The repository organisation (passed by reference).
|
||||
* @param string &$repository The repository name (passed by reference).
|
||||
*
|
||||
* @return void
|
||||
* @since 5.0.4
|
||||
*/
|
||||
private function resolve(string $target, string &$domain, string &$organisation, string &$repository): void
|
||||
{
|
||||
$activeRepo = $this->active($target);
|
||||
|
||||
if ($activeRepo === null) {
|
||||
// No active API found, log or handle this case as needed
|
||||
throw new \Exception('No active API found for the target: ' . $target);
|
||||
}
|
||||
|
||||
try {
|
||||
// Parse the active repository's URL and update the references
|
||||
$parsedUrl = $this->url->parse($activeRepo->url);
|
||||
|
||||
$noneActiveDomain = "{$domain}/{$organisation}/{$repository}";
|
||||
$activeDomain = "{$parsedUrl->scheme}://{$parsedUrl->domain}/{$parsedUrl->organisation}/{$parsedUrl->repository}";
|
||||
|
||||
// update the values passed by reference
|
||||
$domain = $parsedUrl->scheme . '://' . $parsedUrl->domain;
|
||||
$organisation = $parsedUrl->organisation ?? $organisation;
|
||||
$repository = $parsedUrl->repository ?? $repository;
|
||||
|
||||
// add info
|
||||
$this->logInfo("Resolved [{$noneActiveDomain}] to [{$activeDomain}]");
|
||||
} catch (\Exception $e) {
|
||||
// ignore any none [in]active urls
|
||||
$this->logError($e, 'Failed to parse active repository URL.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a random active repository target, excluding the specified domain.
|
||||
*
|
||||
* @param string $target The target network.
|
||||
*
|
||||
* @return object|null The randomly selected active repository, or null if none found.
|
||||
* @since 5.0.4
|
||||
*/
|
||||
private function active(string $target): ?object
|
||||
{
|
||||
try {
|
||||
$activeRepo = $this->status->active($target);
|
||||
} catch (\Exception $e) {
|
||||
// ignore any none [in]active urls
|
||||
$this->logError($e, "Failed to get an [{$target}] active repository.");
|
||||
}
|
||||
|
||||
return $activeRepo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs an info custom message.
|
||||
*
|
||||
* @param string $message A custom message to include with the log entry.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.0.4
|
||||
*/
|
||||
private function logInfo(string $message): void
|
||||
{
|
||||
Log::add($message, Log::INFO, 'jcb-network-resolve');
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs an error with a custom message.
|
||||
*
|
||||
* This method is a placeholder for your actual logging mechanism.
|
||||
*
|
||||
* @param \Exception $exception The exception to log.
|
||||
* @param string $message A custom message to include with the log entry.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.0.4
|
||||
*/
|
||||
private function logError(\Exception $exception, string $message): void
|
||||
{
|
||||
Log::add($message . ' Exception: ' . $exception->getMessage(), Log::ERROR, 'jcb-network-resolve');
|
||||
}
|
||||
}
|
||||
|
150
src/a0c143af-3d7d-4c19-91c4-f72060b4c361/code.power
Normal file
150
src/a0c143af-3d7d-4c19-91c4-f72060b4c361/code.power
Normal file
@ -0,0 +1,150 @@
|
||||
/**
|
||||
* The Url Class.
|
||||
*
|
||||
* @var Url
|
||||
* @since 5.0.4
|
||||
*/
|
||||
protected Url $url;
|
||||
|
||||
/**
|
||||
* The Status Class.
|
||||
*
|
||||
* @var Status
|
||||
* @since 5.0.4
|
||||
*/
|
||||
protected Status $status;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Url $url The Url Class.
|
||||
* @param Status $status The Status Class.
|
||||
*
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function __construct(Url $url, Status $status)
|
||||
{
|
||||
$this->url = $url;
|
||||
$this->status = $status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves the API for a repository if it is part of the core network.
|
||||
*
|
||||
* This method attempts to verify the status of the API and resolve an active URL if the current one is inactive.
|
||||
*
|
||||
* @param string $target The target network.
|
||||
* @param string &$domain The API base domain (passed by reference).
|
||||
* @param string &$organisation The repository organisation (passed by reference).
|
||||
* @param string &$repository The repository name (passed by reference).
|
||||
*
|
||||
* @return void
|
||||
* @since 5.0.4
|
||||
*/
|
||||
public function api(string $target, string &$domain, string &$organisation, string &$repository): void
|
||||
{
|
||||
try {
|
||||
// Check the status of the current API
|
||||
$status = $this->status->get($target, $domain, $repository, $organisation);
|
||||
|
||||
// If the API is inactive, attempt to find another active URL
|
||||
if ($status === 0)
|
||||
{
|
||||
$this->resolve($target, $domain, $organisation, $repository);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
// ignore any none [in]active urls
|
||||
$this->logError($e, 'Failed to resolve API status.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves an active API URL if the current API is inactive.
|
||||
*
|
||||
* Updates the `$domain`, `$organisation`, and `$repository` parameters to point to an active API URL.
|
||||
*
|
||||
* @param string $target The target network.
|
||||
* @param string &$domain The API base domain (passed by reference).
|
||||
* @param string &$organisation The repository organisation (passed by reference).
|
||||
* @param string &$repository The repository name (passed by reference).
|
||||
*
|
||||
* @return void
|
||||
* @since 5.0.4
|
||||
*/
|
||||
private function resolve(string $target, string &$domain, string &$organisation, string &$repository): void
|
||||
{
|
||||
$activeRepo = $this->active($target);
|
||||
|
||||
if ($activeRepo === null) {
|
||||
// No active API found, log or handle this case as needed
|
||||
throw new \Exception('No active API found for the target: ' . $target);
|
||||
}
|
||||
|
||||
try {
|
||||
// Parse the active repository's URL and update the references
|
||||
$parsedUrl = $this->url->parse($activeRepo->url);
|
||||
|
||||
$noneActiveDomain = "{$domain}/{$organisation}/{$repository}";
|
||||
$activeDomain = "{$parsedUrl->scheme}://{$parsedUrl->domain}/{$parsedUrl->organisation}/{$parsedUrl->repository}";
|
||||
|
||||
// update the values passed by reference
|
||||
$domain = $parsedUrl->scheme . '://' . $parsedUrl->domain;
|
||||
$organisation = $parsedUrl->organisation ?? $organisation;
|
||||
$repository = $parsedUrl->repository ?? $repository;
|
||||
|
||||
// add info
|
||||
$this->logInfo("Resolved [{$noneActiveDomain}] to [{$activeDomain}]");
|
||||
} catch (\Exception $e) {
|
||||
// ignore any none [in]active urls
|
||||
$this->logError($e, 'Failed to parse active repository URL.');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves a random active repository target, excluding the specified domain.
|
||||
*
|
||||
* @param string $target The target network.
|
||||
*
|
||||
* @return object|null The randomly selected active repository, or null if none found.
|
||||
* @since 5.0.4
|
||||
*/
|
||||
private function active(string $target): ?object
|
||||
{
|
||||
try {
|
||||
$activeRepo = $this->status->active($target);
|
||||
} catch (\Exception $e) {
|
||||
// ignore any none [in]active urls
|
||||
$this->logError($e, "Failed to get an [{$target}] active repository.");
|
||||
}
|
||||
|
||||
return $activeRepo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs an info custom message.
|
||||
*
|
||||
* @param string $message A custom message to include with the log entry.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.0.4
|
||||
*/
|
||||
private function logInfo(string $message): void
|
||||
{
|
||||
Log::add($message, Log::INFO, 'jcb-network-resolve');
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs an error with a custom message.
|
||||
*
|
||||
* This method is a placeholder for your actual logging mechanism.
|
||||
*
|
||||
* @param \Exception $exception The exception to log.
|
||||
* @param string $message A custom message to include with the log entry.
|
||||
*
|
||||
* @return void
|
||||
* @since 5.0.4
|
||||
*/
|
||||
private function logError(\Exception $exception, string $message): void
|
||||
{
|
||||
Log::add($message . ' Exception: ' . $exception->getMessage(), Log::ERROR, 'jcb-network-resolve');
|
||||
}
|
28
src/a0c143af-3d7d-4c19-91c4-f72060b4c361/settings.json
Normal file
28
src/a0c143af-3d7d-4c19-91c4-f72060b4c361/settings.json
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
"add_head": "1",
|
||||
"add_licensing_template": "2",
|
||||
"extends": "",
|
||||
"guid": "a0c143af-3d7d-4c19-91c4-f72060b4c361",
|
||||
"implements": null,
|
||||
"load_selection": null,
|
||||
"name": "Resolve",
|
||||
"power_version": "1.0.0",
|
||||
"system_name": "Joomla.JCB.Network.Resolve",
|
||||
"type": "final class",
|
||||
"use_selection": {
|
||||
"use_selection0": {
|
||||
"use": "286f7550-9c22-401c-9e5a-2f9426888133",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection1": {
|
||||
"use": "809d3077-c105-4e9c-8ac5-8fbee10cf9fc",
|
||||
"as": "default"
|
||||
}
|
||||
},
|
||||
"extendsinterfaces": null,
|
||||
"namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Network.Resolve",
|
||||
"description": "The Network Resolver\r\n\r\n@since 5.0.4",
|
||||
"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\\Log\\Log;",
|
||||
"composer": ""
|
||||
}
|
@ -139,7 +139,7 @@ final class Layout
|
||||
if ($this->layout->exists($nameSingleCode . '.' . $tabName . '.'
|
||||
. $field['alignment'] . '.' . $field['order_edit']))
|
||||
{
|
||||
$size = $this->layout->count($nameSingleCode . '.' . $tabName . '.'
|
||||
$size = $this->layout->pathCount($nameSingleCode . '.' . $tabName . '.'
|
||||
. $field['alignment']) + 1;
|
||||
while ($this->layout->exists($nameSingleCode . '.' . $tabName . '.'
|
||||
. $field['alignment'] . '.' . $size))
|
||||
@ -168,7 +168,7 @@ final class Layout
|
||||
if ($this->newpublishingfields->exists($nameSingleCode . '.' .
|
||||
$field['alignment'] . '.' . $field['order_edit']))
|
||||
{
|
||||
$size = $this->newpublishingfields->count($nameSingleCode . '.' .
|
||||
$size = $this->newpublishingfields->pathCount($nameSingleCode . '.' .
|
||||
$field['alignment']) + 1;
|
||||
while ($this->newpublishingfields->exists($nameSingleCode . '.' .
|
||||
$field['alignment'] . '.' . $size))
|
||||
@ -191,7 +191,7 @@ final class Layout
|
||||
if ($this->layout->exists($nameSingleCode . '.Details.'
|
||||
. $field['alignment'] . '.' . $field['order_edit']))
|
||||
{
|
||||
$size = $this->layout->count($nameSingleCode . '.Details.'
|
||||
$size = $this->layout->pathCount($nameSingleCode . '.Details.'
|
||||
. $field['alignment']) + 1;
|
||||
while ($this->layout->exists($nameSingleCode . '.Details.'
|
||||
. $field['alignment'] . '.' . $size))
|
||||
|
@ -109,7 +109,7 @@
|
||||
if ($this->layout->exists($nameSingleCode . '.' . $tabName . '.'
|
||||
. $field['alignment'] . '.' . $field['order_edit']))
|
||||
{
|
||||
$size = $this->layout->count($nameSingleCode . '.' . $tabName . '.'
|
||||
$size = $this->layout->pathCount($nameSingleCode . '.' . $tabName . '.'
|
||||
. $field['alignment']) + 1;
|
||||
while ($this->layout->exists($nameSingleCode . '.' . $tabName . '.'
|
||||
. $field['alignment'] . '.' . $size))
|
||||
@ -138,7 +138,7 @@
|
||||
if ($this->newpublishingfields->exists($nameSingleCode . '.' .
|
||||
$field['alignment'] . '.' . $field['order_edit']))
|
||||
{
|
||||
$size = $this->newpublishingfields->count($nameSingleCode . '.' .
|
||||
$size = $this->newpublishingfields->pathCount($nameSingleCode . '.' .
|
||||
$field['alignment']) + 1;
|
||||
while ($this->newpublishingfields->exists($nameSingleCode . '.' .
|
||||
$field['alignment'] . '.' . $size))
|
||||
@ -161,7 +161,7 @@
|
||||
if ($this->layout->exists($nameSingleCode . '.Details.'
|
||||
. $field['alignment'] . '.' . $field['order_edit']))
|
||||
{
|
||||
$size = $this->layout->count($nameSingleCode . '.Details.'
|
||||
$size = $this->layout->pathCount($nameSingleCode . '.Details.'
|
||||
. $field['alignment']) + 1;
|
||||
while ($this->layout->exists($nameSingleCode . '.Details.'
|
||||
. $field['alignment'] . '.' . $size))
|
||||
|
@ -12,7 +12,7 @@
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Builder;
|
||||
|
||||
|
||||
use VDM\Joomla\Abstraction\Registry\Traits\ToString;
|
||||
use VDM\Joomla\Abstraction\Registry\Traits\PathToString;
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
@ -25,10 +25,10 @@ use VDM\Joomla\Abstraction\Registry;
|
||||
final class CustomFieldLinks extends Registry implements Registryinterface
|
||||
{
|
||||
/**
|
||||
* To String Values
|
||||
* Path To String Values
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
use ToString;
|
||||
use PathToString;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/**
|
||||
* To String Values
|
||||
* Path To String Values
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
use ToString;
|
||||
use PathToString;
|
@ -21,6 +21,9 @@ use VDM\Joomla\Componentbuilder\Power\Service\Generator;
|
||||
use VDM\Joomla\Componentbuilder\Service\Gitea;
|
||||
use VDM\Joomla\Componentbuilder\Power\Service\Gitea as GiteaPower;
|
||||
use VDM\Joomla\Gitea\Service\Utilities as GiteaUtilities;
|
||||
use VDM\Joomla\Componentbuilder\Service\Network;
|
||||
use VDM\Joomla\Componentbuilder\Service\Api;
|
||||
use VDM\Joomla\Componentbuilder\Service\Utilities;
|
||||
use VDM\Joomla\Interfaces\FactoryInterface;
|
||||
use VDM\Joomla\Abstraction\Factory as ExtendingFactory;
|
||||
|
||||
@ -56,7 +59,10 @@ abstract class Factory extends ExtendingFactory implements FactoryInterface
|
||||
->registerServiceProvider(new Generator())
|
||||
->registerServiceProvider(new Gitea())
|
||||
->registerServiceProvider(new GiteaPower())
|
||||
->registerServiceProvider(new GiteaUtilities());
|
||||
->registerServiceProvider(new GiteaUtilities())
|
||||
->registerServiceProvider(new Api())
|
||||
->registerServiceProvider(new Network())
|
||||
->registerServiceProvider(new Utilities());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,5 +22,8 @@
|
||||
->registerServiceProvider(new Generator())
|
||||
->registerServiceProvider(new Gitea())
|
||||
->registerServiceProvider(new GiteaPower())
|
||||
->registerServiceProvider(new GiteaUtilities());
|
||||
->registerServiceProvider(new GiteaUtilities())
|
||||
->registerServiceProvider(new Api())
|
||||
->registerServiceProvider(new Network())
|
||||
->registerServiceProvider(new Utilities());
|
||||
}
|
@ -43,6 +43,18 @@
|
||||
"use_selection7": {
|
||||
"use": "6edf0cf3-c2b0-45c9-84d2-c6ef1c5d434c",
|
||||
"as": "GiteaUtilities"
|
||||
},
|
||||
"use_selection8": {
|
||||
"use": "156f449b-ca6c-4a57-a925-be345e751614",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection9": {
|
||||
"use": "3c7567d7-b079-4910-b325-7ed5c30cabff",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection10": {
|
||||
"use": "facd1e1c-ff2f-4520-b735-075c45aa55ed",
|
||||
"as": "default"
|
||||
}
|
||||
},
|
||||
"extendsinterfaces": null,
|
||||
|
@ -12,7 +12,7 @@
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Builder;
|
||||
|
||||
|
||||
use VDM\Joomla\Abstraction\Registry\Traits\Count;
|
||||
use VDM\Joomla\Abstraction\Registry\Traits\PathCount;
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
@ -25,10 +25,10 @@ use VDM\Joomla\Abstraction\Registry;
|
||||
final class Layout extends Registry implements Registryinterface
|
||||
{
|
||||
/**
|
||||
* Count Values
|
||||
* Path Count Values
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
use Count;
|
||||
use PathCount;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Count Values
|
||||
* Path Count Values
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
use Count;
|
||||
use PathCount;
|
@ -32,6 +32,11 @@ class Whmcs
|
||||
*/
|
||||
public function set(object &$item)
|
||||
{
|
||||
if (!isset($item->add_license))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (1 == $item->add_license
|
||||
&& (!isset($item->whmcs_buy_link)
|
||||
|| !StringHelper::check(
|
||||
|
@ -8,6 +8,11 @@
|
||||
*/
|
||||
public function set(object &$item)
|
||||
{
|
||||
if (!isset($item->add_license))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (1 == $item->add_license
|
||||
&& (!isset($item->whmcs_buy_link)
|
||||
|| !StringHelper::check(
|
||||
|
@ -8,7 +8,7 @@
|
||||
```
|
||||
# class Config (Details)
|
||||
> namespace: **VDM\Joomla\Componentbuilder\Fieldtype**
|
||||
> extends: **BaseConfig**
|
||||
> extends: **ComponentConfig**
|
||||
|
||||
```uml
|
||||
@startuml
|
||||
|
@ -17,7 +17,7 @@ use Joomla\CMS\Factory as JoomlaFactory;
|
||||
use VDM\Joomla\Utilities\GetHelper;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Componentbuilder\Utilities\RepoHelper;
|
||||
use VDM\Joomla\Componentbuilder\Abstraction\BaseConfig;
|
||||
use VDM\Joomla\Componentbuilder\Abstraction\ComponentConfig;
|
||||
|
||||
|
||||
/**
|
||||
@ -31,7 +31,7 @@ use VDM\Joomla\Componentbuilder\Abstraction\BaseConfig;
|
||||
*
|
||||
* @since 5.0.3
|
||||
*/
|
||||
class Config extends BaseConfig
|
||||
class Config extends ComponentConfig
|
||||
{
|
||||
/**
|
||||
* The Global Joomla Configuration
|
||||
|
@ -8,7 +8,7 @@
|
||||
```
|
||||
# class Config (Details)
|
||||
> namespace: **VDM\Joomla\Componentbuilder\Power**
|
||||
> extends: **BaseConfig**
|
||||
> extends: **ComponentConfig**
|
||||
|
||||
```uml
|
||||
@startuml
|
||||
|
@ -18,7 +18,7 @@ use Joomla\Input\Input;
|
||||
use VDM\Joomla\Utilities\GetHelper;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Componentbuilder\Utilities\RepoHelper;
|
||||
use VDM\Joomla\Componentbuilder\Abstraction\BaseConfig;
|
||||
use VDM\Joomla\Componentbuilder\Abstraction\ComponentConfig;
|
||||
|
||||
|
||||
/**
|
||||
@ -32,7 +32,7 @@ use VDM\Joomla\Componentbuilder\Abstraction\BaseConfig;
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Config extends BaseConfig
|
||||
class Config extends ComponentConfig
|
||||
{
|
||||
/**
|
||||
* The Global Joomla Configuration
|
||||
|
73
src/c99e85a0-d120-4f25-bcbf-0940dd7b773b/README.md
Normal file
73
src/c99e85a0-d120-4f25-bcbf-0940dd7b773b/README.md
Normal file
@ -0,0 +1,73 @@
|
||||
```
|
||||
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||
```
|
||||
# final class Response (Details)
|
||||
> namespace: **VDM\Joomla\Componentbuilder\Utilities**
|
||||
|
||||
```uml
|
||||
@startuml
|
||||
class Response << (F,LightGreen) >> #RoyalBlue {
|
||||
+ get(JoomlaResponse $response, int $expectedCode = 200, ...) : mixed
|
||||
# getBody(JoomlaResponse $response, mixed $default = null) : mixed
|
||||
# error(JoomlaResponse $response) : string
|
||||
}
|
||||
|
||||
note right of Response::get
|
||||
Process the response and decode it.
|
||||
|
||||
since: 2.0.1
|
||||
return: mixed
|
||||
|
||||
arguments:
|
||||
JoomlaResponse $response
|
||||
int $expectedCode = 200
|
||||
mixed $default = null
|
||||
end note
|
||||
|
||||
note right of Response::getBody
|
||||
Return the body from the response
|
||||
|
||||
since: 2.0.1
|
||||
return: mixed
|
||||
end note
|
||||
|
||||
note right of Response::error
|
||||
Get the error message from the System API response
|
||||
|
||||
since: 2.0.1
|
||||
return: string
|
||||
end note
|
||||
|
||||
@enduml
|
||||
```
|
||||
|
||||
The Power feature in JCB allows you to write PHP classes and their implementations, making it easy to include them in your Joomla project. JCB handles linking, autoloading, namespacing, and folder structure creation for you.
|
||||
|
||||
By using the SPK (Super Power Key) in your custom code (replacing the class name in your code with the SPK), JCB will automatically pull the power from the repository into your project. This makes it available in your JCB instance, allowing you to edit it and include the class in your generated Joomla component.
|
||||
|
||||
JCB uses placeholders like [[[`NamespacePrefix`]]] and [[[`ComponentNamespace`]]] in namespacing to prevent collisions and improve reusability across different JCB systems. You can also set the **JCB powers path** globally or per component under the **Dynamic Integration** tab, providing flexibility and easy maintainability.
|
||||
|
||||
To add this specific Power to your project in JCB:
|
||||
|
||||
> simply use this SPK
|
||||
```
|
||||
Super---c99e85a0_d120_4f25_bcbf_0940dd7b773b---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)
|
||||
|
125
src/c99e85a0-d120-4f25-bcbf-0940dd7b773b/code.php
Normal file
125
src/c99e85a0-d120-4f25-bcbf-0940dd7b773b/code.php
Normal file
@ -0,0 +1,125 @@
|
||||
<?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\Utilities;
|
||||
|
||||
|
||||
use Joomla\CMS\Http\Response as JoomlaResponse;
|
||||
use VDM\Joomla\Utilities\JsonHelper;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
|
||||
|
||||
/**
|
||||
* The Response
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
final class Response
|
||||
{
|
||||
/**
|
||||
* Process the response and decode it.
|
||||
*
|
||||
* @param JoomlaResponse $response The response.
|
||||
* @param integer $expectedCode The expected "good" code.
|
||||
* @param mixed $default The default if body not have length
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @since 2.0.1
|
||||
* @throws \DomainException
|
||||
**/
|
||||
public function get($response, int $expectedCode = 200, $default = null)
|
||||
{
|
||||
// Validate the response code.
|
||||
if ($response->code != $expectedCode)
|
||||
{
|
||||
// Decode the error response and throw an exception.
|
||||
$message = $this->error($response);
|
||||
|
||||
// Throw an exception with the error message and code.
|
||||
throw new \DomainException($message, $response->code);
|
||||
}
|
||||
|
||||
return $this->getBody($response, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the body from the response
|
||||
*
|
||||
* @param JoomlaResponse $response The response.
|
||||
* @param mixed $default The default if body not have length
|
||||
*
|
||||
* @return mixed
|
||||
* @since 2.0.1
|
||||
**/
|
||||
protected function getBody($response, $default = null)
|
||||
{
|
||||
$body = $response->body ?? null;
|
||||
// check that we have a body
|
||||
if (StringHelper::check($body))
|
||||
{
|
||||
// if it's JSON, decode it
|
||||
if (JsonHelper::check($body))
|
||||
{
|
||||
return json_decode((string) $body);
|
||||
}
|
||||
|
||||
// if it's XML, convert it to an object
|
||||
libxml_use_internal_errors(true);
|
||||
$xml = simplexml_load_string($body);
|
||||
if ($xml !== false)
|
||||
{
|
||||
return $xml;
|
||||
}
|
||||
|
||||
// if it's neither JSON nor XML, return as is
|
||||
return $body;
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the error message from the System API response
|
||||
*
|
||||
* @param JoomlaResponse $response The response.
|
||||
*
|
||||
* @return string
|
||||
* @since 2.0.1
|
||||
**/
|
||||
protected function error($response): string
|
||||
{
|
||||
$body = $response->body ?? null;
|
||||
// do we have a json string
|
||||
if (JsonHelper::check($body))
|
||||
{
|
||||
$error = json_decode($body);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 'Invalid or empty response body.';
|
||||
}
|
||||
|
||||
// check if system returned an error object
|
||||
if (isset($error->Error))
|
||||
{
|
||||
// error object found, extract message and code
|
||||
$errorMessage = isset($error->Error->Message) ? $error->Error->Message : 'Unknown error.';
|
||||
$errorCode = isset($error->Error->Code) ? $error->Error->Code : 'Unknown error code.';
|
||||
|
||||
// return formatted error message
|
||||
return 'Error: ' . $errorMessage . ' Code: ' . $errorCode;
|
||||
}
|
||||
|
||||
return 'No error information found in response.';
|
||||
}
|
||||
}
|
||||
|
97
src/c99e85a0-d120-4f25-bcbf-0940dd7b773b/code.power
Normal file
97
src/c99e85a0-d120-4f25-bcbf-0940dd7b773b/code.power
Normal file
@ -0,0 +1,97 @@
|
||||
/**
|
||||
* Process the response and decode it.
|
||||
*
|
||||
* @param JoomlaResponse $response The response.
|
||||
* @param integer $expectedCode The expected "good" code.
|
||||
* @param mixed $default The default if body not have length
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @since 2.0.1
|
||||
* @throws \DomainException
|
||||
**/
|
||||
public function get($response, int $expectedCode = 200, $default = null)
|
||||
{
|
||||
// Validate the response code.
|
||||
if ($response->code != $expectedCode)
|
||||
{
|
||||
// Decode the error response and throw an exception.
|
||||
$message = $this->error($response);
|
||||
|
||||
// Throw an exception with the error message and code.
|
||||
throw new \DomainException($message, $response->code);
|
||||
}
|
||||
|
||||
return $this->getBody($response, $default);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the body from the response
|
||||
*
|
||||
* @param JoomlaResponse $response The response.
|
||||
* @param mixed $default The default if body not have length
|
||||
*
|
||||
* @return mixed
|
||||
* @since 2.0.1
|
||||
**/
|
||||
protected function getBody($response, $default = null)
|
||||
{
|
||||
$body = $response->body ?? null;
|
||||
// check that we have a body
|
||||
if (StringHelper::check($body))
|
||||
{
|
||||
// if it's JSON, decode it
|
||||
if (JsonHelper::check($body))
|
||||
{
|
||||
return json_decode((string) $body);
|
||||
}
|
||||
|
||||
// if it's XML, convert it to an object
|
||||
libxml_use_internal_errors(true);
|
||||
$xml = simplexml_load_string($body);
|
||||
if ($xml !== false)
|
||||
{
|
||||
return $xml;
|
||||
}
|
||||
|
||||
// if it's neither JSON nor XML, return as is
|
||||
return $body;
|
||||
}
|
||||
|
||||
return $default;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the error message from the System API response
|
||||
*
|
||||
* @param JoomlaResponse $response The response.
|
||||
*
|
||||
* @return string
|
||||
* @since 2.0.1
|
||||
**/
|
||||
protected function error($response): string
|
||||
{
|
||||
$body = $response->body ?? null;
|
||||
// do we have a json string
|
||||
if (JsonHelper::check($body))
|
||||
{
|
||||
$error = json_decode($body);
|
||||
}
|
||||
else
|
||||
{
|
||||
return 'Invalid or empty response body.';
|
||||
}
|
||||
|
||||
// check if system returned an error object
|
||||
if (isset($error->Error))
|
||||
{
|
||||
// error object found, extract message and code
|
||||
$errorMessage = isset($error->Error->Message) ? $error->Error->Message : 'Unknown error.';
|
||||
$errorCode = isset($error->Error->Code) ? $error->Error->Code : 'Unknown error code.';
|
||||
|
||||
// return formatted error message
|
||||
return 'Error: ' . $errorMessage . ' Code: ' . $errorCode;
|
||||
}
|
||||
|
||||
return 'No error information found in response.';
|
||||
}
|
28
src/c99e85a0-d120-4f25-bcbf-0940dd7b773b/settings.json
Normal file
28
src/c99e85a0-d120-4f25-bcbf-0940dd7b773b/settings.json
Normal file
@ -0,0 +1,28 @@
|
||||
{
|
||||
"add_head": "1",
|
||||
"add_licensing_template": "2",
|
||||
"extends": "",
|
||||
"guid": "c99e85a0-d120-4f25-bcbf-0940dd7b773b",
|
||||
"implements": null,
|
||||
"load_selection": null,
|
||||
"name": "Response",
|
||||
"power_version": "1.0.0",
|
||||
"system_name": "Joomla.Utilities.Response",
|
||||
"type": "final class",
|
||||
"use_selection": {
|
||||
"use_selection0": {
|
||||
"use": "4b225c51-d293-48e4-b3f6-5136cf5c3f18",
|
||||
"as": "default"
|
||||
},
|
||||
"use_selection1": {
|
||||
"use": "1f28cb53-60d9-4db1-b517-3c7dc6b429ef",
|
||||
"as": "default"
|
||||
}
|
||||
},
|
||||
"extendsinterfaces": null,
|
||||
"namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[ComponentNamespace]]].Utilities.Response",
|
||||
"description": "The Response\r\n\r\n@since 2.0.1",
|
||||
"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\\Http\\Response as JoomlaResponse;",
|
||||
"composer": ""
|
||||
}
|
@ -12,6 +12,7 @@
|
||||
```uml
|
||||
@startuml
|
||||
class Data #Gold {
|
||||
# array $data
|
||||
# Config $config
|
||||
# Event $event
|
||||
# Placeholder $placeholder
|
||||
|
@ -47,6 +47,14 @@ use VDM\Joomla\Utilities\ArrayHelper;
|
||||
*/
|
||||
class Data
|
||||
{
|
||||
/**
|
||||
* The cache
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected array $data;
|
||||
|
||||
/**
|
||||
* The Config Class.
|
||||
*
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user