Update 2024-06-24 1:01:32

This commit is contained in:
Robot 2024-06-23 22:34:48 +02:00
parent 6ae30a020c
commit eea2fa1f13
Signed by untrusted user: Robot
GPG Key ID: 14DECD44E7E1BB95
51 changed files with 1094 additions and 137 deletions

View File

@ -29,19 +29,21 @@ This repository contains an index (see below) of all the approved powers within
- **abstract class BaseConfig** | [Details](src/ffbd4e1f-a342-4080-ab7d-1de3741bf319) | [Code](src/ffbd4e1f-a342-4080-ab7d-1de3741bf319/code.php) | [Settings](src/ffbd4e1f-a342-4080-ab7d-1de3741bf319/settings.json) | Super__ffbd4e1f_a342_4080_ab7d_1de3741bf319__Power
- **abstract class BaseTable** | [Details](src/e0f6ddbe-2a35-4537-942c-faff2ebd04f6) | [Code](src/e0f6ddbe-2a35-4537-942c-faff2ebd04f6/code.php) | [Settings](src/e0f6ddbe-2a35-4537-942c-faff2ebd04f6/settings.json) | Super__e0f6ddbe_2a35_4537_942c_faff2ebd04f6__Power
- **abstract class Database** | [Details](src/6cbef8f8-4813-48e3-b05a-65e1aea95171) | [Code](src/6cbef8f8-4813-48e3-b05a-65e1aea95171/code.php) | [Settings](src/6cbef8f8-4813-48e3-b05a-65e1aea95171/settings.json) | Super__6cbef8f8_4813_48e3_b05a_65e1aea95171__Power
- **abstract class Factory** | [Details](src/2e5bf608-de5c-4b00-a20d-47c26aa350d9) | [Code](src/2e5bf608-de5c-4b00-a20d-47c26aa350d9/code.php) | [Settings](src/2e5bf608-de5c-4b00-a20d-47c26aa350d9/settings.json) | Super__2e5bf608_de5c_4b00_a20d_47c26aa350d9__Power
- **abstract class Grep** | [Details](src/1401a167-0ce4-4f4a-afee-2d8b02ed339b) | [Code](src/1401a167-0ce4-4f4a-afee-2d8b02ed339b/code.php) | [Settings](src/1401a167-0ce4-4f4a-afee-2d8b02ed339b/settings.json) | Super__1401a167_0ce4_4f4a_afee_2d8b02ed339b__Power
- **abstract class Model** | [Details](src/584747d1-3a86-453d-b7a3-a2219de8d777) | [Code](src/584747d1-3a86-453d-b7a3-a2219de8d777/code.php) | [Settings](src/584747d1-3a86-453d-b7a3-a2219de8d777/settings.json) | Super__584747d1_3a86_453d_b7a3_a2219de8d777__Power
- **abstract class Registry** | [Details](src/7e822c03-1b20-41d1-9427-f5b8d5836af7) | [Code](src/7e822c03-1b20-41d1-9427-f5b8d5836af7/code.php) | [Settings](src/7e822c03-1b20-41d1-9427-f5b8d5836af7/settings.json) | Super__7e822c03_1b20_41d1_9427_f5b8d5836af7__Power
- **abstract class Schema** | [Details](src/f3c04c28-bce4-422e-be93-7d163e4e342b) | [Code](src/f3c04c28-bce4-422e-be93-7d163e4e342b/code.php) | [Settings](src/f3c04c28-bce4-422e-be93-7d163e4e342b/settings.json) | Super__f3c04c28_bce4_422e_be93_7d163e4e342b__Power
- **Namespace**: [VDM\Joomla\Componentbuilder](#vdm-joomla-componentbuilder)
- **class Table** | [Details](src/bfd1d6d5-56c1-4fe9-9fee-1c5910e1f5d8) | [Code](src/bfd1d6d5-56c1-4fe9-9fee-1c5910e1f5d8/code.php) | [Settings](src/bfd1d6d5-56c1-4fe9-9fee-1c5910e1f5d8/settings.json) | Super__bfd1d6d5_56c1_4fe9_9fee_1c5910e1f5d8__Power
- **final class Table** | [Details](src/bfd1d6d5-56c1-4fe9-9fee-1c5910e1f5d8) | [Code](src/bfd1d6d5-56c1-4fe9-9fee-1c5910e1f5d8/code.php) | [Settings](src/bfd1d6d5-56c1-4fe9-9fee-1c5910e1f5d8/settings.json) | Super__bfd1d6d5_56c1_4fe9_9fee_1c5910e1f5d8__Power
- **Namespace**: [VDM\Joomla\Data](#vdm-joomla-data)
- **abstract class Factory** | [Details](src/9d76b8dc-3883-4755-b11c-131d19ca8a53) | [Code](src/9d76b8dc-3883-4755-b11c-131d19ca8a53/code.php) | [Settings](src/9d76b8dc-3883-4755-b11c-131d19ca8a53/settings.json) | Super__9d76b8dc_3883_4755_b11c_131d19ca8a53__Power
- **final class Item** | [Details](src/9206082e-a3f7-472e-98b2-de90d06cbdcd) | [Code](src/9206082e-a3f7-472e-98b2-de90d06cbdcd/code.php) | [Settings](src/9206082e-a3f7-472e-98b2-de90d06cbdcd/settings.json) | Super__9206082e_a3f7_472e_98b2_de90d06cbdcd__Power
- **final class Items** | [Details](src/21bca8a4-5b28-41c4-843e-8097f0ba7cca) | [Code](src/21bca8a4-5b28-41c4-843e-8097f0ba7cca/code.php) | [Settings](src/21bca8a4-5b28-41c4-843e-8097f0ba7cca/settings.json) | Super__21bca8a4_5b28_41c4_843e_8097f0ba7cca__Power
- **final class Subform** | [Details](src/85785701-07b2-4f81-bc1e-0f423700c254) | [Code](src/85785701-07b2-4f81-bc1e-0f423700c254/code.php) | [Settings](src/85785701-07b2-4f81-bc1e-0f423700c254/settings.json) | Super__85785701_07b2_4f81_bc1e_0f423700c254__Power
- **class Remote** | [Details](src/728ee726-3f0f-4762-899d-f8c9430cee58) | [Code](src/728ee726-3f0f-4762-899d-f8c9430cee58/code.php) | [Settings](src/728ee726-3f0f-4762-899d-f8c9430cee58/settings.json) | Super__728ee726_3f0f_4762_899d_f8c9430cee58__Power
- **class Subform** | [Details](src/85785701-07b2-4f81-bc1e-0f423700c254) | [Code](src/85785701-07b2-4f81-bc1e-0f423700c254/code.php) | [Settings](src/85785701-07b2-4f81-bc1e-0f423700c254/settings.json) | Super__85785701_07b2_4f81_bc1e_0f423700c254__Power
- **Namespace**: [VDM\Joomla\Database](#vdm-joomla-database)
- **final class Delete** | [Details](src/92291f1f-f248-4ec0-9f2a-3d47c49eeac1) | [Code](src/92291f1f-f248-4ec0-9f2a-3d47c49eeac1/code.php) | [Settings](src/92291f1f-f248-4ec0-9f2a-3d47c49eeac1/settings.json) | Super__92291f1f_f248_4ec0_9f2a_3d47c49eeac1__Power
@ -70,6 +72,7 @@ This repository contains an index (see below) of all the approved powers within
- **class Data** | [Details](src/a5daf189-3345-4b13-8716-c51f686f545b) | [Code](src/a5daf189-3345-4b13-8716-c51f686f545b/code.php) | [Settings](src/a5daf189-3345-4b13-8716-c51f686f545b/settings.json) | Super__a5daf189_3345_4b13_8716_c51f686f545b__Power
- **class Database** | [Details](src/4815e1c7-a433-443d-a112-d1e03d7df84b) | [Code](src/4815e1c7-a433-443d-a112-d1e03d7df84b/code.php) | [Settings](src/4815e1c7-a433-443d-a112-d1e03d7df84b/settings.json) | Super__4815e1c7_a433_443d_a112_d1e03d7df84b__Power
- **class Model** | [Details](src/2dcedd6c-c95b-4a37-9cac-95d28faedca3) | [Code](src/2dcedd6c-c95b-4a37-9cac-95d28faedca3/code.php) | [Settings](src/2dcedd6c-c95b-4a37-9cac-95d28faedca3/settings.json) | Super__2dcedd6c_c95b_4a37_9cac_95d28faedca3__Power
- **class Table** | [Details](src/19b2ba92-1655-4384-acfb-979c80de8b6d) | [Code](src/19b2ba92-1655-4384-acfb-979c80de8b6d/code.php) | [Settings](src/19b2ba92-1655-4384-acfb-979c80de8b6d/settings.json) | Super__19b2ba92_1655_4384_acfb_979c80de8b6d__Power
- **Namespace**: [VDM\Joomla\Utilities](#vdm-joomla-utilities)
- **abstract class ArrayHelper** | [Details](src/0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a) | [Code](src/0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a/code.php) | [Settings](src/0a59c65c-9daf-4bc9-baf4-e063ff9e6a8a/settings.json) | Super__0a59c65c_9daf_4bc9_baf4_e063ff9e6a8a__Power

View File

@ -18,6 +18,7 @@ class Load #Gold {
+ __construct(Model $model, Database $load, ...)
+ table(?string $table) : self
+ value(array $keys, string $field) : mixed
+ values(array $keys, string $field) : ?array
+ item(array $keys) : ?object
+ items(array $keys) : ?array
+ getTable() : string
@ -35,7 +36,7 @@ note right of Load::__construct
?string $table = null
end note
note right of Load::table
note left of Load::table
Set the current active table
since: 3.2.2
@ -54,6 +55,18 @@ Example: $this->value(
return: mixed
end note
note left of Load::values
Get a value from multiple rows from a given table
Example: $this->values(
[
'guid' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
], 'value_key'
);
since: 3.2.2
return: ?array
end note
note right of Load::item
Get values from a given table
Example: $this->item(
@ -66,7 +79,7 @@ Example: $this->item(
return: ?object
end note
note right of Load::items
note left of Load::items
Get values from a given table
Example: $this->items(
[
@ -89,7 +102,7 @@ note right of Load::getTable
return: string
end note
note right of Load::prefix
note left of Load::prefix
Add prefix to the keys
since: 2.0.1

View File

@ -112,6 +112,33 @@ class Load implements LoadInterface
);
}
/**
* Get a value from multiple rows from a given table
* Example: $this->values(
* [
* 'guid' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
* ], 'value_key'
* );
*
* @param array $keys The item keys
* @param string $field The field key
*
* @return array|null
* @since 3.2.2
*/
public function values(array $keys, string $field): ?array
{
return $this->model->values(
$this->load->values(
["a.{$field}" => $field],
['a' => $this->getTable()],
$this->prefix($keys)
),
$field,
$this->getTable()
);
}
/**
* Get values from a given table
* Example: $this->item(

View File

@ -86,6 +86,33 @@
);
}
/**
* Get a value from multiple rows from a given table
* Example: $this->values(
* [
* 'guid' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
* ], 'value_key'
* );
*
* @param array $keys The item keys
* @param string $field The field key
*
* @return array|null
* @since 3.2.2
*/
public function values(array $keys, string $field): ?array
{
return $this->model->values(
$this->load->values(
["a.{$field}" => $field],
['a' => $this->getTable()],
$this->prefix($keys)
),
$field,
$this->getTable()
);
}
/**
* Get values from a given table
* Example: $this->item(

View File

@ -19,6 +19,7 @@ class Load << (F,LightGreen) >> #RoyalBlue {
+ max(string $field, array $tables, ...) : ?int
+ count(array $tables, array $filter) : ?int
+ value(array $select, array $tables, ...) : mixed
+ values(array $select, array $tables, ...) : ?array
# many(array $select, array $tables, ...) : bool
# one(array $select, array $tables, ...) : bool
# query(array $select, array $tables, ...) : ?object
@ -111,7 +112,21 @@ note right of Load::value
?array $order = null
end note
note left of Load::many
note left of Load::values
Load values from multiple rows
since: 3.2.2
return: ?array
arguments:
array $select
array $tables
?array $where = null
?array $order = null
?int $limit = null
end note
note right of Load::many
Load many
since: 3.2.0
@ -125,7 +140,7 @@ note left of Load::many
?int $limit = null
end note
note right of Load::one
note left of Load::one
Load one
since: 3.2.0
@ -138,7 +153,7 @@ note right of Load::one
?array $order = null
end note
note left of Load::query
note right of Load::query
Get the query object
since: 3.2.0
@ -152,7 +167,7 @@ note left of Load::query
?int $limit = null
end note
note right of Load::getKey
note left of Load::getKey
Get the key from the selection array.
This function retrieves a key from the provided selection array.
The key is removed from the array after being retrieved.

View File

@ -216,6 +216,31 @@ final class Load extends Database implements LoadInterface
return null;
}
/**
* Load values from multiple rows
*
* @param array $select Array of selection keys
* @param array $tables Array of tables to search
* @param array|null $where Array of where key=>value match exist
* @param array|null $order Array of how to order the data
* @param int|null $limit Limit the number of values returned
*
* @return array|null
* @since 3.2.2
**/
public function values(array $select, array $tables, ?array $where = null,
?array $order = null, ?int $limit = null): ?array
{
// check if we can get many rows
if ($this->many($select, $tables, $where, $order, $limit))
{
return $this->db->loadColumn();
}
// data does not exist
return null;
}
/**
* Load many
*

View File

@ -190,6 +190,31 @@
return null;
}
/**
* Load values from multiple rows
*
* @param array $select Array of selection keys
* @param array $tables Array of tables to search
* @param array|null $where Array of where key=>value match exist
* @param array|null $order Array of how to order the data
* @param int|null $limit Limit the number of values returned
*
* @return array|null
* @since 3.2.2
**/
public function values(array $select, array $tables, ?array $where = null,
?array $order = null, ?int $limit = null): ?array
{
// check if we can get many rows
if ($this->many($select, $tables, $where, $order, $limit))
{
return $this->db->loadColumn();
}
// data does not exist
return null;
}
/**
* Load many
*

View File

@ -0,0 +1,54 @@
```
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# class Table (Details)
> namespace: **VDM\Joomla\Service**
> extends: ****
```uml
@startuml
class Table #Gold {
+ register(Container $container) : void
+ getTable(Container $container) : DataTable
+ getSchema(Container $container) : Schema
}
note right of Table::register
Registers the service provider with a DI container.
since: 3.2.2
return: void
end note
note right of Table::getTable
Get The Componentbuilder Data Table Class.
since: 3.2.2
return: DataTable
end note
note right of Table::getSchema
Get The Schema Class.
since: 3.2.2
return: Schema
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)

View File

@ -0,0 +1,73 @@
<?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\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\Table as DataTable;
use VDM\Joomla\Componentbuilder\Table\Schema;
/**
* Table Service Provider
*
* @since 3.2.2
*/
class Table implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.2
*/
public function register(Container $container)
{
$container->alias(DataTable::class, 'Table')
->share('Table', [$this, 'getTable'], true);
$container->alias(Schema::class, 'Table.Schema')
->share('Table.Schema', [$this, 'getSchema'], true);
}
/**
* Get The Componentbuilder Data Table Class.
*
* @param Container $container The DI container.
*
* @return DataTable
* @since 3.2.2
*/
public function getTable(Container $container): DataTable
{
return new DataTable();
}
/**
* Get The Schema Class.
*
* @param Container $container The DI container.
*
* @return Schema
* @since 3.2.2
*/
public function getSchema(Container $container): Schema
{
return new Schema(
$container->get('Table')
);
}
}

View File

@ -0,0 +1,44 @@
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
* @since 3.2.2
*/
public function register(Container $container)
{
$container->alias(DataTable::class, 'Table')
->share('Table', [$this, 'getTable'], true);
$container->alias(Schema::class, 'Table.Schema')
->share('Table.Schema', [$this, 'getSchema'], true);
}
/**
* Get The [[[Component]]] Data Table Class.
*
* @param Container $container The DI container.
*
* @return DataTable
* @since 3.2.2
*/
public function getTable(Container $container): DataTable
{
return new DataTable();
}
/**
* Get The Schema Class.
*
* @param Container $container The DI container.
*
* @return Schema
* @since 3.2.2
*/
public function getSchema(Container $container): Schema
{
return new Schema(
$container->get('Table')
);
}

View File

@ -0,0 +1,31 @@
{
"add_head": "1",
"add_licensing_template": "2",
"extends": "",
"guid": "19b2ba92-1655-4384-acfb-979c80de8b6d",
"implements": [
"-1"
],
"load_selection": null,
"name": "Table",
"power_version": "1.0.0",
"system_name": "VDM.Service.Table",
"type": "class",
"use_selection": {
"use_selection0": {
"use": "bfd1d6d5-56c1-4fe9-9fee-1c5910e1f5d8",
"as": "DataTable"
},
"use_selection1": {
"use": "b3d2ec33-76d4-4c3b-bb2c-86ac14a221ce",
"as": "default"
}
},
"extendsinterfaces": null,
"namespace": "[[[NamespacePrefix]]]\\Joomla\\Service.Table",
"description": "Table Service Provider\r\n\r\n@since 3.2.2",
"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": ""
}

View File

@ -142,32 +142,18 @@ final class Items implements ItemsInterface
* @param string $key The key on which the values being searched.
* @param string $get The key of the values we want back
*
* @return array|null The array of found values.
* @return array|null The array of found values.
* @since 3.2.2
*/
public function values(array $values, string $key = 'guid', string $get = 'id'): ?array
{
// Perform the database query
$rows = $this->database->rows(
["a.$get" => $get],
["a" => $this->getTable()],
["a.$key" => ['operator' => 'IN', 'value' => $values]]
);
// Check if rows are found
if ($rows !== null)
{
// Return the values from the found rows
return array_values(
array_map(
fn($row) => $row[$get],
$rows
)
);
}
// Return null if no rows are found
return null;
return $this->load->table($this->getTable())->values([
$key => [
'operator' => 'IN',
'value' => array_values($values)
]
], $get);
}
/**
@ -269,7 +255,12 @@ final class Items implements ItemsInterface
];
// Check for existing items.
$existingItems = $this->values($values, $key, $key);
$existingItems = $this->database->values(
["a.$key" => $key],
["a" => $this->getTable()],
["a.$key" => ['operator' => 'IN', 'value' => $values]]
);
if ($existingItems !== null)
{
$sets['update'] = $this->extractSet($items, $existingItems, $key) ?? [];

View File

@ -113,32 +113,18 @@
* @param string $key The key on which the values being searched.
* @param string $get The key of the values we want back
*
* @return array|null The array of found values.
* @return array|null The array of found values.
* @since 3.2.2
*/
public function values(array $values, string $key = 'guid', string $get = 'id'): ?array
{
// Perform the database query
$rows = $this->database->rows(
["a.$get" => $get],
["a" => $this->getTable()],
["a.$key" => ['operator' => 'IN', 'value' => $values]]
);
// Check if rows are found
if ($rows !== null)
{
// Return the values from the found rows
return array_values(
array_map(
fn($row) => $row[$get],
$rows
)
);
}
// Return null if no rows are found
return null;
return $this->load->table($this->getTable())->values([
$key => [
'operator' => 'IN',
'value' => array_values($values)
]
], $get);
}
/**
@ -240,7 +226,12 @@
];
// Check for existing items.
$existingItems = $this->values($values, $key, $key);
$existingItems = $this->database->values(
["a.$key" => $key],
["a" => $this->getTable()],
["a.$key" => ['operator' => 'IN', 'value' => $values]]
);
if ($existingItems !== null)
{
$sets['update'] = $this->extractSet($items, $existingItems, $key) ?? [];

View File

@ -19,6 +19,7 @@ interface LoadInterface #Lavender {
+ max(string $field, array $tables, ...) : ?int
+ count(array $tables, array $filter) : ?int
+ value(array $select, array $tables, ...) : mixed
+ values(array $select, array $tables, ...) : ?array
}
note right of LoadInterface::rows
@ -35,7 +36,7 @@ note right of LoadInterface::rows
?int $limit = null
end note
note right of LoadInterface::items
note left of LoadInterface::items
Load data rows as an array of objects
since: 3.2.0
@ -62,7 +63,7 @@ note right of LoadInterface::row
?array $order = null
end note
note right of LoadInterface::item
note left of LoadInterface::item
Load data row as an object
since: 3.2.0
@ -87,7 +88,7 @@ note right of LoadInterface::max
array $filter
end note
note right of LoadInterface::count
note left of LoadInterface::count
Count the number of items based on filter result from a given table
since: 3.2.0
@ -106,6 +107,20 @@ note right of LoadInterface::value
?array $where = null
?array $order = null
end note
note left of LoadInterface::values
Load values from multiple rows
since: 3.2.2
return: ?array
arguments:
array $select
array $tables
?array $where = null
?array $order = null
?int $limit = null
end note
@enduml
```

View File

@ -109,6 +109,21 @@ interface LoadInterface
* @return mixed
* @since 3.2.0
**/
public function value(array $select, array $tables, ?array $where = null, ?array $order = null);
public function value(array $select, array $tables, ?array $where = null, ?array $order = null);
/**
* Load values from multiple rows
*
* @param array $select Array of selection keys
* @param array $tables Array of tables to search
* @param array|null $where Array of where key=>value match exist
* @param array|null $order Array of how to order the data
* @param int|null $limit Limit the number of values returned
*
* @return array|null
* @since 3.2.2
**/
public function values(array $select, array $tables, ?array $where = null,
?array $order = null, ?int $limit = null): ?array;
}

View File

@ -88,4 +88,19 @@
* @return mixed
* @since 3.2.0
**/
public function value(array $select, array $tables, ?array $where = null, ?array $order = null);
public function value(array $select, array $tables, ?array $where = null, ?array $order = null);
/**
* Load values from multiple rows
*
* @param array $select Array of selection keys
* @param array $tables Array of tables to search
* @param array|null $where Array of where key=>value match exist
* @param array|null $order Array of how to order the data
* @param int|null $limit Limit the number of values returned
*
* @return array|null
* @since 3.2.2
**/
public function values(array $select, array $tables, ?array $where = null,
?array $order = null, ?int $limit = null): ?array;

View File

@ -0,0 +1,54 @@
```
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# abstract class Factory (Details)
> namespace: **VDM\Joomla\Abstraction**
> extends: ****
```uml
@startuml
abstract Factory #Orange {
+ {static} _(string $key) : Mixed
+ {static} getContainer() : Container
# {abstract} {static} createContainer() : Container
}
note right of Factory::_
Get any class from the package container
since: 0.0.0
return: Mixed
end note
note right of Factory::getContainer
Get the global package container
since: 0.0.0
return: Container
end note
note right of Factory::createContainer
Create a container object
since: 0.0.0
return: Container
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)

View File

@ -0,0 +1,83 @@
<?php
/**
* @package Joomla.Component.Builder
*
* @created 4th September, 2022
* @author Llewellyn van der Merwe <https://dev.vdm.io>
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace VDM\Joomla\Abstraction;
use Joomla\DI\Container;
use VDM\Joomla\Interfaces\FactoryInterface;
/** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
**
** In realms of code where purists frown, the anti-pattern wears a crown,
** A paradox of chaos bright, where complex paths lose all its slight.
** For in its tangled, wild embrace, lies raw creativity's face,
** No rigid forms, no strict decree, just boundless, daring artistry.
** In flaws, we find the freedom's key, where messy code and brilliance spree,
** A dance of thought, unchained, unbound, in anti-pattern, beauty's found.
**
** Perfect Paradox and True Nature of the Anti-Pattern by ChatGPT
**
** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **
**
** @since 0.0.0
**/
abstract class Factory implements FactoryInterface
{
/**
* Global Package Container
*
* @var Container|null
* @since 0.0.0
**/
protected static ?Container $container = null;
/**
* Get any class from the package container
*
* @param string $key The container class key
*
* @return Mixed
* @since 0.0.0
*/
public static function _($key)
{
return static::getContainer()->get($key);
}
/**
* Get the global package container
*
* @return Container
* @since 0.0.0
*/
public static function getContainer(): Container
{
if (!static::$container)
{
static::$container = static::createContainer();
}
return static::$container;
}
/**
* Create a container object
*
* @return Container
* @since 0.0.0
*/
abstract protected static function createContainer(): Container;
}

View File

@ -0,0 +1,44 @@
/**
* Global Package Container
*
* @var Container|null
* @since 0.0.0
**/
protected static ?Container $container = null;
/**
* Get any class from the package container
*
* @param string $key The container class key
*
* @return Mixed
* @since 0.0.0
*/
public static function _($key)
{
return static::getContainer()->get($key);
}
/**
* Get the global package container
*
* @return Container
* @since 0.0.0
*/
public static function getContainer(): Container
{
if (!static::$container)
{
static::$container = static::createContainer();
}
return static::$container;
}
/**
* Create a container object
*
* @return Container
* @since 0.0.0
*/
abstract protected static function createContainer(): Container;

View File

@ -0,0 +1,21 @@
{
"add_head": "1",
"add_licensing_template": "2",
"extends": "",
"guid": "2e5bf608-de5c-4b00-a20d-47c26aa350d9",
"implements": [
"caf33c5d-858c-4f9a-894f-ab302ec5445a"
],
"load_selection": null,
"name": "Factory",
"power_version": "1.0.0",
"system_name": "VDM.Factory",
"type": "abstract class",
"use_selection": null,
"extendsinterfaces": null,
"namespace": "[[[NamespacePrefix]]]\\Joomla\\Abstraction.Factory",
"description": "\/** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **\r\n ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **\r\n **\r\n ** In realms of code where purists frown, the anti-pattern wears a crown,\r\n ** A paradox of chaos bright, where complex paths lose all its slight.\r\n ** For in its tangled, wild embrace, lies raw creativity's face,\r\n ** No rigid forms, no strict decree, just boundless, daring artistry.\r\n ** In flaws, we find the freedom's key, where messy code and brilliance spree,\r\n ** A dance of thought, unchained, unbound, in anti-pattern, beauty's found.\r\n **\r\n ** Perfect Paradox and True Nature of the Anti-Pattern by ChatGPT\r\n **\r\n ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **\r\n ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** ** **\r\n **\r\n ** @since 0.0.0\r\n **\/",
"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;",
"composer": ""
}

View File

@ -19,6 +19,7 @@ abstract Model #Orange {
+ __construct(Table $table, ?string $tableName = null, ...)
+ table(string $table) : self
+ {abstract} value(mixed $value, string $field, ...) : mixed
+ values(?array $items = null, string $field, ...) : ?array
+ item(?object $item, ?string $table = null) : ?object
+ items(?array $items = null, ?string $table = null) : ?array
+ row(?array $item, ?string $table = null) : ?array
@ -64,7 +65,20 @@ Example: $this->value(value, 'value_key', 'table_name');
?string $table = null
end note
note left of Model::item
note left of Model::values
Model a value of multiple items
Example: $this->items(Array, 'value_key', 'table_name');
since: 3.2.2
return: ?array
arguments:
?array $items = null
string $field
?string $table = null
end note
note right of Model::item
Model the values of an item
Example: $this->item(Object, 'table_name');
@ -72,7 +86,7 @@ Example: $this->item(Object, 'table_name');
return: ?object
end note
note right of Model::items
note left of Model::items
Model the values of multiple items
Example: $this->items(Array, 'table_name');
@ -80,7 +94,7 @@ Example: $this->items(Array, 'table_name');
return: ?array
end note
note left of Model::row
note right of Model::row
Model the values of an row
Example: $this->item(Array, 'table_name');
@ -88,7 +102,7 @@ Example: $this->item(Array, 'table_name');
return: ?array
end note
note right of Model::rows
note left of Model::rows
Model the values of multiple rows
Example: $this->items(Array, 'table_name');
@ -96,7 +110,7 @@ Example: $this->items(Array, 'table_name');
return: ?array
end note
note left of Model::last
note right of Model::last
Get last modeled ID
Example: $this->last('table_name');
@ -104,42 +118,42 @@ Example: $this->last('table_name');
return: ?int
end note
note right of Model::setTable
note left of Model::setTable
Set the current active table
since: 3.2.2
return: void
end note
note left of Model::setAllowEmpty
note right of Model::setAllowEmpty
Set the switch to control the behaviour of empty values
since: 3.2.2
return: void
end note
note right of Model::getTable
note left of Model::getTable
Get the current active table
since: 3.2.0
return: string
end note
note left of Model::getAllowEmpty
note right of Model::getAllowEmpty
Get the switch to control the behaviour of empty values
since: 3.2.2
return: bool
end note
note right of Model::getTableFields
note left of Model::getTableFields
Get the current active table's fields (including defaults)
since: 3.2.0
return: ?array
end note
note left of Model::validateBefore
note right of Model::validateBefore
Validate before the value is modelled (basic, override in child class)
since: 3.2.0
@ -151,7 +165,7 @@ note left of Model::validateBefore
?string $table = null
end note
note right of Model::validateAfter
note left of Model::validateAfter
Validate after the value is modelled (basic, override in child class)
since: 3.2.0

View File

@ -107,6 +107,69 @@ abstract class Model implements ModelInterface
*/
abstract public function value($value, string $field, ?string $table = null);
/**
* Model a value of multiple items
* Example: $this->items(Array, 'value_key', 'table_name');
*
* @param array|null $items The array of values
* @param string $field The field key
* @param string|null $table The table
*
* @return array|null
* @since 3.2.2
*/
public function values(?array $items = null, string $field, ?string $table = null): ?array
{
// check if this is a valid table
if (ArrayHelper::check($items))
{
// set the table name
if (empty($table))
{
$table = $this->getTable();
}
// validate if field exist in table
if (!$this->table->exist($table, $field))
{
return null;
}
// value counter
$value_number = 0;
// check if this is a valid table
$item_bucket = [];
foreach ($items as $value)
{
if (!$this->validateBefore($value, $field, $table))
{
continue;
}
$value = $this->value($value, $field, $table);
if (!$this->validateAfter($value, $field, $table))
{
continue;
}
$item_bucket[] = $value;
$value_number++;
}
// do we have any values left
if ($value_number > 0)
{
return $item_bucket;
}
}
return null;
}
/**
* Model the values of an item
* Example: $this->item(Object, 'table_name');

View File

@ -80,6 +80,69 @@
*/
abstract public function value($value, string $field, ?string $table = null);
/**
* Model a value of multiple items
* Example: $this->items(Array, 'value_key', 'table_name');
*
* @param array|null $items The array of values
* @param string $field The field key
* @param string|null $table The table
*
* @return array|null
* @since 3.2.2
*/
public function values(?array $items = null, string $field, ?string $table = null): ?array
{
// check if this is a valid table
if (ArrayHelper::check($items))
{
// set the table name
if (empty($table))
{
$table = $this->getTable();
}
// validate if field exist in table
if (!$this->table->exist($table, $field))
{
return null;
}
// value counter
$value_number = 0;
// check if this is a valid table
$item_bucket = [];
foreach ($items as $value)
{
if (!$this->validateBefore($value, $field, $table))
{
continue;
}
$value = $this->value($value, $field, $table);
if (!$this->validateAfter($value, $field, $table))
{
continue;
}
$item_bucket[] = $value;
$value_number++;
}
// do we have any values left
if ($value_number > 0)
{
return $item_bucket;
}
}
return null;
}
/**
* Model the values of an item
* Example: $this->item(Object, 'table_name');

View File

@ -6,12 +6,12 @@
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# class Subform (Details)
# final class Subform (Details)
> namespace: **VDM\Joomla\Data**
> extends: ****
```uml
@startuml
class Subform #Gold {
class Subform << (F,LightGreen) >> #RoyalBlue {
# Items $items
# string $table
+ __construct(Items $items, ?string $table = null)

View File

@ -21,7 +21,7 @@ use VDM\Joomla\Interfaces\Data\SubformInterface;
*
* @since 3.2.2
*/
class Subform implements SubformInterface
final class Subform implements SubformInterface
{
/**
* The ItemsInterface Class.

View File

@ -10,7 +10,7 @@
"name": "Subform",
"power_version": "1.0.0",
"system_name": "VDM.Data.Subform",
"type": "class",
"type": "final class",
"use_selection": {
"use_selection0": {
"use": "7212e4db-371f-4cfd-8122-32e9bb100d83",

View File

@ -14,6 +14,7 @@
interface ModelInterface #Lavender {
+ table(string $table) : self
+ value(mixed $value, string $field, ...) : mixed
+ values(?array $items = null, string $field, ...) : ?array
+ item(?object $item, ?string $table = null) : ?object
+ items(?array $items = null, ?string $table = null) : ?array
+ row(?array $item, ?string $table = null) : ?array
@ -43,7 +44,20 @@ Example: $this->value(value, 'value_key', 'table_name');
?string $table = null
end note
note right of ModelInterface::item
note right of ModelInterface::values
Model a value of multiple items
Example: $this->items(Array, 'value_key', 'table_name');
since: 3.2.0
return: ?array
arguments:
?array $items = null
string $field
?string $table = null
end note
note left of ModelInterface::item
Model the values of an item
Example: $this->item(Object, 'table_name');
@ -51,7 +65,7 @@ Example: $this->item(Object, 'table_name');
return: ?object
end note
note left of ModelInterface::items
note right of ModelInterface::items
Model the values of multiple items
Example: $this->items(Array, 'table_name');
@ -59,7 +73,7 @@ Example: $this->items(Array, 'table_name');
return: ?array
end note
note right of ModelInterface::row
note left of ModelInterface::row
Model the values of an row
Example: $this->item(Array, 'table_name');
@ -67,7 +81,7 @@ Example: $this->item(Array, 'table_name');
return: ?array
end note
note left of ModelInterface::rows
note right of ModelInterface::rows
Model the values of multiple rows
Example: $this->items(Array, 'table_name');
@ -75,7 +89,7 @@ Example: $this->items(Array, 'table_name');
return: ?array
end note
note right of ModelInterface::last
note left of ModelInterface::last
Get last modeled ID
Example: $this->last('table_name');
@ -83,14 +97,14 @@ Example: $this->last('table_name');
return: ?int
end note
note left of ModelInterface::setTable
note right of ModelInterface::setTable
Set the current active table
since: 3.2.2
return: void
end note
note right of ModelInterface::setAllowEmpty
note left of ModelInterface::setAllowEmpty
Set the switch to control the behaviour of empty values
since: 3.2.2

View File

@ -42,6 +42,19 @@ interface ModelInterface
*/
public function value($value, string $field, ?string $table = null);
/**
* Model a value of multiple items
* Example: $this->items(Array, 'value_key', 'table_name');
*
* @param array|null $items The array of values
* @param string $field The field key
* @param string|null $table The table
*
* @return array|null
* @since 3.2.0
*/
public function values(?array $items = null, string $field, ?string $table = null): ?array;
/**
* Model the values of an item
* Example: $this->item(Object, 'table_name');

View File

@ -21,6 +21,19 @@
*/
public function value($value, string $field, ?string $table = null);
/**
* Model a value of multiple items
* Example: $this->items(Array, 'value_key', 'table_name');
*
* @param array|null $items The array of values
* @param string $field The field key
* @param string|null $table The table
*
* @return array|null
* @since 3.2.0
*/
public function values(?array $items = null, string $field, ?string $table = null): ?array;
/**
* Model the values of an item
* Example: $this->item(Object, 'table_name');

View File

@ -142,22 +142,7 @@ final class Item implements ItemInterface
*/
public function value(string $value, string $key = 'guid', string $get = 'id')
{
// Perform the database query
$value = $this->database->value(
["a.$get" => $get],
["a" => $this->getTable()],
["a.$key" => $value]
);
// Check if rows are found
if ($value !== null)
{
// Return the value
return $value;
}
// Return null if no rows are found
return null;
return $this->load->table($this->getTable())->value([$key => $value], $get);
}
/**
@ -243,7 +228,13 @@ final class Item implements ItemInterface
*/
private function action(string $value, string $key): string
{
if (($id = $this->value($value, $key, 'id')) !== null && $id > 0)
$id = $this->database->value(
["a.id" => 'id'],
["a" => $this->getTable()],
["a.$key" => $value]
);
if ($id !== null && $id > 0)
{
return 'update';
}

View File

@ -113,22 +113,7 @@
*/
public function value(string $value, string $key = 'guid', string $get = 'id')
{
// Perform the database query
$value = $this->database->value(
["a.$get" => $get],
["a" => $this->getTable()],
["a.$key" => $value]
);
// Check if rows are found
if ($value !== null)
{
// Return the value
return $value;
}
// Return null if no rows are found
return null;
return $this->load->table($this->getTable())->value([$key => $value], $get);
}
/**
@ -214,7 +199,13 @@
*/
private function action(string $value, string $key): string
{
if (($id = $this->value($value, $key, 'id')) !== null && $id > 0)
$id = $this->database->value(
["a.id" => 'id'],
["a" => $this->getTable()],
["a.$key" => $value]
);
if ($id !== null && $id > 0)
{
return 'update';
}

View File

@ -0,0 +1,38 @@
```
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# abstract class Factory (Details)
> namespace: **VDM\Joomla\Data**
> extends: **ExtendingFactory**
```uml
@startuml
abstract Factory #Orange {
# {static} createContainer() : Container
}
note right of Factory::createContainer
Create a container object
since: 3.2.2
return: Container
end note
@enduml
```
---
```
██╗ ██████╗██████╗
██║██╔════╝██╔══██╗
██║██║ ██████╔╝
██ ██║██║ ██╔══██╗
╚█████╔╝╚██████╗██████╔╝
╚════╝ ╚═════╝╚═════╝
```
> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)

View File

@ -0,0 +1,46 @@
<?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\Data;
use Joomla\DI\Container;
use VDM\Joomla\Service\Table;
use VDM\Joomla\Service\Database;
use VDM\Joomla\Service\Model;
use VDM\Joomla\Service\Data;
use VDM\Joomla\Interfaces\FactoryInterface;
use VDM\Joomla\Abstraction\Factory as ExtendingFactory;
/**
* Data Factory
*
* @since 3.2.2
*/
abstract class Factory extends ExtendingFactory implements FactoryInterface
{
/**
* Create a container object
*
* @return Container
* @since 3.2.2
*/
protected static function createContainer(): Container
{
return (new Container())
->registerServiceProvider(new Table())
->registerServiceProvider(new Database())
->registerServiceProvider(new Model())
->registerServiceProvider(new Data());
}
}

View File

@ -0,0 +1,14 @@
/**
* Create a container object
*
* @return Container
* @since 3.2.2
*/
protected static function createContainer(): Container
{
return (new Container())
->registerServiceProvider(new Table())
->registerServiceProvider(new Database())
->registerServiceProvider(new Model())
->registerServiceProvider(new Data());
}

View File

@ -0,0 +1,38 @@
{
"add_head": "1",
"add_licensing_template": "2",
"extends": "2e5bf608-de5c-4b00-a20d-47c26aa350d9",
"guid": "9d76b8dc-3883-4755-b11c-131d19ca8a53",
"implements": [
"caf33c5d-858c-4f9a-894f-ab302ec5445a"
],
"load_selection": null,
"name": "Factory",
"power_version": "1.0.0",
"system_name": "VDM.Data.Factory",
"type": "abstract class",
"use_selection": {
"use_selection0": {
"use": "19b2ba92-1655-4384-acfb-979c80de8b6d",
"as": "default"
},
"use_selection1": {
"use": "4815e1c7-a433-443d-a112-d1e03d7df84b",
"as": "default"
},
"use_selection2": {
"use": "2dcedd6c-c95b-4a37-9cac-95d28faedca3",
"as": "default"
},
"use_selection3": {
"use": "a5daf189-3345-4b13-8716-c51f686f545b",
"as": "default"
}
},
"extendsinterfaces": null,
"namespace": "[[[NamespacePrefix]]]\\Joomla\\Data.Factory",
"description": "Data Factory\r\n\r\n@since 3.2.2",
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/joomla\/Component-Builder>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
"head": "use Joomla\\DI\\Container;",
"composer": ""
}

View File

@ -18,7 +18,7 @@ use VDM\Joomla\Abstraction\Schema as ExtendingSchema;
/**
* JCB Tables Schema
* Componentbuilder Tables Schema
*
* @since 3.2.1
*/

View File

@ -9,7 +9,7 @@
"load_selection": null,
"name": "Schema",
"power_version": "2.0.0",
"system_name": "JCB.Table.Schema",
"system_name": "VDM.Table.Schema",
"type": "final class",
"use_selection": {
"use_selection0": {
@ -18,8 +18,8 @@
}
},
"extendsinterfaces": null,
"namespace": "[[[NamespacePrefix]]]\\Joomla\\Componentbuilder.Table.Schema",
"description": "JCB Tables Schema\r\n\r\n@since 3.2.1",
"namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[Component]]].Table.Schema",
"description": "[[[Component]]] Tables Schema\r\n\r\n@since 3.2.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": "",
"composer": ""

View File

@ -6,12 +6,12 @@
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
```
# class Table (Details)
# final class Table (Details)
> namespace: **VDM\Joomla\Componentbuilder**
> extends: **BaseTable**
```uml
@startuml
class Table #Gold {
class Table << (F,LightGreen) >> #RoyalBlue {
}
@enduml

View File

@ -17,11 +17,11 @@ use VDM\Joomla\Abstraction\BaseTable;
/**
* JCB Tables
* Componentbuilder Tables
*
* @since 3.2.0
*/
class Table extends BaseTable implements Tableinterface
final class Table extends BaseTable implements Tableinterface
{
/**
* All areas/views/tables with their field details

View File

@ -9,12 +9,12 @@
"load_selection": null,
"name": "Table",
"power_version": "2.0.0",
"system_name": "JCB.Table",
"type": "class",
"system_name": "VDM.Table",
"type": "final class",
"use_selection": null,
"extendsinterfaces": null,
"namespace": "[[[NamespacePrefix]]]\\Joomla\\Componentbuilder.Table",
"description": "JCB Tables\r\n\r\n@since 3.2.0",
"namespace": "[[[NamespacePrefix]]]\\Joomla\\[[[Component]]].Table",
"description": "[[[Component]]] Tables\r\n\r\n@since 3.2.0",
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/joomla\/Component-Builder>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
"head": "",
"composer": ""

View File

@ -14,6 +14,7 @@
interface LoadInterface #Lavender {
+ table(?string $table) : self
+ value(array $keys, string $field) : mixed
+ values(array $keys, string $field) : ?array
+ item(array $keys) : ?object
+ items(array $keys) : ?array
+ getTable() : string
@ -38,6 +39,18 @@ Example: $this->value(
return: mixed
end note
note right of LoadInterface::values
Get a value from multiple rows from a given table
Example: $this->values(
[
'guid' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
], 'value_key'
);
since: 3.2.2
return: ?array
end note
note right of LoadInterface::item
Get values from a given table
Example: $this->item(

View File

@ -45,6 +45,22 @@ interface LoadInterface
*/
public function value(array $keys, string $field);
/**
* Get a value from multiple rows from a given table
* Example: $this->values(
* [
* 'guid' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
* ], 'value_key'
* );
*
* @param array $keys The item keys
* @param string $field The field key
*
* @return array|null
* @since 3.2.2
*/
public function values(array $keys, string $field): ?array;
/**
* Get values from a given table
* Example: $this->item(

View File

@ -24,6 +24,22 @@
*/
public function value(array $keys, string $field);
/**
* Get a value from multiple rows from a given table
* Example: $this->values(
* [
* 'guid' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
* ], 'value_key'
* );
*
* @param array $keys The item keys
* @param string $field The field key
*
* @return array|null
* @since 3.2.2
*/
public function values(array $keys, string $field): ?array;
/**
* Get values from a given table
* Example: $this->item(

View File

@ -19,14 +19,14 @@ interface FactoryInterface #Lavender {
note right of FactoryInterface::_
Get any class from the container
since: 3.2.0
since: 0.0.0
return: Mixed
end note
note right of FactoryInterface::getContainer
Get the global container
since: 3.2.0
since: 0.0.0
return: Container
end note

View File

@ -16,7 +16,9 @@ use Joomla\DI\Container;
/**
* The Container Factory Interface
* The Container Factory Interface
*
* @since 0.0.0
*/
interface FactoryInterface
{
@ -26,7 +28,7 @@ interface FactoryInterface
* @param string $key The container class key
*
* @return Mixed
* @since 3.2.0
* @since 0.0.0
*/
public static function _(string $key);
@ -34,7 +36,7 @@ interface FactoryInterface
* Get the global container
*
* @return Container
* @since 3.2.0
* @since 0.0.0
*/
public static function getContainer(): Container;
}

View File

@ -4,7 +4,7 @@
* @param string $key The container class key
*
* @return Mixed
* @since 3.2.0
* @since 0.0.0
*/
public static function _(string $key);
@ -12,6 +12,6 @@
* Get the global container
*
* @return Container
* @since 3.2.0
* @since 0.0.0
*/
public static function getContainer(): Container;

View File

@ -12,7 +12,7 @@
"use_selection": null,
"extendsinterfaces": null,
"namespace": "[[[NamespacePrefix]]]\\Joomla\\Interfaces.FactoryInterface",
"description": "The Container Factory Interface",
"description": "The Container Factory Interface\r\n\r\n@since 0.0.0",
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/joomla\/Component-Builder>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
"head": "use Joomla\\DI\\Container;",
"composer": ""

View File

@ -14,6 +14,7 @@ namespace VDM\Joomla\Utilities;
use Joomla\CMS\Factory;
use VDM\Joomla\Utilities\Component\Helper;
use VDM\Joomla\Data\Factory as Data;
/**
@ -35,6 +36,8 @@ abstract class GetHelper
*
* @return mixed string/int/float
* @since 3.0.9
*
* @deprecated 5.1 Use Data::_('Load')->table($table)->value(...)
*/
public static function var(?string $table = null, $where = null,
string $whereString = 'user', string $what = 'id',
@ -103,6 +106,8 @@ abstract class GetHelper
*
* @return array|null
* @since 3.0.9
*
* @deprecated 5.1 Use Data::_('Load')->table($table)->values(...)
*/
public static function vars(?string $table = null, $where = null,
string $whereString = 'user', string $what = 'id', string $operator = 'IN',

View File

@ -10,6 +10,8 @@
*
* @return mixed string/int/float
* @since 3.0.9
*
* @deprecated 5.1 Use Data::_('Load')->table($table)->value(...)
*/
public static function var(?string $table = null, $where = null,
string $whereString = 'user', string $what = 'id',
@ -78,6 +80,8 @@
*
* @return array|null
* @since 3.0.9
*
* @deprecated 5.1 Use Data::_('Load')->table($table)->values(...)
*/
public static function vars(?string $table = null, $where = null,
string $whereString = 'user', string $what = 'id', string $operator = 'IN',

View File

@ -20,6 +20,10 @@
"use_selection0": {
"use": "640b5352-fb09-425f-a26e-cd44eda03f15",
"as": "default"
},
"use_selection1": {
"use": "9d76b8dc-3883-4755-b11c-131d19ca8a53",
"as": "Data"
}
},
"extendsinterfaces": null,

View File

@ -98,6 +98,17 @@
"spk": "Super__152c8793_8b75_4715_996a_257b9f65451c__Power",
"guid": "152c8793-8b75-4715-996a-257b9f65451c"
},
"19b2ba92-1655-4384-acfb-979c80de8b6d": {
"name": "Table",
"type": "class",
"namespace": "VDM\\Joomla\\Service",
"code": "src\/19b2ba92-1655-4384-acfb-979c80de8b6d\/code.php",
"power": "src\/19b2ba92-1655-4384-acfb-979c80de8b6d\/code.power",
"settings": "src\/19b2ba92-1655-4384-acfb-979c80de8b6d\/settings.json",
"path": "src\/19b2ba92-1655-4384-acfb-979c80de8b6d",
"spk": "Super__19b2ba92_1655_4384_acfb_979c80de8b6d__Power",
"guid": "19b2ba92-1655-4384-acfb-979c80de8b6d"
},
"1f28cb53-60d9-4db1-b517-3c7dc6b429ef": {
"name": "StringHelper",
"type": "abstract class",
@ -164,6 +175,17 @@
"spk": "Super__2dcedd6c_c95b_4a37_9cac_95d28faedca3__Power",
"guid": "2dcedd6c-c95b-4a37-9cac-95d28faedca3"
},
"2e5bf608-de5c-4b00-a20d-47c26aa350d9": {
"name": "Factory",
"type": "abstract class",
"namespace": "VDM\\Joomla\\Abstraction",
"code": "src\/2e5bf608-de5c-4b00-a20d-47c26aa350d9\/code.php",
"power": "src\/2e5bf608-de5c-4b00-a20d-47c26aa350d9\/code.power",
"settings": "src\/2e5bf608-de5c-4b00-a20d-47c26aa350d9\/settings.json",
"path": "src\/2e5bf608-de5c-4b00-a20d-47c26aa350d9",
"spk": "Super__2e5bf608_de5c_4b00_a20d_47c26aa350d9__Power",
"guid": "2e5bf608-de5c-4b00-a20d-47c26aa350d9"
},
"30c5b4c2-f75f-4d15-869a-f8bfedd87358": {
"name": "ClassfunctionHelper",
"type": "abstract class",
@ -441,7 +463,7 @@
},
"85785701-07b2-4f81-bc1e-0f423700c254": {
"name": "Subform",
"type": "class",
"type": "final class",
"namespace": "VDM\\Joomla\\Data",
"code": "src\/85785701-07b2-4f81-bc1e-0f423700c254\/code.php",
"power": "src\/85785701-07b2-4f81-bc1e-0f423700c254\/code.power",
@ -527,6 +549,17 @@
"spk": "Super__9c513baf_b279_43fd_ae29_a585c8cbc4f0__Power",
"guid": "9c513baf-b279-43fd-ae29-a585c8cbc4f0"
},
"9d76b8dc-3883-4755-b11c-131d19ca8a53": {
"name": "Factory",
"type": "abstract class",
"namespace": "VDM\\Joomla\\Data",
"code": "src\/9d76b8dc-3883-4755-b11c-131d19ca8a53\/code.php",
"power": "src\/9d76b8dc-3883-4755-b11c-131d19ca8a53\/code.power",
"settings": "src\/9d76b8dc-3883-4755-b11c-131d19ca8a53\/settings.json",
"path": "src\/9d76b8dc-3883-4755-b11c-131d19ca8a53",
"spk": "Super__9d76b8dc_3883_4755_b11c_131d19ca8a53__Power",
"guid": "9d76b8dc-3883-4755-b11c-131d19ca8a53"
},
"9ef0eb24-aae4-4f5a-99af-d724db44808f": {
"name": "FieldHelper",
"type": "abstract class",
@ -639,7 +672,7 @@
},
"bfd1d6d5-56c1-4fe9-9fee-1c5910e1f5d8": {
"name": "Table",
"type": "class",
"type": "final class",
"namespace": "VDM\\Joomla\\Componentbuilder",
"code": "src\/bfd1d6d5-56c1-4fe9-9fee-1c5910e1f5d8\/code.php",
"power": "src\/bfd1d6d5-56c1-4fe9-9fee-1c5910e1f5d8\/code.power",