Release of v5.0.0-beta4
Add fallback option to ensure that all JCB tables and fields exist. Move the powers autoloader to its own file.
This commit is contained in:
@ -34,7 +34,7 @@ abstract class BaseTable implements Tableinterface
|
||||
* All default fields
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.0
|
||||
* @since 3.2.1
|
||||
**/
|
||||
protected array $defaults = [
|
||||
'id' => [
|
||||
@ -45,7 +45,29 @@ abstract class BaseTable implements Tableinterface
|
||||
'title' => false,
|
||||
'list' => NULL,
|
||||
'store' => NULL,
|
||||
'tab_name' => NULL
|
||||
'tab_name' => NULL,
|
||||
'db' => [
|
||||
'type' => 'INT(11)',
|
||||
'default' => '',
|
||||
'auto_increment' => true,
|
||||
'primary_key' => true,
|
||||
'null_switch' => 'NOT NULL'
|
||||
]
|
||||
],
|
||||
'asset_id' => [
|
||||
'name' => 'asset_id',
|
||||
'label' => NULL,
|
||||
'type' => NULL,
|
||||
'title' => false,
|
||||
'list' => NULL,
|
||||
'store' => NULL,
|
||||
'tab_name' => NULL,
|
||||
'db' => [
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'null_switch' => 'NOT NULL',
|
||||
'comment' => 'FK to the #__assets table.'
|
||||
]
|
||||
],
|
||||
'ordering' => [
|
||||
'name' => 'ordering',
|
||||
@ -54,7 +76,12 @@ abstract class BaseTable implements Tableinterface
|
||||
'title' => false,
|
||||
'list' => NULL,
|
||||
'store' => NULL,
|
||||
'tab_name' => NULL
|
||||
'tab_name' => NULL,
|
||||
'db' => [
|
||||
'type' => 'INT(11)',
|
||||
'default' => '0',
|
||||
'null_switch' => 'NOT NULL'
|
||||
]
|
||||
],
|
||||
'published' => [
|
||||
'name' => 'published',
|
||||
@ -63,7 +90,14 @@ abstract class BaseTable implements Tableinterface
|
||||
'title' => false,
|
||||
'list' => NULL,
|
||||
'store' => NULL,
|
||||
'tab_name' => NULL
|
||||
'tab_name' => NULL,
|
||||
'db' => [
|
||||
'type' => 'TINYINT(3)',
|
||||
'default' => '1',
|
||||
'null_switch' => 'NOT NULL',
|
||||
'key' => true,
|
||||
'key_name' => 'state'
|
||||
]
|
||||
],
|
||||
'modified_by' => [
|
||||
'name' => 'modified_by',
|
||||
@ -72,7 +106,14 @@ abstract class BaseTable implements Tableinterface
|
||||
'title' => false,
|
||||
'list' => NULL,
|
||||
'store' => NULL,
|
||||
'tab_name' => NULL
|
||||
'tab_name' => NULL,
|
||||
'db' => [
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'null_switch' => 'NOT NULL',
|
||||
'key' => true,
|
||||
'key_name' => 'modifiedby'
|
||||
]
|
||||
],
|
||||
'modified' => [
|
||||
'name' => 'modified',
|
||||
@ -81,7 +122,12 @@ abstract class BaseTable implements Tableinterface
|
||||
'title' => false,
|
||||
'list' => NULL,
|
||||
'store' => NULL,
|
||||
'tab_name' => NULL
|
||||
'tab_name' => NULL,
|
||||
'db' => [
|
||||
'type' => 'DATETIME',
|
||||
'default' => '0000-00-00 00:00:00',
|
||||
'null_switch' => 'NOT NULL'
|
||||
]
|
||||
],
|
||||
'created_by' => [
|
||||
'name' => 'created_by',
|
||||
@ -90,7 +136,14 @@ abstract class BaseTable implements Tableinterface
|
||||
'title' => false,
|
||||
'list' => NULL,
|
||||
'store' => NULL,
|
||||
'tab_name' => NULL
|
||||
'tab_name' => NULL,
|
||||
'db' => [
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'null_switch' => 'NOT NULL',
|
||||
'key' => true,
|
||||
'key_name' => 'createdby'
|
||||
]
|
||||
],
|
||||
'created' => [
|
||||
'name' => 'created',
|
||||
@ -99,7 +152,42 @@ abstract class BaseTable implements Tableinterface
|
||||
'title' => false,
|
||||
'list' => NULL,
|
||||
'store' => NULL,
|
||||
'tab_name' => NULL
|
||||
'tab_name' => NULL,
|
||||
'db' => [
|
||||
'type' => 'DATETIME',
|
||||
'default' => '0000-00-00 00:00:00',
|
||||
'null_switch' => 'NOT NULL'
|
||||
]
|
||||
],
|
||||
'checked_out' => [
|
||||
'name' => 'checked_out',
|
||||
'label' => NULL,
|
||||
'type' => NULL,
|
||||
'title' => false,
|
||||
'list' => NULL,
|
||||
'store' => NULL,
|
||||
'tab_name' => NULL,
|
||||
'db' => [
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'null_switch' => 'NOT NULL',
|
||||
'key' => true,
|
||||
'key_name' => 'checkout'
|
||||
]
|
||||
],
|
||||
'checked_out_time' => [
|
||||
'name' => 'checked_out_time',
|
||||
'label' => NULL,
|
||||
'type' => NULL,
|
||||
'title' => false,
|
||||
'list' => NULL,
|
||||
'store' => NULL,
|
||||
'tab_name' => NULL,
|
||||
'db' => [
|
||||
'type' => 'DATETIME',
|
||||
'default' => '0000-00-00 00:00:00',
|
||||
'null_switch' => 'NOT NULL'
|
||||
]
|
||||
],
|
||||
'hits' => [
|
||||
'name' => 'hits',
|
||||
@ -108,7 +196,12 @@ abstract class BaseTable implements Tableinterface
|
||||
'title' => false,
|
||||
'list' => NULL,
|
||||
'store' => NULL,
|
||||
'tab_name' => NULL
|
||||
'tab_name' => NULL,
|
||||
'db' => [
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'null_switch' => 'NOT NULL'
|
||||
]
|
||||
],
|
||||
'version' => [
|
||||
'name' => 'version',
|
||||
@ -117,7 +210,26 @@ abstract class BaseTable implements Tableinterface
|
||||
'title' => false,
|
||||
'list' => NULL,
|
||||
'store' => NULL,
|
||||
'tab_name' => NULL
|
||||
'tab_name' => NULL,
|
||||
'db' => [
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '1',
|
||||
'null_switch' => 'NOT NULL'
|
||||
]
|
||||
],
|
||||
'params' => [
|
||||
'name' => 'params',
|
||||
'label' => NULL,
|
||||
'type' => NULL,
|
||||
'title' => false,
|
||||
'list' => NULL,
|
||||
'store' => 'json',
|
||||
'tab_name' => NULL,
|
||||
'db' => [
|
||||
'type' => 'TEXT',
|
||||
'default' => '',
|
||||
'null_switch' => 'NULL'
|
||||
]
|
||||
]
|
||||
];
|
||||
|
||||
@ -130,48 +242,41 @@ abstract class BaseTable implements Tableinterface
|
||||
* Example: $this->get('table_name');
|
||||
* Get all areas/views/tables with all their item/field/column details
|
||||
* Example: $this->get('All');
|
||||
* Example: $this->get();
|
||||
*
|
||||
* @param string $table The table
|
||||
* @param string|null $table The table
|
||||
* @param string|null $field The field
|
||||
* @param string|null $key The value key
|
||||
*
|
||||
* @return mixed
|
||||
* @since 3.2.0
|
||||
* @since 3.2.1
|
||||
*/
|
||||
public function get(string $table, ?string $field = null, ?string $key = null)
|
||||
public function get(?string $table = null, ?string $field = null, ?string $key = null)
|
||||
{
|
||||
// return the item/field/column of an area/view/table
|
||||
if (is_string($field) && is_string($key))
|
||||
// Return specific value
|
||||
if ($table && $field && $key)
|
||||
{
|
||||
// return the value of a item/field/column of an area/view/table
|
||||
if (isset($this->tables[$table][$field][$key]))
|
||||
{
|
||||
return $this->tables[$table][$field][$key];
|
||||
}
|
||||
|
||||
return $this->getDefaultKey($field, $key);
|
||||
}
|
||||
// return the item/field/column of an area/view/table
|
||||
elseif (is_string($field))
|
||||
{
|
||||
if (isset($this->tables[$table][$field]))
|
||||
{
|
||||
return $this->tables[$table][$field];
|
||||
}
|
||||
|
||||
return $this->getDefault($field);
|
||||
}
|
||||
// return an area/view/table
|
||||
elseif ($table !== 'All')
|
||||
{
|
||||
if (isset($this->tables[$table]))
|
||||
{
|
||||
return $this->tables[$table];
|
||||
}
|
||||
return null;
|
||||
return $this->tables[$table][$field][$key] ?? $this->getDefaultKey($field, $key);
|
||||
}
|
||||
|
||||
// return all
|
||||
// Return field within table
|
||||
if ($table && $field)
|
||||
{
|
||||
return $this->tables[$table][$field] ?? $this->getDefault($field);
|
||||
}
|
||||
|
||||
// Return all fields in a table or all tables if 'All' is passed
|
||||
if ($table)
|
||||
{
|
||||
if (strtoupper($table) === 'ALL')
|
||||
{
|
||||
return $this->tables;
|
||||
}
|
||||
|
||||
return $this->tables[$table] ?? null;
|
||||
}
|
||||
|
||||
// Return all tables
|
||||
return $this->tables;
|
||||
}
|
||||
|
||||
@ -268,27 +373,30 @@ abstract class BaseTable implements Tableinterface
|
||||
*
|
||||
* @param string $table The area
|
||||
* @param bool $default Add the default fields
|
||||
* @param bool $details Add/Leave fields the details
|
||||
*
|
||||
* @return array|null On success an array of fields
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function fields(string $table, bool $default = false): ?array
|
||||
public function fields(string $table, bool $default = false, bool $details = false): ?array
|
||||
{
|
||||
// return all fields of an area/view/table
|
||||
if (($table = $this->get($table)) !== null)
|
||||
// Retrieve fields from the specified table
|
||||
$fields = $this->get($table);
|
||||
|
||||
if ($fields === null)
|
||||
{
|
||||
if ($default)
|
||||
{
|
||||
return $this->addDefault(array_keys($table));
|
||||
}
|
||||
else
|
||||
{
|
||||
return array_keys($table);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// none found
|
||||
return null;
|
||||
// Determine the fields output based on the $default and $details flags
|
||||
if ($details)
|
||||
{
|
||||
return $default ? $this->addDefaultDetails($fields) : $fields;
|
||||
}
|
||||
|
||||
$fieldKeys = array_keys($fields);
|
||||
|
||||
return $default ? $this->addDefault($fieldKeys) : $fieldKeys;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -304,6 +412,11 @@ abstract class BaseTable implements Tableinterface
|
||||
// add default fields
|
||||
foreach ($this->defaults as $default)
|
||||
{
|
||||
if (in_array($default['name'], $fields))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// used just for loading the fields
|
||||
$order = $default['order'] ?? 1;
|
||||
unset($default['order']);
|
||||
@ -321,6 +434,31 @@ abstract class BaseTable implements Tableinterface
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the default fields
|
||||
*
|
||||
* @param array $fields The table dynamic fields
|
||||
*
|
||||
* @return array Fields (with defaults details added)
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function addDefaultDetails(array $fields): array
|
||||
{
|
||||
// add default fields
|
||||
foreach ($this->defaults as $default)
|
||||
{
|
||||
// remove ordering for now
|
||||
unset($default['order']);
|
||||
|
||||
if (!isset($fields[$default['name']]))
|
||||
{
|
||||
$fields[$default['name']] = $default;
|
||||
}
|
||||
}
|
||||
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the field is a default field
|
||||
*
|
||||
@ -353,10 +491,10 @@ abstract class BaseTable implements Tableinterface
|
||||
* @param string $field The field to check
|
||||
* @param string $key The field key/property to check
|
||||
*
|
||||
* @return string|null String value if a default field property exist
|
||||
* @return mixed String value if a default field property exist
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getDefaultKey(string $field, string $key): ?string
|
||||
protected function getDefaultKey(string $field, string $key)
|
||||
{
|
||||
return $this->defaults[$field][$key] ?? null;
|
||||
}
|
||||
|
@ -41,10 +41,10 @@ abstract class Registry extends ActiveRegistry implements Activeregistryinterfac
|
||||
* @param mixed $value Value of entry
|
||||
*
|
||||
* @throws \InvalidArgumentException If any of the path values are not a number or string.
|
||||
* @return void
|
||||
* @return $this
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function set(string $path, $value): void
|
||||
public function set(string $path, $value): static
|
||||
{
|
||||
if (($keys = $this->getActiveKeys($path)) === null)
|
||||
{
|
||||
@ -52,6 +52,8 @@ abstract class Registry extends ActiveRegistry implements Activeregistryinterfac
|
||||
}
|
||||
|
||||
$this->setActive($value, ...$keys);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -65,10 +67,10 @@ abstract class Registry extends ActiveRegistry implements Activeregistryinterfac
|
||||
* Override in child class allowed set class property $addAsArray = true.
|
||||
*
|
||||
* @throws \InvalidArgumentException If any of the path values are not a number or string.
|
||||
* @return void
|
||||
* @return $this
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function add(string $path, $value, ?bool $asArray = null): void
|
||||
public function add(string $path, $value, ?bool $asArray = null): static
|
||||
{
|
||||
if (($keys = $this->getActiveKeys($path)) === null)
|
||||
{
|
||||
@ -76,6 +78,8 @@ abstract class Registry extends ActiveRegistry implements Activeregistryinterfac
|
||||
}
|
||||
|
||||
$this->addActive($value, $asArray, ...$keys);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -104,10 +108,10 @@ abstract class Registry extends ActiveRegistry implements Activeregistryinterfac
|
||||
* @param string $path Registry path (e.g. vdm.content.builder)
|
||||
*
|
||||
* @throws \InvalidArgumentException If any of the path values are not a number or string.
|
||||
* @return void
|
||||
* @return $this
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function remove(string $path): void
|
||||
public function remove(string $path): static
|
||||
{
|
||||
if (($keys = $this->getActiveKeys($path)) === null)
|
||||
{
|
||||
@ -115,6 +119,8 @@ abstract class Registry extends ActiveRegistry implements Activeregistryinterfac
|
||||
}
|
||||
|
||||
$this->removeActive(...$keys);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -141,12 +147,14 @@ abstract class Registry extends ActiveRegistry implements Activeregistryinterfac
|
||||
*
|
||||
* @param string|null $value The value to set.
|
||||
*
|
||||
* @return void
|
||||
* @return $this
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function setSeparator(?string $value): void
|
||||
public function setSeparator(?string $value): static
|
||||
{
|
||||
$this->separator = $value;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
|
419
libraries/vendor_jcb/VDM.Joomla/src/Abstraction/Schema.php
Normal file
419
libraries/vendor_jcb/VDM.Joomla/src/Abstraction/Schema.php
Normal file
@ -0,0 +1,419 @@
|
||||
<?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\CMS\Factory;
|
||||
use VDM\Joomla\Interfaces\Tableinterface as Table;
|
||||
use VDM\Joomla\Interfaces\SchemaInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Schema Checking
|
||||
*
|
||||
* @since 3.2.1
|
||||
*/
|
||||
abstract class Schema implements SchemaInterface
|
||||
{
|
||||
/**
|
||||
* The Table Class.
|
||||
*
|
||||
* @var Table
|
||||
* @since 3.2.1
|
||||
*/
|
||||
protected Table $table;
|
||||
|
||||
/**
|
||||
* The Database Class
|
||||
*
|
||||
* @since 3.2.1
|
||||
*/
|
||||
protected $db;
|
||||
|
||||
/**
|
||||
* The local tables
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.1
|
||||
*/
|
||||
private array $tables;
|
||||
|
||||
/**
|
||||
* The component table prefix
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.1
|
||||
*/
|
||||
private string $prefix;
|
||||
|
||||
/**
|
||||
* The field unique keys
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.1
|
||||
*/
|
||||
private array $uniqueKeys;
|
||||
|
||||
/**
|
||||
* The field keys
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.1
|
||||
*/
|
||||
private array $keys;
|
||||
|
||||
/**
|
||||
* The success messages of the action
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.1
|
||||
*/
|
||||
private array $success;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Table $table The Table Class.
|
||||
*
|
||||
* @since 3.2.1
|
||||
* @throws \Exception If the database fails
|
||||
*/
|
||||
public function __construct(Table $table)
|
||||
{
|
||||
$this->table = $table;
|
||||
|
||||
try {
|
||||
// set the database object
|
||||
$this->db = Factory::getDbo();
|
||||
|
||||
// get current component tables
|
||||
$this->tables = $this->db->getTableList();
|
||||
|
||||
// set the component table
|
||||
$this->prefix = $this->db->getPrefix() . $this->getCode();
|
||||
} catch (\Exception $e) {
|
||||
throw new \Exception("Error: failed to initialize schema class due to a database error.", 0, $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check and update database schema for missing fields or tables.
|
||||
*
|
||||
* @return array The array of successful updates/actions, if empty no update/action was taken.
|
||||
* @since 3.2.1
|
||||
* @throws \Exception If there is an error during the update process.
|
||||
*/
|
||||
public function update(): array
|
||||
{
|
||||
try {
|
||||
$this->success = [
|
||||
"Success: scan of the component tables started."
|
||||
];
|
||||
|
||||
foreach ($this->table->tables() as $table)
|
||||
{
|
||||
$this->uniqueKeys = [];
|
||||
$this->keys = [];
|
||||
|
||||
if (!$this->tableExists($table))
|
||||
{
|
||||
$this->createTable($table);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->updateSchema($table);
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw new \Exception("Error: updating database schema.", 0, $e);
|
||||
}
|
||||
|
||||
if (count($this->success) == 1)
|
||||
{
|
||||
$this->success[] = "Success: scan of the component tables completed with no update needed.";
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->success[] = "Success: scan of the component tables completed.";
|
||||
}
|
||||
|
||||
return $this->success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a table with all necessary fields.
|
||||
*
|
||||
* @param string $table The name of the table to create.
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.1
|
||||
* @throws \Exception If there is an error creating the table.
|
||||
*/
|
||||
public function createTable(string $table): void
|
||||
{
|
||||
try {
|
||||
$columns = [];
|
||||
$fields = $this->table->fields($table, true);
|
||||
$createTable = 'CREATE TABLE IF NOT EXISTS ' . $this->db->quoteName($this->getTable($table));
|
||||
|
||||
foreach ($fields as $field)
|
||||
{
|
||||
if (($def = $this->getColumnDefinition($table, $field)) !== null)
|
||||
{
|
||||
$columns[] = $def;
|
||||
}
|
||||
}
|
||||
|
||||
$columnDefinitions = implode(', ', $columns);
|
||||
|
||||
$keys = $this->getTableKeys();
|
||||
|
||||
$createTableSql = "$createTable ($columnDefinitions, $keys)";
|
||||
|
||||
$this->db->setQuery($createTableSql);
|
||||
$this->db->execute();
|
||||
} catch (\Exception $e) {
|
||||
throw new \Exception("Error: failed to create missing $table table.", 0, $e);
|
||||
}
|
||||
|
||||
$this->success[] = "Success: created missing $table table.";
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the schema of an existing table.
|
||||
*
|
||||
* @param string $table The table to update.
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.1
|
||||
* @throws \Exception If there is an error while updating the schema.
|
||||
*/
|
||||
public function updateSchema(string $table): void
|
||||
{
|
||||
try {
|
||||
$existingColumns = $this->getExistingColumns($table);
|
||||
$expectedColumns = $this->table->fields($table, true);
|
||||
|
||||
$missingColumns = array_diff($expectedColumns, $existingColumns);
|
||||
|
||||
if (!empty($missingColumns))
|
||||
{
|
||||
$this->addMissingColumns($table, $missingColumns);
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
throw new \Exception("Error: updating schema for $table table.", 0, $e);
|
||||
}
|
||||
|
||||
if (!empty($missingColumns))
|
||||
{
|
||||
$columns = (count($missingColumns) == 1) ? 'column' : 'columns';
|
||||
$missingColumns = implode(', ', $missingColumns);
|
||||
$this->success[] = "Success: added missing ($missingColumns) $columns to $table table.";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the targeted component code
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.1
|
||||
*/
|
||||
abstract protected function getCode(): string;
|
||||
|
||||
/**
|
||||
* Add missing columns to a table.
|
||||
*
|
||||
* @param string $table The table to update.
|
||||
* @param array $fields List of missing columns/fields.
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.1
|
||||
* @throws \Exception If there is an error adding columns.
|
||||
*/
|
||||
protected function addMissingColumns(string $table, array $fields): void
|
||||
{
|
||||
try {
|
||||
$query = $this->db->getQuery(true);
|
||||
$alterTable = 'ALTER TABLE ' . $this->db->quoteName($this->getTable($table)) . ' ';
|
||||
|
||||
// Start an ALTER TABLE query
|
||||
$alterQueries = [];
|
||||
foreach ($fields as $field)
|
||||
{
|
||||
if (($def = $this->getColumnDefinition($table, $field)) !== null)
|
||||
{
|
||||
$alterQueries[] = " ADD " . $def;
|
||||
}
|
||||
}
|
||||
|
||||
$this->db->setQuery($alterTable . implode(', ', $alterQueries));
|
||||
$this->db->execute();
|
||||
} catch (\Exception $e) {
|
||||
$columns = (count($fields) == 1) ? 'column' : 'columns';
|
||||
$fields = implode(', ', $fields);
|
||||
throw new \Exception("Error: failed to add ($fields) $columns to $table table.", 0, $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Key all needed keys for this table
|
||||
*
|
||||
* @return string of keys
|
||||
* @since 3.2.1
|
||||
*/
|
||||
protected function getTableKeys(): string
|
||||
{
|
||||
$keys = [];
|
||||
$keys[] = 'PRIMARY KEY (`id`)'; // TODO (we may want this to be dynamicly set)
|
||||
|
||||
if (!empty($this->uniqueKeys))
|
||||
{
|
||||
$keys[] = implode(', ', $this->uniqueKeys);
|
||||
}
|
||||
|
||||
if (!empty($this->keys))
|
||||
{
|
||||
$keys[] = implode(', ', $this->keys);
|
||||
}
|
||||
|
||||
return implode(', ', $keys);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to set the unique key
|
||||
*
|
||||
* @param string $column The field column database array values
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.1
|
||||
*/
|
||||
protected function setUniqueKey(array $column): void
|
||||
{
|
||||
if (isset($column['unique_key']) && $column['unique_key'])
|
||||
{
|
||||
$key = $column['unique_key_name'] ?? $column['name'];
|
||||
$this->uniqueKeys[] = "UNIQUE KEY `idx_" . $key . "` (`" . $column['name'] . "`)";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to set the key
|
||||
*
|
||||
* @param string $column The field column database array values
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.1
|
||||
*/
|
||||
protected function setKey(array $column): void
|
||||
{
|
||||
if (isset($column['key']) && $column['key'])
|
||||
{
|
||||
$key = $column['key_name'] ?? $column['name'];
|
||||
$this->keys[] = "KEY `idx_" . $key . "` (`" . $column['name'] . "`)";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add the component name to get the full table name.
|
||||
*
|
||||
* @param string $table The table name.
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.1
|
||||
*/
|
||||
protected function getTable(string $table): string
|
||||
{
|
||||
return $this->prefix . '_' . $table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a table exists in the database.
|
||||
*
|
||||
* @param string $table The name of the table to check.
|
||||
*
|
||||
* @return bool True if table exists, False otherwise.
|
||||
* @since 3.2.1
|
||||
*/
|
||||
private function tableExists(string $table): bool
|
||||
{
|
||||
return in_array($this->getTable($table), $this->tables);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch existing columns from a database table.
|
||||
*
|
||||
* @param string $table The name of the table.
|
||||
*
|
||||
* @return array An array of column names.
|
||||
* @since 3.2.1
|
||||
*/
|
||||
private function getExistingColumns(string $table): array
|
||||
{
|
||||
$columns = $this->db->getTableColumns($this->getTable($table), false);
|
||||
|
||||
return array_keys($columns);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a SQL snippet for defining a table column, incorporating column type,
|
||||
* default value, nullability, and auto-increment properties.
|
||||
*
|
||||
* @param string $table The table name to be used.
|
||||
* @param string $field The field name in the table to generate SQL for.
|
||||
*
|
||||
* @return string|null The SQL snippet for the column definition.
|
||||
* @since 3.2.1
|
||||
* @throws \Exception If the schema details cannot be retrieved or the SQL statement cannot be constructed properly.
|
||||
*/
|
||||
private function getColumnDefinition(string $table, string $field): ?string
|
||||
{
|
||||
try {
|
||||
// Retrieve the database schema details for the specified table and field
|
||||
if (($db = $this->table->get($table, $field, 'db')) === null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// Prepare the column name
|
||||
$column_name = $this->db->quoteName($field);
|
||||
$db['name'] = $field;
|
||||
|
||||
// Prepare the default value SQL, null switch, and auto increment statement
|
||||
$default = !empty($db['default']) ? " DEFAULT " . $this->db->quote($db['default']) : '';
|
||||
$null_switch = !empty($db['null_switch']) ? " " . $db['null_switch'] : '';
|
||||
$auto_increment = !empty($db['auto_increment']) ? " AUTO_INCREMENT" : '';
|
||||
$type = !empty($db['type']) ? $db['type'] : 'TEXT';
|
||||
|
||||
$this->setKeys($db);
|
||||
|
||||
// Assemble the SQL snippet for the column definition
|
||||
return "{$column_name} {$type}{$default}{$null_switch}{$auto_increment}";
|
||||
} catch (\Exception $e) {
|
||||
throw new \Exception("Error: failed to generate column definition for $table.$field", 0, $e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function to set the view keys
|
||||
*
|
||||
* @param string $column The field column database array values
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.1
|
||||
*/
|
||||
private function setKeys(array $column): void
|
||||
{
|
||||
$this->setUniqueKey($column);
|
||||
$this->setKey($column);
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ namespace VDM\Joomla\Componentbuilder\Compiler\Builder;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Placefix;
|
||||
use VDM\Joomla\Abstraction\Registry\Traits\IsString;
|
||||
use VDM\Joomla\Interfaces\Registryinterface;
|
||||
use VDM\Joomla\Abstraction\Registry;
|
||||
|
||||
@ -24,6 +25,13 @@ use VDM\Joomla\Abstraction\Registry;
|
||||
*/
|
||||
class ContentOne extends Registry implements Registryinterface
|
||||
{
|
||||
/**
|
||||
* Is String Values
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
use IsString;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
|
@ -693,6 +693,8 @@ final class Builders
|
||||
$field['settings']->null_switch);
|
||||
// set index types
|
||||
$_guid = true;
|
||||
$databaseuniquekey = false;
|
||||
$databasekey = false;
|
||||
if ($field['settings']->indexes == 1
|
||||
&& !in_array(
|
||||
$field['settings']->datatype, $textKeys
|
||||
@ -700,6 +702,7 @@ final class Builders
|
||||
{
|
||||
// build unique keys of this view for db
|
||||
$this->databaseuniquekeys->add($nameSingleCode, $name, true);
|
||||
$databaseuniquekey = true;
|
||||
// prevent guid from being added twice
|
||||
if ('guid' === $name)
|
||||
{
|
||||
@ -715,6 +718,7 @@ final class Builders
|
||||
{
|
||||
// build keys of this view for db
|
||||
$this->databasekeys->add($nameSingleCode, $name, true);
|
||||
$databasekey = true;
|
||||
}
|
||||
// special treatment for GUID
|
||||
if ('guid' === $name && $_guid)
|
||||
@ -1300,10 +1304,61 @@ final class Builders
|
||||
'title' => (is_string($title_) && $name === $title_) ? true : false,
|
||||
'list' => $nameListCode,
|
||||
'store' => (isset($field['store'])) ? $field['store'] : null,
|
||||
'tab_name' => $tabName
|
||||
'tab_name' => $tabName,
|
||||
'db' => $this->normalizeDatabaseValues($nameSingleCode, $name, $databaseuniquekey, $databasekey)
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Normalizes database values by adjusting the 'length' and 'default' fields based on specific conditions.
|
||||
* This function modifies the database values by replacing placeholder texts and appending specifications
|
||||
* to types based on the 'length' field. It removes unnecessary fields from the result array.
|
||||
*
|
||||
* @param string $nameSingleCode The code for naming single entries.
|
||||
* @param string $name The name of the database entry.
|
||||
* @param string $uniquekey Is this field a uniquekey
|
||||
* @param string $iskey Is this field a key
|
||||
*
|
||||
* @return array|null Returns the modified database values array or null if no values are found.
|
||||
* @since 3.2.1
|
||||
*/
|
||||
private function normalizeDatabaseValues($nameSingleCode, $name, $uniquekey, $iskey): ?array
|
||||
{
|
||||
$db_values = $this->databasetables->get($nameSingleCode . '.' . $name, null);
|
||||
if ($db_values === null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (isset($db_values['lenght']))
|
||||
{
|
||||
if ($db_values['lenght'] === 'Other' && isset($db_values['lenght_other']))
|
||||
{
|
||||
$db_values['lenght'] = $db_values['lenght_other'];
|
||||
}
|
||||
$db_values['lenght'] = trim($db_values['lenght']);
|
||||
if (strlen($db_values['lenght']))
|
||||
{
|
||||
$db_values['type'] .= '(' . $db_values['lenght'] . ')';
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($db_values['default']))
|
||||
{
|
||||
if ($db_values['default'] === 'Other' && isset($db_values['other']))
|
||||
{
|
||||
$db_values['default'] = $db_values['other'];
|
||||
}
|
||||
}
|
||||
|
||||
$db_values['unique_key'] = $uniquekey;
|
||||
$db_values['key'] = $iskey;
|
||||
|
||||
unset($db_values['ID'], $db_values['lenght'], $db_values['lenght_other'], $db_values['other']);
|
||||
|
||||
return $db_values;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1206,11 +1206,6 @@ class Infusion extends Interpretation
|
||||
);
|
||||
}
|
||||
|
||||
// all fields stored in database
|
||||
CFactory::_('Compiler.Builder.Content.One')->set('ALL_COMPONENT_FIELDS',
|
||||
CFactory::_('Compiler.Builder.Component.Fields')->varExport(null, 1)
|
||||
);
|
||||
|
||||
// setup the layouts
|
||||
$this->setCustomViewLayouts();
|
||||
|
||||
@ -2082,11 +2077,16 @@ class Infusion extends Interpretation
|
||||
// UNINSTALLSCRIPT
|
||||
CFactory::_('Compiler.Builder.Content.One')->add('UNINSTALLSCRIPT', $this->setUninstallScript());
|
||||
|
||||
// INSTALLERMETHODS
|
||||
CFactory::_('Compiler.Builder.Content.One')->add('INSTALLERMETHODS', CFactory::_('Customcode.Dispenser')->get(
|
||||
'php_method', 'install', PHP_EOL
|
||||
));
|
||||
|
||||
// MOVEFOLDERSSCRIPT
|
||||
CFactory::_('Compiler.Builder.Content.One')->set('MOVEFOLDERSSCRIPT', $this->setMoveFolderScript());
|
||||
|
||||
// MOVEFOLDERSMETHOD
|
||||
CFactory::_('Compiler.Builder.Content.One')->set('MOVEFOLDERSMETHOD', $this->setMoveFolderMethod());
|
||||
// INSTALLERMETHODS2
|
||||
CFactory::_('Compiler.Builder.Content.One')->add('INSTALLERMETHODS', $this->setMoveFolderMethod());
|
||||
|
||||
// HELPER_UIKIT
|
||||
CFactory::_('Compiler.Builder.Content.One')->set('HELPER_UIKIT', $this->setUikitHelperMethods());
|
||||
@ -2144,6 +2144,11 @@ class Infusion extends Interpretation
|
||||
);
|
||||
}
|
||||
|
||||
// all fields stored in database
|
||||
CFactory::_('Compiler.Builder.Content.One')->set('ALL_COMPONENT_FIELDS',
|
||||
CFactory::_('Compiler.Builder.Component.Fields')->varExport(null, 1)
|
||||
);
|
||||
|
||||
// set the autoloader for Powers (first time)
|
||||
CFactory::_('Power.Autoloader')->set();
|
||||
|
||||
|
@ -10346,7 +10346,7 @@ class Interpretation extends Fields
|
||||
// check if default field was overwritten
|
||||
if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.params'))
|
||||
{
|
||||
$db_ .= PHP_EOL . Indent::_(1) . "`params` text NULL,";
|
||||
$db_ .= PHP_EOL . Indent::_(1) . "`params` TEXT NULL,";
|
||||
}
|
||||
// check if default field was overwritten
|
||||
if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.published'))
|
||||
@ -10432,6 +10432,23 @@ class Interpretation extends Fields
|
||||
{
|
||||
$db_ .= PHP_EOL . Indent::_(1)
|
||||
. "`access` INT(10) unsigned NOT NULL DEFAULT 0,";
|
||||
// add to component dynamic fields
|
||||
CFactory::_('Compiler.Builder.Component.Fields')->set($view . '.access',
|
||||
[
|
||||
'name' => 'access',
|
||||
'label' => 'Access',
|
||||
'type' => 'accesslevel',
|
||||
'title' => false,
|
||||
'store' => NULL,
|
||||
'tab_name' => NULL,
|
||||
'db' => [
|
||||
'type' => 'INT(10) unsigned',
|
||||
'default' => '0',
|
||||
'key' => true,
|
||||
'null_switch' => 'NOT NULL'
|
||||
]
|
||||
]
|
||||
);
|
||||
}
|
||||
// check if default field was overwritten
|
||||
if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.ordering'))
|
||||
@ -10468,6 +10485,49 @@ class Interpretation extends Fields
|
||||
$db_ .= PHP_EOL . Indent::_(1)
|
||||
. "`metadata` TEXT NOT NULL,";
|
||||
}
|
||||
// add to component dynamic fields
|
||||
CFactory::_('Compiler.Builder.Component.Fields')->set($view . '.metakey',
|
||||
[
|
||||
'name' => 'metakey',
|
||||
'label' => 'Meta Keywords',
|
||||
'type' => 'textarea',
|
||||
'title' => false,
|
||||
'store' => NULL,
|
||||
'tab_name' => 'publishing',
|
||||
'db' => [
|
||||
'type' => 'TEXT',
|
||||
'default' => ''
|
||||
]
|
||||
]
|
||||
);
|
||||
CFactory::_('Compiler.Builder.Component.Fields')->set($view . '.metadesc',
|
||||
[
|
||||
'name' => 'metadesc',
|
||||
'label' => 'Meta Description',
|
||||
'type' => 'textarea',
|
||||
'title' => false,
|
||||
'store' => NULL,
|
||||
'tab_name' => 'publishing',
|
||||
'db' => [
|
||||
'type' => 'TEXT',
|
||||
'default' => ''
|
||||
]
|
||||
]
|
||||
);
|
||||
CFactory::_('Compiler.Builder.Component.Fields')->set($view . '.metadata',
|
||||
[
|
||||
'name' => 'metadata',
|
||||
'label' => 'Meta Data',
|
||||
'type' => NULL,
|
||||
'title' => false,
|
||||
'store' => 'json',
|
||||
'tab_name' => 'publishing',
|
||||
'db' => [
|
||||
'type' => 'TEXT',
|
||||
'default' => ''
|
||||
]
|
||||
]
|
||||
);
|
||||
}
|
||||
// TODO (we may want this to be dynamicly set)
|
||||
$db_ .= PHP_EOL . Indent::_(1) . "PRIMARY KEY (`id`)";
|
||||
|
@ -15,15 +15,15 @@ namespace VDM\Joomla\Componentbuilder\Compiler;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Application\CMSApplication;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Utilities\JsonHelper;
|
||||
use VDM\Joomla\Utilities\GuidHelper;
|
||||
use VDM\Joomla\Utilities\String\NamespaceHelper;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Config;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
|
||||
use VDM\Joomla\Componentbuilder\JoomlaPower\Super as SuperPower;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Utilities\JsonHelper;
|
||||
use VDM\Joomla\Utilities\GuidHelper;
|
||||
use VDM\Joomla\Utilities\String\NamespaceHelper;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\PowerInterface;
|
||||
|
||||
|
||||
|
@ -88,7 +88,8 @@ class Autoloader
|
||||
*/
|
||||
public function set()
|
||||
{
|
||||
if (ArrayHelper::check($this->power->namespace))
|
||||
// make sure we only load this once
|
||||
if (ArrayHelper::check($this->power->namespace) && !$this->content->isString('CUSTOM_POWER_AUTOLOADER'))
|
||||
{
|
||||
/************************* IMPORTANT SORT NOTICE ***********************************************
|
||||
* make sure the name space values are sorted from the longest string to the shortest
|
||||
|
@ -16,6 +16,7 @@ use VDM\Joomla\Componentbuilder\Interfaces\GrepInterface as Grep;
|
||||
use VDM\Joomla\Componentbuilder\Interfaces\Database\InsertInterface as Insert;
|
||||
use VDM\Joomla\Componentbuilder\Interfaces\Database\UpdateInterface as Update;
|
||||
use VDM\Joomla\Utilities\GuidHelper;
|
||||
use VDM\Joomla\Componentbuilder\Interfaces\SuperInterface;
|
||||
|
||||
|
||||
/**
|
||||
@ -23,7 +24,7 @@ use VDM\Joomla\Utilities\GuidHelper;
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Super
|
||||
class Super implements SuperInterface
|
||||
{
|
||||
/**
|
||||
* The Power Search Tool
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,52 @@
|
||||
<?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\Table;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Table as Table;
|
||||
use VDM\Joomla\Interfaces\SchemaInterface;
|
||||
use VDM\Joomla\Abstraction\Schema as ExtendingSchema;
|
||||
|
||||
|
||||
/**
|
||||
* JCB Tables Schema
|
||||
*
|
||||
* @since 3.2.1
|
||||
*/
|
||||
final class Schema extends ExtendingSchema implements SchemaInterface
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Table $table The Table Class.
|
||||
*
|
||||
* @since 3.2.1
|
||||
*/
|
||||
public function __construct(?Table $table = null)
|
||||
{
|
||||
$table ??= new Table;
|
||||
|
||||
parent::__construct($table);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the targeted component code
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.1
|
||||
*/
|
||||
protected function getCode(): string
|
||||
{
|
||||
return 'componentbuilder';
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@ -26,10 +26,10 @@ interface Registryinterface
|
||||
* @param mixed $value Value of entry
|
||||
*
|
||||
* @throws \InvalidArgumentException If any of the path values are not a number or string.
|
||||
* @return void
|
||||
* @return $this
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function set(string $path, $value): void;
|
||||
public function set(string $path, $value): static;
|
||||
|
||||
/**
|
||||
* Adds content into the registry. If a key exists,
|
||||
@ -42,10 +42,10 @@ interface Registryinterface
|
||||
* Override in child class allowed set class property $addAsArray = true.
|
||||
*
|
||||
* @throws \InvalidArgumentException If any of the path values are not a number or string.
|
||||
* @return void
|
||||
* @return $this
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function add(string $path, $value, ?bool $asArray = null): void;
|
||||
public function add(string $path, $value, ?bool $asArray = null): static;
|
||||
|
||||
/**
|
||||
* Retrieves a value (or sub-array) from the registry using multiple keys.
|
||||
@ -65,10 +65,10 @@ interface Registryinterface
|
||||
* @param string $path Registry path (e.g. vdm.content.builder)
|
||||
*
|
||||
* @throws \InvalidArgumentException If any of the path values are not a number or string.
|
||||
* @return void
|
||||
* @return $this
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function remove(string $path): void;
|
||||
public function remove(string $path): static;
|
||||
|
||||
/**
|
||||
* Checks the existence of a particular location in the registry using multiple keys.
|
||||
@ -86,9 +86,9 @@ interface Registryinterface
|
||||
*
|
||||
* @param string|null $value The value to set.
|
||||
*
|
||||
* @return void
|
||||
* @return $this
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function setSeparator(?string $value): void;
|
||||
public function setSeparator(?string $value): static;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,53 @@
|
||||
<?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\Interfaces;
|
||||
|
||||
|
||||
/**
|
||||
* Schema Checking Interface
|
||||
*
|
||||
* @since 3.2.1
|
||||
*/
|
||||
interface SchemaInterface
|
||||
{
|
||||
/**
|
||||
* Check and update database schema for missing fields or tables.
|
||||
*
|
||||
* @return array The array of successful updates/actions, if empty no update/action was taken.
|
||||
* @since 3.2.1
|
||||
* @throws \Exception If there is an error during the update process.
|
||||
*/
|
||||
public function update(): array;
|
||||
|
||||
/**
|
||||
* Create a table with all necessary fields.
|
||||
*
|
||||
* @param string $table The name of the table to create.
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.1
|
||||
* @throws \Exception If there is an error creating the table.
|
||||
*/
|
||||
public function createTable(string $table): void;
|
||||
|
||||
/**
|
||||
* Update the schema of an existing table.
|
||||
*
|
||||
* @param string $table The table to update.
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.1
|
||||
* @throws \Exception If there is an error while updating the schema.
|
||||
*/
|
||||
public function updateSchema(string $table): void;
|
||||
}
|
||||
|
@ -26,15 +26,16 @@ interface Tableinterface
|
||||
* Example: $this->get('table_name');
|
||||
* Get all areas/views/tables with all their item/field/column details
|
||||
* Example: $this->get('All');
|
||||
* Example: $this->get();
|
||||
*
|
||||
* @param string $table The table
|
||||
* @param string|null $table The table
|
||||
* @param string|null $field The field
|
||||
* @param string|null $key The value key
|
||||
*
|
||||
* @return mixed
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(string $table, ?string $field = null, ?string $key = null);
|
||||
public function get(?string $table = null, ?string $field = null, ?string $key = null);
|
||||
|
||||
/**
|
||||
* Get title field from an area/view/table
|
||||
@ -80,10 +81,11 @@ interface Tableinterface
|
||||
*
|
||||
* @param string $table The area
|
||||
* @param bool $default Add the default fields
|
||||
* @param bool $details Add/Leave fields the details
|
||||
*
|
||||
* @return array|null On success an array of fields
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function fields(string $table, bool $default = false): ?array;
|
||||
public function fields(string $table, bool $default = false, bool $details = false): ?array;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user