Release of v5.1.1-alpha5

Refactor initialization flow to accommodate future scalability and integration with all designated areas. Refactor the Creator Builders class. Refactor the FieldString and FieldXML classes.
This commit is contained in:
2025-05-13 13:39:32 +00:00
parent 0b7e68d14e
commit 3b502eb09b
336 changed files with 22863 additions and 20677 deletions

View File

@@ -20,9 +20,9 @@ use VDM\Joomla\Abstraction\Grep as ExtendingGrep;
/**
* Global Resource Empowerment Platform
*
* The Grep feature will try to find your joomla power in the repositories listed in the global
* Options of JCB in the super powers tab, and if it can't be found there will try the global core
* Super powers of JCB. All searches are performed according the [algorithm:cascading]
* The Grep feature will try to find your power in the repositories
* linked to this [area], and if it can't be found there will try the global core
* Super Powers of JCB. All searches are performed according the [algorithm:cascading]
* See documentation for more details: https://git.vdm.dev/joomla/super-powers/wiki
*
* @since 3.2.1
@@ -84,19 +84,25 @@ final class Grep extends ExtendingGrep implements GrepInterface
// get the branch name
$branch = $this->getBranchName($path);
// get the guid_field key
$guid_field = $this->getGuidField();
// get the settings path
$settings_path = $this->getSettingsPath();
// load the base and token if set
$this->loadApi($this->contents, $path->base ?? null, $path->token ?? null);
// get the settings
if (($power = $this->loadRemoteFile($path->organisation, $path->repository, $path->index->{$guid}->path . '/item.json', $branch)) !== null &&
isset($power->guid))
if (($power = $this->loadRemoteFile($path->organisation, $path->repository, $path->index->{$guid}->path . '/' . $settings_path, $branch)) !== null &&
isset($power->{$guid_field}))
{
// set the git details in params
$path_guid = $path->guid ?? null;
if ($path_guid !== null)
{
// get the Settings meta
if (($meta = $this->contents->metadata($path->organisation, $path->repository, $path->index->{$guid}->path . '/item.json', $branch)) !== null &&
if (($meta = $this->contents->metadata($path->organisation, $path->repository, $path->index->{$guid}->path . '/' . $settings_path, $branch)) !== null &&
isset($meta->sha))
{
if (isset($power->params) && is_object($power->params) &&

View File

@@ -0,0 +1,154 @@
<?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\JoomlaPower\Remote;
use VDM\Joomla\Interfaces\Remote\ConfigInterface;
use VDM\Joomla\Abstraction\Remote\Config as ExtendingConfig;
/**
* Base Configure values for the remote classes
*
* @since 5.1.1
*/
final class Config extends ExtendingConfig implements ConfigInterface
{
/**
* Table Name
*
* @var string
* @since 5.0.3
*/
protected string $table = 'joomla_power';
/**
* Area Name
*
* @var string|null
* @since 5.0.3
*/
protected ?string $area = 'Joomla Power';
/**
* Prefix Key
*
* @var string
* @since 3.2.2
*/
protected string $prefix_key = 'Joomla---';
/**
* Suffix Key
*
* @var string
* @since 3.2.2
*/
// [DEFAULT] protected string $suffix_key = '---Power';
/**
* The main readme file path
*
* @var string
* @since 5.1.1
*/
// [DEFAULT] protected string $main_readme_path = 'README.md';
/**
* The index file path (index of all items)
*
* @var string
* @since 3.2.2
*/
// [DEFAULT] protected string $index_path = 'index.json';
/**
* The item (files) source path
*
* @var string
* @since 5.1.1
*/
// [DEFAULT] protected string $src_path = 'src';
/**
* The item settings file path
*
* @var string
* @since 3.2.2
*/
// [DEFAULT] protected string $settings_path = 'item.json';
/**
* The item guid=unique field
*
* @var string
* @since 5.1.1
*/
// [DEFAULT] protected string $guid_field = 'guid';
/**
* The item map
*
* @var array
* @since 5.0.3
protected array $map = [];
[DEFAULT] */
/**
* The index map
* must always have: [name,path,guid]
* you can add more
*
* @var array
* @since 5.0.3
*/
protected array $index_map = [
'name' => 'index_map_IndexName',
'settings' => 'index_map_IndexSettingsPath',
'path' => 'index_map_IndexPath',
'jpk' => 'index_map_IndexKey',
'guid' => 'index_map_IndexGUID'
];
/**
* The index header
* mapping the index map to a table
* must always have: [name,path,guid,local]
* with [name] always first
* with [path,guid,local] always last
* you can add more in between
*
* @var array
* @since 5.1.1
*/
protected array $index_header = [
'name',
'jpk',
'path',
'guid',
'local'
];
/**
* Core Placeholders
*
* @var array
* @since 5.0.3
protected array $placeholders = [
'[['.'[NamespacePrefix]]]' => 'VDM',
'[['.'[ComponentNamespace]]]' => 'Componentbuilder',
'[['.'[Component]]]' => 'Componentbuilder',
'[['.'[component]]]' => 'componentbuilder'
];
[DEFAULT] */
}

