Release of v3.2.2-alpha5
Add repositories for better integration with gitea. Refactored the Data classes. Add new Data classes.
This commit is contained in:
112
libraries/vendor_jcb/VDM.Joomla/src/Data/Action/Delete.php
Normal file
112
libraries/vendor_jcb/VDM.Joomla/src/Data/Action/Delete.php
Normal file
@@ -0,0 +1,112 @@
|
||||
<?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\Action;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\DeleteInterface as Database;
|
||||
use VDM\Joomla\Interfaces\Data\DeleteInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Data Delete
|
||||
*
|
||||
* @since 3.2.2
|
||||
*/
|
||||
class Delete implements DeleteInterface
|
||||
{
|
||||
/**
|
||||
* The Delete Class.
|
||||
*
|
||||
* @var Database
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected Database $database;
|
||||
|
||||
/**
|
||||
* Table Name
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected string $table;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Database $database The Delete Class.
|
||||
* @param string|null $table The table name.
|
||||
*
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function __construct(Database $database, ?string $table = null)
|
||||
{
|
||||
$this->database = $database;
|
||||
if ($table !== null)
|
||||
{
|
||||
$this->table = $table;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current active table
|
||||
*
|
||||
* @param string|null $table The table that should be active
|
||||
*
|
||||
* @return self
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function table(?string $table): self
|
||||
{
|
||||
if ($table !== null)
|
||||
{
|
||||
$this->table = $table;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all items in the database that match these conditions
|
||||
*
|
||||
* @param array $conditions Conditions by which to delete the data in database [array of arrays (key => value)]
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.2
|
||||
**/
|
||||
public function items(array $conditions): bool
|
||||
{
|
||||
return $this->database->items($conditions, $this->getTable());
|
||||
}
|
||||
|
||||
/**
|
||||
* Truncate a table
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.2
|
||||
**/
|
||||
public function truncate(): void
|
||||
{
|
||||
$this->database->truncate($this->getTable());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current active table
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function getTable(): string
|
||||
{
|
||||
return $this->table;
|
||||
}
|
||||
}
|
||||
|
202
libraries/vendor_jcb/VDM.Joomla/src/Data/Action/Insert.php
Normal file
202
libraries/vendor_jcb/VDM.Joomla/src/Data/Action/Insert.php
Normal file
@@ -0,0 +1,202 @@
|
||||
<?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\Action;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\ModelInterface as Model;
|
||||
use VDM\Joomla\Interfaces\InsertInterface as Database;
|
||||
use VDM\Joomla\Interfaces\Data\InsertInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Data Insert (GUID)
|
||||
*
|
||||
* @since 3.2.2
|
||||
*/
|
||||
class Insert implements InsertInterface
|
||||
{
|
||||
/**
|
||||
* Model
|
||||
*
|
||||
* @var Model
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Model $model;
|
||||
|
||||
/**
|
||||
* Database
|
||||
*
|
||||
* @var Database
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Database $database;
|
||||
|
||||
/**
|
||||
* Table Name
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.1
|
||||
*/
|
||||
protected string $table;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Model $model The set model object.
|
||||
* @param Database $database The insert database object.
|
||||
* @param string|null $table The table name.
|
||||
*
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function __construct(Model $model, Database $database, ?string $table = null)
|
||||
{
|
||||
$this->model = $model;
|
||||
$this->database = $database;
|
||||
if ($table !== null)
|
||||
{
|
||||
$this->table = $table;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current active table
|
||||
*
|
||||
* @param string|null $table The table that should be active
|
||||
*
|
||||
* @return self
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function table(?string $table): self
|
||||
{
|
||||
if ($table !== null)
|
||||
{
|
||||
$this->table = $table;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a value to a given table
|
||||
* Example: $this->value(Value, 'value_key', 'GUID');
|
||||
*
|
||||
* @param mixed $value The field value
|
||||
* @param string $field The field key
|
||||
* @param string $keyValue The key value
|
||||
* @param string $key The key name
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function value($value, string $field, string $keyValue, string $key = 'guid'): bool
|
||||
{
|
||||
// build the array
|
||||
$item = [];
|
||||
$item[$key] = $keyValue;
|
||||
$item[$field] = $value;
|
||||
|
||||
// Insert the column of this table
|
||||
return $this->row($item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert single row with multiple values to a given table
|
||||
* Example: $this->item(Array);
|
||||
*
|
||||
* @param array $item The item to save
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function row(array $item): bool
|
||||
{
|
||||
// check if object could be modelled
|
||||
if (($item = $this->model->row($item, $this->getTable())) !== null)
|
||||
{
|
||||
// Insert the column of this table
|
||||
return $this->database->row($item, $this->getTable());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert multiple rows to a given table
|
||||
* Example: $this->items(Array);
|
||||
*
|
||||
* @param array|null $items The items updated in database (array of arrays)
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function rows(?array $items): bool
|
||||
{
|
||||
// check if object could be modelled
|
||||
if (($items = $this->model->rows($items, $this->getTable())) !== null)
|
||||
{
|
||||
// Insert the column of this table
|
||||
return $this->database->rows($items, $this->getTable());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert single item with multiple values to a given table
|
||||
* Example: $this->item(Object);
|
||||
*
|
||||
* @param object $item The item to save
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function item(object $item): bool
|
||||
{
|
||||
// check if object could be modelled
|
||||
if (($item = $this->model->item($item, $this->getTable())) !== null)
|
||||
{
|
||||
// Insert the column of this table
|
||||
return $this->database->item($item, $this->getTable());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert multiple items to a given table
|
||||
* Example: $this->items(Array);
|
||||
*
|
||||
* @param array|null $items The items updated in database (array of objects)
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function items(?array $items): bool
|
||||
{
|
||||
// check if object could be modelled
|
||||
if (($items = $this->model->items($items, $this->getTable())) !== null)
|
||||
{
|
||||
// Update the column of this table using guid as the primary key.
|
||||
return $this->database->items($items, $this->getTable());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current active table
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function getTable(): string
|
||||
{
|
||||
return $this->table;
|
||||
}
|
||||
}
|
||||
|
197
libraries/vendor_jcb/VDM.Joomla/src/Data/Action/Load.php
Normal file
197
libraries/vendor_jcb/VDM.Joomla/src/Data/Action/Load.php
Normal file
@@ -0,0 +1,197 @@
|
||||
<?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\Action;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\ModelInterface as Model;
|
||||
use VDM\Joomla\Interfaces\LoadInterface as Database;
|
||||
use VDM\Joomla\Interfaces\Data\LoadInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Data Load (GUID)
|
||||
*
|
||||
* @since 3.2.2
|
||||
*/
|
||||
class Load implements LoadInterface
|
||||
{
|
||||
/**
|
||||
* Model Load
|
||||
*
|
||||
* @var Model
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected Model $model;
|
||||
|
||||
/**
|
||||
* Database Load
|
||||
*
|
||||
* @var Database
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected Database $load;
|
||||
|
||||
/**
|
||||
* Table Name
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.1
|
||||
*/
|
||||
protected string $table;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Model $model The model object.
|
||||
* @param Database $load The database object.
|
||||
* @param string|null $table The table name.
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function __construct(Model $model, Database $load, ?string $table = null)
|
||||
{
|
||||
$this->model = $model;
|
||||
$this->load = $load;
|
||||
if ($table !== null)
|
||||
{
|
||||
$this->table = $table;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current active table
|
||||
*
|
||||
* @param string|null $table The table that should be active
|
||||
*
|
||||
* @return self
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function table(?string $table): self
|
||||
{
|
||||
if ($table !== null)
|
||||
{
|
||||
$this->table = $table;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a value from a given table
|
||||
* Example: $this->value(
|
||||
* [
|
||||
* 'guid' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
|
||||
* ], 'value_key'
|
||||
* );
|
||||
*
|
||||
* @param array $keys The item keys
|
||||
* @param string $field The field key
|
||||
*
|
||||
* @return mixed
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function value(array $keys, string $field)
|
||||
{
|
||||
return $this->model->value(
|
||||
$this->load->value(
|
||||
["a.{$field}" => $field],
|
||||
['a' => $this->getTable()],
|
||||
$this->prefix($keys)
|
||||
),
|
||||
$field,
|
||||
$this->getTable()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get values from a given table
|
||||
* Example: $this->item(
|
||||
* [
|
||||
* 'guid' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
|
||||
* ]
|
||||
* );
|
||||
*
|
||||
* @param array $keys The item keys
|
||||
*
|
||||
* @return object|null
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function item(array $keys): ?object
|
||||
{
|
||||
return $this->model->item(
|
||||
$this->load->item(
|
||||
['all' => 'a.*'],
|
||||
['a' => $this->getTable()],
|
||||
$this->prefix($keys)
|
||||
),
|
||||
$this->getTable()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get values from a given table
|
||||
* Example: $this->items(
|
||||
* [
|
||||
* 'guid' => [
|
||||
* 'operator' => 'IN',
|
||||
* 'value' => [''xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'', ''xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'']
|
||||
* ]
|
||||
* ]
|
||||
* );
|
||||
* Example: $this->items($ids);
|
||||
*
|
||||
* @param array $keys The item keys
|
||||
*
|
||||
* @return array|null
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function items(array $keys): ?array
|
||||
{
|
||||
return $this->model->items(
|
||||
$this->load->items(
|
||||
['all' => 'a.*'], ['a' => $this->getTable()], $this->prefix($keys)
|
||||
),
|
||||
$this->getTable()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current active table
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function getTable(): string
|
||||
{
|
||||
return $this->table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add prefix to the keys
|
||||
*
|
||||
* @param array $keys The query keys
|
||||
*
|
||||
* @return array
|
||||
* @since 2.0.1
|
||||
*/
|
||||
private function prefix(array &$keys): array
|
||||
{
|
||||
// update the key values
|
||||
$bucket = [];
|
||||
foreach ($keys as $k => $v)
|
||||
{
|
||||
$bucket['a.' . $k] = $v;
|
||||
}
|
||||
return $bucket;
|
||||
}
|
||||
}
|
||||
|
206
libraries/vendor_jcb/VDM.Joomla/src/Data/Action/Update.php
Normal file
206
libraries/vendor_jcb/VDM.Joomla/src/Data/Action/Update.php
Normal file
@@ -0,0 +1,206 @@
|
||||
<?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\Action;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\ModelInterface as Model;
|
||||
use VDM\Joomla\Interfaces\UpdateInterface as Database;
|
||||
use VDM\Joomla\Interfaces\Data\UpdateInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Data Update
|
||||
*
|
||||
* @since 3.2.2
|
||||
*/
|
||||
class Update implements UpdateInterface
|
||||
{
|
||||
/**
|
||||
* Model
|
||||
*
|
||||
* @var Model
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Model $model;
|
||||
|
||||
/**
|
||||
* Database
|
||||
*
|
||||
* @var Database
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Database $database;
|
||||
|
||||
/**
|
||||
* Table Name
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.1
|
||||
*/
|
||||
protected string $table;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Model $model The set model object.
|
||||
* @param Database $database The update database object.
|
||||
* @param string|null $table The table name.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(Model $model, Database $database, ?string $table = null)
|
||||
{
|
||||
$this->model = $model;
|
||||
$this->database = $database;
|
||||
if ($table !== null)
|
||||
{
|
||||
$this->table = $table;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current active table
|
||||
*
|
||||
* @param string|null $table The table that should be active
|
||||
*
|
||||
* @return self
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function table(?string $table): self
|
||||
{
|
||||
if ($table !== null)
|
||||
{
|
||||
$this->table = $table;
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a value to a given table
|
||||
* Example: $this->value(Value, 'value_key', 'GUID');
|
||||
*
|
||||
* @param mixed $value The field value
|
||||
* @param string $field The field key
|
||||
* @param string $keyValue The key value
|
||||
* @param string $key The key name
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function value($value, string $field, string $keyValue, string $key = 'guid'): bool
|
||||
{
|
||||
// build the array
|
||||
$item = [];
|
||||
$item[$key] = $keyValue;
|
||||
$item[$field] = $value;
|
||||
|
||||
// Update the column of this table using $key as the primary key.
|
||||
return $this->row($item, $key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update single row with multiple values to a given table
|
||||
* Example: $this->item(Array);
|
||||
*
|
||||
* @param array $item The item to save
|
||||
* @param string $key The key name
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function row(array $item, string $key = 'guid'): bool
|
||||
{
|
||||
// check if object could be modelled
|
||||
if (($item = $this->model->row($item, $this->getTable())) !== null)
|
||||
{
|
||||
// Update the column of this table using $key as the primary key.
|
||||
return $this->database->row($item, $key, $this->getTable());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update multiple rows to a given table
|
||||
* Example: $this->items(Array);
|
||||
*
|
||||
* @param array|null $items The items updated in database (array of arrays)
|
||||
* @param string $key The key name
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function rows(?array $items, string $key = 'guid'): bool
|
||||
{
|
||||
// check if object could be modelled
|
||||
if (($items = $this->model->rows($items, $this->getTable())) !== null)
|
||||
{
|
||||
// Update the column of this table using $key as the primary key.
|
||||
return $this->database->rows($items, $key, $this->getTable());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update single item with multiple values to a given table
|
||||
* Example: $this->item(Object);
|
||||
*
|
||||
* @param object $item The item to save
|
||||
* @param string $key The key name
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function item(object $item, string $key = 'guid'): bool
|
||||
{
|
||||
// check if object could be modelled
|
||||
if (($item = $this->model->item($item, $this->getTable())) !== null)
|
||||
{
|
||||
// Update the column of this table using $key as the primary key.
|
||||
return $this->database->item($item, $key, $this->getTable());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update multiple items to a given table
|
||||
* Example: $this->items(Array);
|
||||
*
|
||||
* @param array|null $items The items updated in database (array of objects)
|
||||
* @param string $key The key name
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function items(?array $items, string $key = 'guid'): bool
|
||||
{
|
||||
// check if object could be modelled
|
||||
if (($items = $this->model->items($items, $this->getTable())) !== null)
|
||||
{
|
||||
// Update the column of this table using $key as the primary key.
|
||||
return $this->database->items($items, $key, $this->getTable());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current active table
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function getTable(): string
|
||||
{
|
||||
return $this->table;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
Reference in New Issue
Block a user