Release of v5.0.0-beta3

Add Joomla powers for namespace dynamic management.
This commit is contained in:
2024-04-16 20:26:48 +02:00
parent 25b751a935
commit 00f14c3bba
97 changed files with 6755 additions and 145 deletions

View File

@@ -14,13 +14,14 @@ namespace VDM\Joomla\Componentbuilder\Compiler\Power;
use Joomla\CMS\Factory;
use VDM\Joomla\Utilities\GuidHelper;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Power\ExtractorInterface;
/**
* Compiler Power Extractor
* @since 3.2.0
*/
final class Extractor
class Extractor implements ExtractorInterface
{
/**
* The pattern to get the powers
@@ -30,6 +31,30 @@ final class Extractor
**/
protected string $pattern = '/Super_'.'_'.'_[a-zA-Z0-9_]+_'.'_'.'_Power/';
/**
* The pattern to get the Front
*
* @var string
* @since 3.2.1
**/
protected string $_pattern = 'Super';
/**
* The pattern to get the Back
*
* @var string
* @since 3.2.1
**/
protected string $pattern_ = 'Power';
/**
* The Table
*
* @var string
* @since 3.2.1
**/
protected string $table = 'power';
/**
* Powers GUID's
*
@@ -122,7 +147,7 @@ final class Extractor
* @return void
* @since 3.2.0
*/
public function search(string $code)
public function search(string $code): void
{
$matches = [];
preg_match_all($this->pattern, $code, $matches);
@@ -147,7 +172,7 @@ final class Extractor
{
foreach ($found as $super_power)
{
$guid = str_replace(['Super_'.'_'.'_', '_'.'_'.'_Power'], '', $super_power);
$guid = str_replace([], '', $super_power);
$guid = str_replace('_', '-', $guid);
if (GuidHelper::valid($guid))
@@ -171,7 +196,7 @@ final class Extractor
foreach ($found as $super_power)
{
$guid = str_replace(['Super_'.'_'.'_', '_'.'_'.'_Power'], '', $super_power);
$guid = str_replace([$this->_pattern . '___', '___' . $this->pattern_], '', $super_power);
$guid = str_replace('_', '-', $guid);
if (GuidHelper::valid($guid))
@@ -197,7 +222,7 @@ final class Extractor
foreach ($found as $super_power)
{
$guid = str_replace(['Super_'.'_'.'_', '_'.'_'.'_Power'], '', $super_power);
$guid = str_replace([$this->_pattern . '___', '___' . $this->pattern_], '', $super_power);
$guid = str_replace('_', '-', $guid);
if (GuidHelper::valid($guid))
@@ -226,7 +251,7 @@ final class Extractor
. ', ".", "\\\") AS full_namespace, '
. $this->db->quoteName('guid')
)
->from($this->db->quoteName('#__componentbuilder_power'))
->from($this->db->quoteName('#__componentbuilder_' . $this->table))
->where($this->db->quoteName('guid') . ' IN (' . implode(',', array_map([$this->db, 'quote'], $guids)) . ')');
$this->db->setQuery($query);
$this->db->execute();

View File

@@ -12,18 +12,18 @@
namespace VDM\Joomla\Componentbuilder\Compiler\Power;
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
use VDM\Joomla\Componentbuilder\Compiler\Power;
use VDM\Joomla\Componentbuilder\Compiler\Power\Extractor;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\PowerInterface as Power;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Power\ExtractorInterface as Extractor;
use VDM\Joomla\Componentbuilder\Compiler\Power\Parser;
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Power\InjectorInterface;
/**
* Compiler Power Injector
* @since 3.2.0
*/
final class Injector
class Injector implements InjectorInterface
{
/**
* Power Objects
@@ -107,13 +107,13 @@ final class Injector
*
* @since 3.2.0
*/
public function __construct(?Power $power = null, ?Extractor $extractor = null,
?Parser $parser = null, ?Placeholder $placeholder = null)
public function __construct(Power $power = null, Extractor $extractor = null,
Parser $parser = null, Placeholder $placeholder = null)
{
$this->power = $power ?: Compiler::_('Power');
$this->extractor = $extractor ?: Compiler::_('Power.Extractor');
$this->parser = $parser ?: Compiler::_('Power.Parser');
$this->placeholder = $placeholder ?: Compiler::_('Placeholder');
$this->power = $power;
$this->extractor = $extractor;
$this->parser = $parser;
$this->placeholder = $placeholder;
}
/**