View File

@@ -1,34 +0,0 @@
<?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\JoomlaPower\Remote;
use VDM\Joomla\Interfaces\Remote\GetInterface;
use VDM\Joomla\Abstraction\Remote\Get as ExtendingGet;
/**
* Remote Get Joomla Power of JCB
*
* @since 3.2.0
*/
final class Get extends ExtendingGet implements GetInterface
{
/**
* Table Name
*
* @var string
* @since 3.2.1
*/
protected string $table = 'joomla_power';
}

View File

@@ -12,6 +12,7 @@
namespace VDM\Joomla\Componentbuilder\JoomlaPower\Remote;
use Joomla\CMS\Language\Text;
use VDM\Joomla\Interfaces\Remote\SetInterface;
use VDM\Joomla\Abstraction\Remote\Set as ExtendingSet;
@@ -23,57 +24,6 @@ use VDM\Joomla\Abstraction\Remote\Set as ExtendingSet;
*/
final class Set extends ExtendingSet implements SetInterface
{
/**
* Table Name
*
* @var string
* @since 3.2.2
*/
protected string $table = 'joomla_power';
/**
* Area Name
*
* @var string
* @since 3.2.2
*/
protected string $area = 'Joomla Power';
/**
* Prefix Key
*
* @var string
* @since 3.2.2
*/
protected string $prefix_key = 'Joomla---';
/**
* The item map
*
* @var array
* @since 3.2.2
*/
protected array $map = [
'system_name' => 'system_name',
'settings' => 'settings',
'guid' => 'guid',
'description' => 'description'
];
/**
* The index map
*
* @var array
* @since 3.2.2
*/
protected array $index_map = [
'name' => 'index_map_IndexName',
'settings' => 'index_map_IndexSettingsPath',
'path' => 'index_map_IndexPath',
'jpk' => 'index_map_IndexKey',
'guid' => 'index_map_IndexGUID'
];
/**
* update an existing item (if changed)
*
@@ -86,25 +36,36 @@ final class Set extends ExtendingSet implements SetInterface
*/
protected function updateItem(object $item, object $existing, object $repo): bool
{
// make sure there was a change
$sha = $existing->params->source[$repo->guid . '-settings'] ?? null;
$existing = $this->mapItem($existing);
$area = $this->getArea();
$item_name = $this->index_map_IndexName($item);
$repo_name = $this->getRepoName($repo);
if ($sha === null || $this->areObjectsEqual($item, $existing))
{
$this->messages->add('warning', Text::sprintf('COM_COMPONENTBUILDER_S_ITEM_S_DETAILS_IN_REPOS_DID_NOT_CHANGE_SO_NO_UPDATE_WAS_MADE', $area, $item_name, $repo_name));
return false;
}
$this->git->update(
$result = $this->git->update(
$repo->organisation, // The owner name.
$repo->repository, // The repository name.
'src/' . $item->guid . '/' . $this->getSettingsPath(), // The file path.
$this->index_map_IndexSettingsPath($item), // The file path.
json_encode($item, JSON_PRETTY_PRINT), // The file content.
'Update ' . $item->system_name, // The commit message.
$sha, // The blob SHA of the old file.
$repo->write_branch // The branch name.
);
return true;
$success = is_object($result);
if (!$success)
{
$this->messages->add('warning', Text::sprintf('COM_COMPONENTBUILDER_S_ITEM_S_DETAILS_IN_REPOS_FAILED_TO_UPDATE', $area, $item_name, $repo_name));
}
return $success;
}
/**
@@ -113,19 +74,21 @@ final class Set extends ExtendingSet implements SetInterface
* @param object $item
* @param object $repo
*
* @return void
* @return bool
* @since 3.2.2
*/
protected function createItem(object $item, object $repo): void
protected function createItem(object $item, object $repo): bool
{
$this->git->create(
$result = $this->git->create(
$repo->organisation, // The owner name.
$repo->repository, // The repository name.
'src/' . $item->guid . '/' . $this->getSettingsPath(), // The file path.
$this->index_map_IndexSettingsPath($item), // The file path.
json_encode($item, JSON_PRETTY_PRINT), // The file content.
'Create ' . $item->system_name, // The commit message.
$repo->write_branch // The branch name.
);
return is_object($result);
}
/**
@@ -150,7 +113,7 @@ final class Set extends ExtendingSet implements SetInterface
$this->git->update(
$repo->organisation, // The owner name.
$repo->repository, // The repository name.
'src/' . $item->guid . '/README.md', // The file path.
$this->index_map_IndexPath($item) . '/README.md', // The file path.
$this->itemReadme->get($item), // The file content.
'Update ' . $item->system_name . ' readme file', // The commit message.
$sha, // The blob SHA of the old file.
@@ -172,7 +135,7 @@ final class Set extends ExtendingSet implements SetInterface
$this->git->create(
$repo->organisation, // The owner name.
$repo->repository, // The repository name.
'src/' . $item->guid . '/README.md', // The file path.
$this->index_map_IndexPath($item) . '/README.md', // The file path.
$this->itemReadme->get($item), // The file content.
'Create ' . $item->system_name . ' readme file', // The commit message.
$repo->write_branch // The branch name.

View File

@@ -15,9 +15,11 @@ namespace VDM\Joomla\Componentbuilder\JoomlaPower\Service;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use VDM\Joomla\Componentbuilder\JoomlaPower\Config;
use VDM\Joomla\Componentbuilder\Table;
use VDM\Joomla\Componentbuilder\Power\Table;
use VDM\Joomla\Componentbuilder\Package\MessageBus;
use VDM\Joomla\Componentbuilder\JoomlaPower\Grep;
use VDM\Joomla\Componentbuilder\JoomlaPower\Remote\Get;
use VDM\Joomla\Componentbuilder\JoomlaPower\Remote\Config as RemoteConfig;
use VDM\Joomla\Componentbuilder\Power\Remote\Get;
use VDM\Joomla\Componentbuilder\JoomlaPower\Remote\Set;
use VDM\Joomla\Componentbuilder\JoomlaPower\Readme\Item as ItemReadme;
use VDM\Joomla\Componentbuilder\JoomlaPower\Readme\Main as MainReadme;
@@ -43,12 +45,18 @@ class JoomlaPower implements ServiceProviderInterface
$container->alias(Config::class, 'Config')
->share('Config', [$this, 'getConfig'], true);
$container->alias(Table::class, 'Table')
->share('Table', [$this, 'getTable'], true);
$container->alias(Table::class, 'Power.Table')->alias('Table', 'Power.Table')
->share('Power.Table', [$this, 'getPowerTable'], true);
$container->alias(MessageBus::class, 'Power.Message')
->share('Power.Message', [$this, 'getMessageBus'], true);
$container->alias(Grep::class, 'Joomla.Power.Grep')
->share('Joomla.Power.Grep', [$this, 'getGrep'], true);
$container->alias(RemoteConfig::class, 'Joomla.Power.Remote.Config')
->share('Joomla.Power.Remote.Config', [$this, 'getRemoteConfig'], true);
$container->alias(Get::class, 'Joomla.Power.Remote.Get')
->share('Joomla.Power.Remote.Get', [$this, 'getRemoteGet'], true);
@@ -76,18 +84,31 @@ class JoomlaPower implements ServiceProviderInterface
}
/**
* Get The Table Class.
* Get The Power Table Class.
*
* @param Container $container The DI container.
*
* @return Table
* @since 3.2.1
* @since 5.1.1
*/
public function getTable(Container $container): Table
public function getPowerTable(Container $container): Table
{
return new Table();
}
/**
* Get The Message Bus Class.
*
* @param Container $container The DI container.
*
* @return MessageBus
* @since 5.2.1
*/
public function getMessageBus(Container $container): MessageBus
{
return new MessageBus();
}
/**
* Get The Grep Class.
*
@@ -99,12 +120,28 @@ class JoomlaPower implements ServiceProviderInterface
public function getGrep(Container $container): Grep
{
return new Grep(
$container->get('Joomla.Power.Remote.Config'),
$container->get('Gitea.Repository.Contents'),
$container->get('Network.Resolve'),
$container->get('Config')->approved_joomla_paths
);
}
/**
* Get The Remote Config Class.
*
* @param Container $container The DI container.
*
* @return RemoteConfig
* @since 5.1.1
*/
public function getRemoteConfig(Container $container): RemoteConfig
{
return new RemoteConfig(
$container->get('Power.Table')
);
}
/**
* Get The Remote Get Class.
*
@@ -116,6 +153,7 @@ class JoomlaPower implements ServiceProviderInterface
public function getRemoteGet(Container $container): Get
{
return new Get(
$container->get('Joomla.Power.Remote.Config'),
$container->get('Joomla.Power.Grep'),
$container->get('Data.Item')
);
@@ -132,12 +170,14 @@ class JoomlaPower implements ServiceProviderInterface
public function getRemoteSet(Container $container): Set
{
return new Set(
$container->get('Config')->approved_joomla_paths,
$container->get('Joomla.Power.Remote.Config'),
$container->get('Joomla.Power.Grep'),
$container->get('Data.Items'),
$container->get('Joomla.Power.Readme.Item'),
$container->get('Joomla.Power.Readme.Main'),
$container->get('Gitea.Repository.Contents')
$container->get('Gitea.Repository.Contents'),
$container->get('Power.Message'),
$container->get('Config')->approved_joomla_paths
);
}

View File

@@ -0,0 +1 @@
<html><body bgcolor="#FFFFFF"></body></html>