Stable release of v4.0.0-alpha1

First alpha release of Component Builder towards Joomla 4 (very unstable...).
This commit is contained in:
2024-03-09 21:47:28 +02:00
parent 3c91a5cdbb
commit c660bb6280
3040 changed files with 296304 additions and 269820 deletions

View File

@@ -32,6 +32,14 @@ abstract class ActiveRegistry implements Activeregistryinterface
**/
protected array $active = [];
/**
* Base switch to add values as string or array
*
* @var boolean
* @since 3.2.0
**/
protected bool $addAsArray = false;
/**
* Check if the registry has any content.
*
@@ -95,21 +103,29 @@ abstract class ActiveRegistry implements Activeregistryinterface
* Adds content into the registry. If a key exists,
* it either appends or concatenates based on the value's type.
*
* @param mixed $value The value to set.
* @param bool $asArray Determines if the new value should be treated as an array.
* @param string ...$keys The keys to determine the location.
* @param mixed $value The value to set.
* @param bool|null $asArray Determines if the new value should be treated as an array.
* Default is $addAsArray = false (if null) in base class.
* Override in child class allowed set class property $addAsArray = true.
* @param string ...$keys The keys to determine the location.
*
* @throws \InvalidArgumentException If any of the keys are not a number or string.
* @return void
* @since 3.2.0
*/
public function addActive($value, bool $asArray, string ...$keys): void
public function addActive($value, ?bool $asArray, string ...$keys): void
{
if (!$this->validActiveKeys($keys))
{
throw new \InvalidArgumentException("Keys must only be strings or numbers to add any value.");
}
// null fallback to class value
if ($asArray === null)
{
$asArray = $this->addAsArray;
}
$array = &$this->active;
foreach ($keys as $key)

View File

@@ -42,7 +42,7 @@ abstract class BaseConfig extends JoomlaRegistry
*
* @since 3.2.0
*/
public function __set(string $key, $value)
public function __set($key, $value)
{
$this->set($key, $value);
}
@@ -50,12 +50,12 @@ abstract class BaseConfig extends JoomlaRegistry
/**
* getting any valid value
*
* @param string $key The value's key/path name
* @param string $key The value's key/path name
*
* @since 3.2.0
* @throws \InvalidArgumentException If $key is not a valid function name.
*/
public function __get(string $key)
public function __get($key)
{
// check if it has been set
if (($value = $this->get($key, '__N0T_S3T_Y3T_')) !== '__N0T_S3T_Y3T_')

View File

@@ -26,10 +26,9 @@ abstract class Database
/**
* Database object to query local DB
*
* @var \JDatabaseDriver
* @since 3.2.0
*/
protected \JDatabaseDriver $db;
protected $db;
/**
* Core Component Table Name
@@ -42,14 +41,12 @@ abstract class Database
/**
* Constructor
*
* @param \JDatabaseDriver|null $db The database driver
*
* @throws \Exception
* @since 3.2.0
*/
public function __construct(?\JDatabaseDriver $db = null)
public function __construct()
{
$this->db = $db ?: JoomlaFactory::getDbo();
$this->db = JoomlaFactory::getDbo();
// set the component table
$this->table = '#__' . Helper::getCode();

View File

@@ -58,15 +58,17 @@ abstract class Registry extends ActiveRegistry implements Activeregistryinterfac
* Adds content into the registry. If a key exists,
* it either appends or concatenates based on $asArray switch.
*
* @param string $path Registry path (e.g. vdm.content.builder)
* @param mixed $value Value of entry
* @param bool $asArray Determines if the new value should be treated as an array. Default is false.
* @param string $path Registry path (e.g. vdm.content.builder)
* @param mixed $value Value of entry
* @param bool|null $asArray Determines if the new value should be treated as an array.
* Default is $addAsArray = false (if null) in base class.
* 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
* @since 3.2.0
*/
public function add(string $path, $value, bool $asArray = false): void
public function add(string $path, $value, ?bool $asArray = null): void
{
if (($keys = $this->getActiveKeys($path)) === null)
{