Release of v5.0.1-alpha6
Add new subform classes. Fix registry class methods return type. Update all list and custom fields to use the new layouts.
This commit is contained in:
83
libraries/vendor_jcb/VDM.Joomla/src/Abstraction/Factory.php
Normal file
83
libraries/vendor_jcb/VDM.Joomla/src/Abstraction/Factory.php
Normal 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;
|
||||
}
|
||||
|
@@ -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');
|
||||
|
@@ -40,10 +40,10 @@ abstract class Registry extends ActiveRegistry implements Registryinterface
|
||||
* @param mixed $value Value of entry
|
||||
*
|
||||
* @throws \InvalidArgumentException If any of the path values are not a number or string.
|
||||
* @return $this
|
||||
* @return self
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function set(string $path, $value): static
|
||||
public function set(string $path, $value): self
|
||||
{
|
||||
if (($keys = $this->getActiveKeys($path)) === null)
|
||||
{
|
||||
@@ -66,10 +66,10 @@ abstract class Registry extends ActiveRegistry implements 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 $this
|
||||
* @return self
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function add(string $path, $value, ?bool $asArray = null): static
|
||||
public function add(string $path, $value, ?bool $asArray = null): self
|
||||
{
|
||||
if (($keys = $this->getActiveKeys($path)) === null)
|
||||
{
|
||||
@@ -107,10 +107,10 @@ abstract class Registry extends ActiveRegistry implements 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 $this
|
||||
* @return self
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function remove(string $path): static
|
||||
public function remove(string $path): self
|
||||
{
|
||||
if (($keys = $this->getActiveKeys($path)) === null)
|
||||
{
|
||||
@@ -146,10 +146,10 @@ abstract class Registry extends ActiveRegistry implements Registryinterface
|
||||
*
|
||||
* @param string|null $value The value to set.
|
||||
*
|
||||
* @return $this
|
||||
* @return self
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function setSeparator(?string $value): static
|
||||
public function setSeparator(?string $value): self
|
||||
{
|
||||
$this->separator = $value;
|
||||
|
||||
|
Reference in New Issue
Block a user