Release of v4.0.1-alpha5
Add repositories for better integration with gitea. Refactored the Data classes. Add new Data classes.
This commit is contained in:
@@ -13,9 +13,11 @@ namespace VDM\Joomla\Componentbuilder\Compiler;
|
||||
|
||||
|
||||
use Joomla\Registry\Registry as JoomlaRegistry;
|
||||
use Joomla\CMS\Factory as JoomlaFactory;
|
||||
use Joomla\CMS\Factory as JoomlaFactory;
|
||||
use Joomla\Input\Input;
|
||||
use VDM\Joomla\Utilities\GetHelper;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Componentbuilder\Utilities\RepoHelper;
|
||||
use VDM\Joomla\Componentbuilder\Abstraction\BaseConfig;
|
||||
|
||||
|
||||
@@ -43,9 +45,9 @@ class Config extends BaseConfig
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Input|null $input Input
|
||||
* @param Registry|null $params The component parameters
|
||||
* @param Registry|null $config The Joomla configuration
|
||||
* @param Input|null $input Input
|
||||
* @param JoomlaRegistry|null $params The component parameters
|
||||
* @param JoomlaRegistry|null $config The Joomla configuration
|
||||
*
|
||||
* @throws \Exception
|
||||
* @since 3.2.0
|
||||
@@ -65,7 +67,7 @@ class Config extends BaseConfig
|
||||
*/
|
||||
protected function getGiteausername(): ?string
|
||||
{
|
||||
return $this->custom_gitea_username ?? $this->params->get('gitea_username');
|
||||
return $this->params->get('gitea_username');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,66 +78,7 @@ class Config extends BaseConfig
|
||||
*/
|
||||
protected function getGiteatoken(): ?string
|
||||
{
|
||||
return $this->custom_gitea_token ?? $this->params->get('gitea_token');
|
||||
}
|
||||
|
||||
/**
|
||||
* get Add Custom Gitea URL
|
||||
*
|
||||
* @return int the add switch
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getAddcustomgiteaurl(): int
|
||||
{
|
||||
return $this->params->get('add_custom_gitea_url', 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* get Custom Gitea URL
|
||||
*
|
||||
* @return string the custom gitea url
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getCustomgiteaurl(): ?string
|
||||
{
|
||||
if ($this->add_custom_gitea_url == 2)
|
||||
{
|
||||
return $this->params->get('custom_gitea_url');
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* get Custom Gitea Username
|
||||
*
|
||||
* @return string the custom access token
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getCustomgiteausername(): ?string
|
||||
{
|
||||
if ($this->add_custom_gitea_url == 2)
|
||||
{
|
||||
return $this->params->get('custom_gitea_username');
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* get Custom Gitea Access Token
|
||||
*
|
||||
* @return string the custom access token
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getCustomgiteatoken(): ?string
|
||||
{
|
||||
if ($this->add_custom_gitea_url == 2)
|
||||
{
|
||||
return $this->params->get('custom_gitea_token');
|
||||
}
|
||||
|
||||
return null;
|
||||
return $this->params->get('gitea_token');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -149,11 +92,6 @@ class Config extends BaseConfig
|
||||
// the VDM default organisation is [joomla]
|
||||
$organisation = 'joomla';
|
||||
|
||||
if ($this->add_custom_gitea_url == 2)
|
||||
{
|
||||
return $this->params->get('super_powers_core_organisation', $organisation);
|
||||
}
|
||||
|
||||
return $organisation;
|
||||
}
|
||||
|
||||
@@ -168,45 +106,66 @@ class Config extends BaseConfig
|
||||
// some defaults repos we need by JCB
|
||||
$repos = [];
|
||||
|
||||
// only add custom init with custom gitea
|
||||
$paths = null;
|
||||
if ($this->add_custom_gitea_url == 2)
|
||||
{
|
||||
$paths = $this->params->get('super_powers_core_repos');
|
||||
}
|
||||
|
||||
// get the users own power repo (can overwrite all)
|
||||
if (!empty($this->gitea_username))
|
||||
if ($this->gitea_username !== null)
|
||||
{
|
||||
$repos[$this->gitea_username . '.super-powers'] = (object) ['owner' => $this->gitea_username, 'repo' => 'super-powers', 'branch' => 'master'];
|
||||
$repos[$this->gitea_username . '.super-powers'] = (object) [
|
||||
'organisation' => $this->gitea_username,
|
||||
'repository' => 'super-powers',
|
||||
'read_branch' => 'master'
|
||||
];
|
||||
}
|
||||
|
||||
if (!empty($paths) && is_array($paths))
|
||||
{
|
||||
foreach ($paths as $path)
|
||||
{
|
||||
$owner = $path->owner ?? null;
|
||||
$repo = $path->repo ?? null;
|
||||
if ($owner !== null && $repo !== null)
|
||||
{
|
||||
// we make sure to get only the objects
|
||||
$repos = ["{$owner}.{$repo}" => $path] + $repos;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$repos[$this->super_powers_core_organisation . '.super-powers'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'super-powers', 'branch' => 'master'];
|
||||
$repos[$this->super_powers_core_organisation . '.jcb-compiler'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'jcb-compiler', 'branch' => 'master'];
|
||||
$repos[$this->super_powers_core_organisation . '.jcb-packager'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'jcb-packager', 'branch' => 'master'];
|
||||
$repos[$this->super_powers_core_organisation . '.phpseclib'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'phpseclib', 'branch' => 'master'];
|
||||
$repos[$this->super_powers_core_organisation . '.search'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'search', 'branch' => 'master'];
|
||||
$repos[$this->super_powers_core_organisation . '.gitea'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'gitea', 'branch' => 'master'];
|
||||
$repos[$this->super_powers_core_organisation . '.openai'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'openai', 'branch' => 'master'];
|
||||
$repos[$this->super_powers_core_organisation . '.minify'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'minify', 'branch' => 'master'];
|
||||
$repos[$this->super_powers_core_organisation . '.psr'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'psr', 'branch' => 'master'];
|
||||
$repos[$this->super_powers_core_organisation . '.fof'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'fof', 'branch' => 'master'];
|
||||
}
|
||||
$repos[$this->super_powers_core_organisation . '.super-powers'] = (object) [
|
||||
'organisation' => $this->super_powers_core_organisation,
|
||||
'repository' => 'super-powers',
|
||||
'read_branch' => 'master'
|
||||
];
|
||||
$repos[$this->super_powers_core_organisation . '.jcb-compiler'] = (object) [
|
||||
'organisation' => $this->super_powers_core_organisation,
|
||||
'repository' => 'jcb-compiler',
|
||||
'read_branch' => 'master'
|
||||
];
|
||||
$repos[$this->super_powers_core_organisation . '.jcb-packager'] = (object) [
|
||||
'organisation' => $this->super_powers_core_organisation,
|
||||
'repository' => 'jcb-packager',
|
||||
'read_branch' => 'master'
|
||||
];
|
||||
$repos[$this->super_powers_core_organisation . '.phpseclib'] = (object) [
|
||||
'organisation' => $this->super_powers_core_organisation,
|
||||
'repository' => 'phpseclib',
|
||||
'read_branch' => 'master'
|
||||
];
|
||||
$repos[$this->super_powers_core_organisation . '.search'] = (object) [
|
||||
'organisation' => $this->super_powers_core_organisation,
|
||||
'repository' => 'search',
|
||||
'read_branch' => 'master'
|
||||
];
|
||||
$repos[$this->super_powers_core_organisation . '.gitea'] = (object) [
|
||||
'organisation' => $this->super_powers_core_organisation,
|
||||
'repository' => 'gitea',
|
||||
'read_branch' => 'master'
|
||||
];
|
||||
$repos[$this->super_powers_core_organisation . '.openai'] = (object) [
|
||||
'organisation' => $this->super_powers_core_organisation,
|
||||
'repository' => 'openai',
|
||||
'read_branch' => 'master'
|
||||
];
|
||||
$repos[$this->super_powers_core_organisation . '.minify'] = (object) [
|
||||
'organisation' => $this->super_powers_core_organisation,
|
||||
'repository' => 'minify',
|
||||
'read_branch' => 'master'
|
||||
];
|
||||
$repos[$this->super_powers_core_organisation . '.psr'] = (object) [
|
||||
'organisation' => $this->super_powers_core_organisation,
|
||||
'repository' => 'psr',
|
||||
'read_branch' => 'master'
|
||||
];
|
||||
$repos[$this->super_powers_core_organisation . '.fof'] = (object) [
|
||||
'organisation' => $this->super_powers_core_organisation,
|
||||
'repository' => 'fof',
|
||||
'read_branch' => 'master'
|
||||
];
|
||||
|
||||
return $repos;
|
||||
}
|
||||
@@ -830,19 +789,14 @@ class Config extends BaseConfig
|
||||
// some defaults repos we need by JCB
|
||||
$approved = $this->super_powers_core_repos;
|
||||
|
||||
if (!$this->add_own_powers)
|
||||
{
|
||||
return array_values($approved);
|
||||
}
|
||||
$paths = RepoHelper::get(1); // super powers = 1
|
||||
|
||||
$paths = $this->params->get('approved_paths');
|
||||
|
||||
if (!empty($paths))
|
||||
if ($paths !== null)
|
||||
{
|
||||
foreach ($paths as $path)
|
||||
{
|
||||
$owner = $path->owner ?? null;
|
||||
$repo = $path->repo ?? null;
|
||||
$owner = $path->organisation ?? null;
|
||||
$repo = $path->repository ?? null;
|
||||
if ($owner !== null && $repo !== null)
|
||||
{
|
||||
// we make sure to get only the objects
|
||||
@@ -879,11 +833,19 @@ class Config extends BaseConfig
|
||||
// some defaults repos we need by JCB
|
||||
$repos = [];
|
||||
// get the users own power repo (can overwrite all)
|
||||
if (!empty($this->gitea_username))
|
||||
if ($this->gitea_username !== null)
|
||||
{
|
||||
$repos[$this->gitea_username . '.joomla-powers'] = (object) ['owner' => $this->gitea_username, 'repo' => 'joomla-powers', 'branch' => 'master'];
|
||||
$repos[$this->gitea_username . '.joomla-powers'] = (object) [
|
||||
'organisation' => $this->gitea_username,
|
||||
'repository' => 'joomla-powers',
|
||||
'read_branch' => 'master'
|
||||
];
|
||||
}
|
||||
$repos[$this->joomla_powers_core_organisation . '.joomla-powers'] = (object) ['owner' => $this->joomla_powers_core_organisation, 'repo' => 'joomla-powers', 'branch' => 'master'];
|
||||
$repos[$this->joomla_powers_core_organisation . '.joomla-powers'] = (object) [
|
||||
'organisation' => $this->joomla_powers_core_organisation,
|
||||
'repository' => 'joomla-powers',
|
||||
'read_branch' => 'master'
|
||||
];
|
||||
|
||||
return $repos;
|
||||
}
|
||||
|
@@ -15,7 +15,9 @@ namespace VDM\Joomla\Componentbuilder\Compiler;
|
||||
use Joomla\DI\Container;
|
||||
use VDM\Joomla\Componentbuilder\Service\Crypt;
|
||||
use VDM\Joomla\Componentbuilder\Service\Server;
|
||||
use VDM\Joomla\Componentbuilder\Service\Database;
|
||||
use VDM\Joomla\Service\Database;
|
||||
use VDM\Joomla\Service\Model as BaseModel;
|
||||
use VDM\Joomla\Service\Data;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Service\Model;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Service\Compiler;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Service\Event;
|
||||
@@ -149,6 +151,8 @@ abstract class Factory implements FactoryInterface
|
||||
->registerServiceProvider(new Crypt())
|
||||
->registerServiceProvider(new Server())
|
||||
->registerServiceProvider(new Database())
|
||||
->registerServiceProvider(new BaseModel())
|
||||
->registerServiceProvider(new Data())
|
||||
->registerServiceProvider(new Model())
|
||||
->registerServiceProvider(new Compiler())
|
||||
->registerServiceProvider(new Event())
|
||||
|
@@ -21,7 +21,6 @@ use VDM\Joomla\Utilities\JsonHelper;
|
||||
use VDM\Joomla\Utilities\GuidHelper;
|
||||
use VDM\Joomla\Utilities\String\ClassfunctionHelper;
|
||||
use VDM\Joomla\Utilities\String\NamespaceHelper;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Config;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
|
||||
@@ -102,43 +101,43 @@ class Power implements PowerInterface
|
||||
protected array $retry = [];
|
||||
|
||||
/**
|
||||
* Compiler Config
|
||||
* The Config Class.
|
||||
*
|
||||
* @var Config
|
||||
* @var Config
|
||||
* @since 3.2.0
|
||||
**/
|
||||
*/
|
||||
protected Config $config;
|
||||
|
||||
/**
|
||||
* Compiler Placeholder
|
||||
* The Placeholder Class.
|
||||
*
|
||||
* @var Placeholder
|
||||
* @var Placeholder
|
||||
* @since 3.2.0
|
||||
**/
|
||||
*/
|
||||
protected Placeholder $placeholder;
|
||||
|
||||
/**
|
||||
* Compiler Customcode
|
||||
* The Customcode Class.
|
||||
*
|
||||
* @var Customcode
|
||||
* @var Customcode
|
||||
* @since 3.2.0
|
||||
**/
|
||||
*/
|
||||
protected Customcode $customcode;
|
||||
|
||||
/**
|
||||
* Compiler Customcode in Gui
|
||||
* The Gui Class.
|
||||
*
|
||||
* @var Gui
|
||||
* @var Gui
|
||||
* @since 3.2.0
|
||||
**/
|
||||
*/
|
||||
protected Gui $gui;
|
||||
|
||||
/**
|
||||
* The JCB Superpower class
|
||||
* The Super Class.
|
||||
*
|
||||
* @var Superpower
|
||||
* @var Superpower
|
||||
* @since 3.2.0
|
||||
**/
|
||||
*/
|
||||
protected Superpower $superpower;
|
||||
|
||||
/**
|
||||
@@ -158,23 +157,22 @@ class Power implements PowerInterface
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Config|null $config The compiler config object.
|
||||
* @param Placeholder|null $placeholder The compiler placeholder object.
|
||||
* @param Customcode|null $customcode The compiler customcode object.
|
||||
* @param Gui|null $gui The compiler customcode gui object.
|
||||
* @param Superpower|null $superpower The JCB superpower object.
|
||||
* @param Config $config The Config Class.
|
||||
* @param Placeholder $placeholder The Placeholder Class.
|
||||
* @param Customcode $customcode The Customcode Class.
|
||||
* @param Gui $gui The Gui Class.
|
||||
* @param Superpower $superpower The Super Class.
|
||||
*
|
||||
* @throws \Exception
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(?Config $config = null, ?Placeholder $placeholder = null,
|
||||
?Customcode $customcode = null, ?Gui $gui = null, ?Superpower $superpower = null)
|
||||
public function __construct(Config $config, Placeholder $placeholder,
|
||||
Customcode $customcode, Gui $gui, Superpower $superpower)
|
||||
{
|
||||
$this->config = $config ?: Compiler::_('Config');
|
||||
$this->placeholder = $placeholder ?: Compiler::_('Placeholder');
|
||||
$this->customcode = $customcode ?: Compiler::_('Customcode');
|
||||
$this->gui = $gui ?: Compiler::_('Customcode.Gui');
|
||||
$this->superpower = $superpower ?: Compiler::_('Superpower');
|
||||
$this->config = $config;
|
||||
$this->placeholder = $placeholder;
|
||||
$this->customcode = $customcode;
|
||||
$this->gui = $gui;
|
||||
$this->superpower = $superpower;
|
||||
$this->db = Factory::getDbo();
|
||||
$this->app = Factory::getApplication();
|
||||
}
|
||||
|
@@ -19,9 +19,6 @@ use VDM\Joomla\Componentbuilder\JoomlaPower\Grep;
|
||||
use VDM\Joomla\Componentbuilder\JoomlaPower\Super as Superpower;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\JoomlaPower\Extractor;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\JoomlaPower\Injector;
|
||||
use VDM\Joomla\Componentbuilder\JoomlaPower\Model\Upsert;
|
||||
use VDM\Joomla\Componentbuilder\JoomlaPower\Database\Insert;
|
||||
use VDM\Joomla\Componentbuilder\JoomlaPower\Database\Update;
|
||||
|
||||
|
||||
/**
|
||||
@@ -55,15 +52,6 @@ class JoomlaPower implements ServiceProviderInterface
|
||||
|
||||
$container->alias(Injector::class, 'Joomla.Power.Injector')
|
||||
->share('Joomla.Power.Injector', [$this, 'getInjector'], true);
|
||||
|
||||
$container->alias(Upsert::class, 'Joomla.Power.Model.Upsert')
|
||||
->share('Joomla.Power.Model.Upsert', [$this, 'getModelUpsert'], true);
|
||||
|
||||
$container->alias(Insert::class, 'Joomla.Power.Insert')
|
||||
->share('Joomla.Power.Insert', [$this, 'getInsert'], true);
|
||||
|
||||
$container->alias(Update::class, 'Joomla.Power.Update')
|
||||
->share('Joomla.Power.Update', [$this, 'getUpdate'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -97,8 +85,7 @@ class JoomlaPower implements ServiceProviderInterface
|
||||
{
|
||||
return new Superpower(
|
||||
$container->get('Joomla.Power.Grep'),
|
||||
$container->get('Joomla.Power.Insert'),
|
||||
$container->get('Joomla.Power.Update')
|
||||
$container->get('Data.Item')
|
||||
);
|
||||
}
|
||||
|
||||
@@ -149,53 +136,6 @@ class JoomlaPower implements ServiceProviderInterface
|
||||
$container->get('Power.Parser'),
|
||||
$container->get('Placeholder')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Power Model Upsert
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Upsert
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getModelUpsert(Container $container): Upsert
|
||||
{
|
||||
return new Upsert(
|
||||
$container->get('Table')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Power Insert
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Insert
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getInsert(Container $container): Insert
|
||||
{
|
||||
return new Insert(
|
||||
$container->get('Joomla.Power.Model.Upsert'),
|
||||
$container->get('Insert')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Power Update
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Update
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getUpdate(Container $container): Update
|
||||
{
|
||||
return new Update(
|
||||
$container->get('Joomla.Power.Model.Upsert'),
|
||||
$container->get('Update')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -15,10 +15,10 @@ namespace VDM\Joomla\Componentbuilder\Compiler\Service;
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Power as Powers;
|
||||
use VDM\Joomla\Componentbuilder\Power\Grep;
|
||||
use VDM\Joomla\Componentbuilder\Power\Super as Superpower;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Power\Infusion;
|
||||
use VDM\Joomla\Componentbuilder\Power\Grep;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Power\Autoloader;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Power\Infusion;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Power\Structure;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Power\Parser;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Power\Plantuml;
|
||||
@@ -26,9 +26,6 @@ use VDM\Joomla\Componentbuilder\Compiler\Power\Repo\Readme as RepoReadme;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Power\Repos\Readme as ReposReadme;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Power\Extractor;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Power\Injector;
|
||||
use VDM\Joomla\Componentbuilder\Power\Model\Upsert;
|
||||
use VDM\Joomla\Componentbuilder\Power\Database\Insert;
|
||||
use VDM\Joomla\Componentbuilder\Power\Database\Update;
|
||||
|
||||
|
||||
/**
|
||||
@@ -83,19 +80,10 @@ class Power implements ServiceProviderInterface
|
||||
|
||||
$container->alias(Injector::class, 'Power.Injector')
|
||||
->share('Power.Injector', [$this, 'getInjector'], true);
|
||||
|
||||
$container->alias(Upsert::class, 'Power.Model.Upsert')
|
||||
->share('Power.Model.Upsert', [$this, 'getModelUpsert'], true);
|
||||
|
||||
$container->alias(Insert::class, 'Power.Insert')
|
||||
->share('Power.Insert', [$this, 'getInsert'], true);
|
||||
|
||||
$container->alias(Update::class, 'Power.Update')
|
||||
->share('Power.Update', [$this, 'getUpdate'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Powers
|
||||
* Get The Power Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
@@ -108,12 +96,13 @@ class Power implements ServiceProviderInterface
|
||||
$container->get('Config'),
|
||||
$container->get('Placeholder'),
|
||||
$container->get('Customcode'),
|
||||
$container->get('Customcode.Gui')
|
||||
$container->get('Customcode.Gui'),
|
||||
$container->get('Superpower')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Superpower
|
||||
* Get The Super Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
@@ -124,13 +113,12 @@ class Power implements ServiceProviderInterface
|
||||
{
|
||||
return new Superpower(
|
||||
$container->get('Power.Grep'),
|
||||
$container->get('Power.Insert'),
|
||||
$container->get('Power.Update')
|
||||
$container->get('Data.Item')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Grep
|
||||
* Get The Grep Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
@@ -147,7 +135,7 @@ class Power implements ServiceProviderInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Compiler Autoloader
|
||||
* Get The Autoloader Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
@@ -164,7 +152,7 @@ class Power implements ServiceProviderInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Compiler Power Infusion
|
||||
* Get The Infusion Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
@@ -187,7 +175,7 @@ class Power implements ServiceProviderInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Compiler Power Structure Builder
|
||||
* Get The Structure Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
@@ -210,11 +198,11 @@ class Power implements ServiceProviderInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Compiler Power Parser
|
||||
* Get The Parser Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Structure
|
||||
* @return Parser
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getParser(Container $container): Parser
|
||||
@@ -223,7 +211,7 @@ class Power implements ServiceProviderInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Compiler Power Plantuml Builder
|
||||
* Get The Plantuml Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
@@ -236,7 +224,7 @@ class Power implements ServiceProviderInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Compiler Power Repo Readme Builder
|
||||
* Get The Readme Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
@@ -252,7 +240,7 @@ class Power implements ServiceProviderInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Compiler Power Repos Readme Builder
|
||||
* Get The Readme Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
@@ -268,7 +256,7 @@ class Power implements ServiceProviderInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Compiler Power Extractor
|
||||
* Get The Extractor Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
@@ -281,7 +269,7 @@ class Power implements ServiceProviderInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Compiler Power Injector
|
||||
* Get The Injector Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
@@ -296,53 +284,6 @@ class Power implements ServiceProviderInterface
|
||||
$container->get('Power.Parser'),
|
||||
$container->get('Placeholder')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Power Model Upsert
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Upsert
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getModelUpsert(Container $container): Upsert
|
||||
{
|
||||
return new Upsert(
|
||||
$container->get('Table')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Power Insert
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Insert
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getInsert(Container $container): Insert
|
||||
{
|
||||
return new Insert(
|
||||
$container->get('Power.Model.Upsert'),
|
||||
$container->get('Insert')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Power Update
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Update
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getUpdate(Container $container): Update
|
||||
{
|
||||
return new Update(
|
||||
$container->get('Power.Model.Upsert'),
|
||||
$container->get('Update')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,81 +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\Interfaces\Database;
|
||||
|
||||
|
||||
/**
|
||||
* Database Insert
|
||||
*
|
||||
* @since 3.2.1
|
||||
*/
|
||||
interface InsertInterface
|
||||
{
|
||||
/**
|
||||
* Insert a value to a given table
|
||||
* Example: $this->value(Value, 'value_key', 'GUID');
|
||||
*
|
||||
* @param mixed $value The field value
|
||||
* @param string $field The field key
|
||||
* @param string $keyValue The key value
|
||||
* @param string $key The key name
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function value($value, string $field, string $keyValue, string $key = 'guid'): bool;
|
||||
|
||||
/**
|
||||
* Insert single row with multiple values to a given table
|
||||
* Example: $this->item(Array);
|
||||
*
|
||||
* @param array $item The item to save
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function row(array $item): bool;
|
||||
|
||||
/**
|
||||
* Insert multiple rows to a given table
|
||||
* Example: $this->items(Array);
|
||||
*
|
||||
* @param array|null $items The items updated in database (array of arrays)
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function rows(?array $items): bool;
|
||||
|
||||
/**
|
||||
* Insert single item with multiple values to a given table
|
||||
* Example: $this->item(Object);
|
||||
*
|
||||
* @param object $item The item to save
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function item(object $item): bool;
|
||||
|
||||
/**
|
||||
* Insert multiple items to a given table
|
||||
* Example: $this->items(Array);
|
||||
*
|
||||
* @param array|null $items The items updated in database (array of objects)
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function items(?array $items): bool;
|
||||
|
||||
}
|
||||
|
@@ -1,80 +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\Interfaces\Database;
|
||||
|
||||
|
||||
/**
|
||||
* Database Update
|
||||
*
|
||||
* @since 3.2.1
|
||||
*/
|
||||
interface UpdateInterface
|
||||
{
|
||||
/**
|
||||
* Update a value to a given table
|
||||
* Example: $this->value(Value, 'value_key', 'GUID');
|
||||
*
|
||||
* @param mixed $value The field value
|
||||
* @param string $field The field key
|
||||
* @param string $keyValue The key value
|
||||
* @param string $key The key name
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function value($value, string $field, string $keyValue, string $key = 'guid'): bool;
|
||||
|
||||
/**
|
||||
* Update single row with multiple values to a given table
|
||||
* Example: $this->item(Array);
|
||||
*
|
||||
* @param array $item The item to save
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function row(array $item): bool;
|
||||
|
||||
/**
|
||||
* Update multiple rows to a given table
|
||||
* Example: $this->items(Array);
|
||||
*
|
||||
* @param array|null $items The items updated in database (array of arrays)
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function rows(?array $items): bool;
|
||||
|
||||
/**
|
||||
* Update single item with multiple values to a given table
|
||||
* Example: $this->item(Object);
|
||||
*
|
||||
* @param object $item The item to save
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function item(object $item): bool;
|
||||
|
||||
/**
|
||||
* Update multiple items to a given table
|
||||
* Example: $this->items(Array);
|
||||
*
|
||||
* @param array|null $items The items updated in database (array of objects)
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function items(?array $items): bool;
|
||||
}
|
||||
|
@@ -1 +0,0 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -1,52 +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\Interfaces;
|
||||
|
||||
|
||||
/**
|
||||
* Superpower of JCB
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
interface SuperInterface
|
||||
{
|
||||
/**
|
||||
* Init all power not found in database
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function init(): bool;
|
||||
|
||||
/**
|
||||
* Reset the powers
|
||||
*
|
||||
* @param array $powers The global unique ids of the powers
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function reset(array $powers): bool;
|
||||
|
||||
/**
|
||||
* Load a superpower
|
||||
*
|
||||
* @param string $guid The global unique id of the power
|
||||
* @param array $order The search order
|
||||
* @param string|null $action The action to load power
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function load(string $guid, array $order = ['remote', 'local'], ?string $action = null): bool;
|
||||
}
|
||||
|
@@ -65,7 +65,7 @@ class Config extends BaseConfig
|
||||
*/
|
||||
protected function getGiteausername(): ?string
|
||||
{
|
||||
return $this->custom_gitea_username ?? $this->params->get('gitea_username');
|
||||
return $this->params->get('gitea_username');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,66 +76,7 @@ class Config extends BaseConfig
|
||||
*/
|
||||
protected function getGiteatoken(): ?string
|
||||
{
|
||||
return $this->custom_gitea_token ?? $this->params->get('gitea_token');
|
||||
}
|
||||
|
||||
/**
|
||||
* get Add Custom Gitea URL
|
||||
*
|
||||
* @return int the add switch
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getAddcustomgiteaurl(): int
|
||||
{
|
||||
return $this->params->get('add_custom_gitea_url', 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* get Custom Gitea URL
|
||||
*
|
||||
* @return string the custom gitea url
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getCustomgiteaurl(): ?string
|
||||
{
|
||||
if ($this->add_custom_gitea_url == 2)
|
||||
{
|
||||
return $this->params->get('custom_gitea_url');
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* get Custom Gitea Username
|
||||
*
|
||||
* @return string the custom access token
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getCustomgiteausername(): ?string
|
||||
{
|
||||
if ($this->add_custom_gitea_url == 2)
|
||||
{
|
||||
return $this->params->get('custom_gitea_username');
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* get Custom Gitea Access Token
|
||||
*
|
||||
* @return string the custom access token
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getCustomgiteatoken(): ?string
|
||||
{
|
||||
if ($this->add_custom_gitea_url == 2)
|
||||
{
|
||||
return $this->params->get('custom_gitea_token');
|
||||
}
|
||||
|
||||
return null;
|
||||
return $this->params->get('gitea_token');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -165,9 +106,9 @@ class Config extends BaseConfig
|
||||
// get the users own power repo (can overwrite all)
|
||||
if (!empty($this->gitea_username))
|
||||
{
|
||||
$repos[$this->gitea_username . '.joomla-powers'] = (object) ['owner' => $this->gitea_username, 'repo' => 'joomla-powers', 'branch' => 'master'];
|
||||
$repos[$this->gitea_username . '.joomla-powers'] = (object) ['organisation' => $this->gitea_username, 'repository' => 'joomla-powers', 'read_branch' => 'master'];
|
||||
}
|
||||
$repos[$this->joomla_powers_core_organisation . '.joomla-powers'] = (object) ['owner' => $this->joomla_powers_core_organisation, 'repo' => 'joomla-powers', 'branch' => 'master'];
|
||||
$repos[$this->joomla_powers_core_organisation . '.joomla-powers'] = (object) ['organisation' => $this->joomla_powers_core_organisation, 'repository' => 'joomla-powers', 'read_branch' => 'master'];
|
||||
|
||||
return $repos;
|
||||
}
|
||||
@@ -183,7 +124,7 @@ class Config extends BaseConfig
|
||||
// some defaults repos we need by JCB
|
||||
if (!empty($this->gitea_username))
|
||||
{
|
||||
return (object) ['owner' => $this->gitea_username, 'repo' => 'joomla-powers', 'branch' => 'master'];
|
||||
return (object) ['organisation' => $this->gitea_username, 'repository' => 'joomla-powers', 'read_branch' => 'master'];
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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\Database;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Interfaces\Database\InsertInterface;
|
||||
use VDM\Joomla\Componentbuilder\Power\Database\Insert as ExtendingInsert;
|
||||
|
||||
|
||||
/**
|
||||
* Joomla Power Database Insert
|
||||
*
|
||||
* @since 3.2.1
|
||||
*/
|
||||
final class Insert extends ExtendingInsert implements InsertInterface
|
||||
{
|
||||
/**
|
||||
* Table Name
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.1
|
||||
*/
|
||||
protected string $table = 'power';
|
||||
}
|
||||
|
@@ -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\Database;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Power\Database\LoadInterface;
|
||||
use VDM\Joomla\Componentbuilder\Power\Database\Load as ExtendingLoad;
|
||||
|
||||
|
||||
/**
|
||||
* Power Database Load
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
final class Load extends ExtendingLoad implements LoadInterface
|
||||
{
|
||||
/**
|
||||
* Table Name
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.1
|
||||
*/
|
||||
protected string $table = 'joomla_power';
|
||||
}
|
||||
|
@@ -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\Database;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Interfaces\Database\UpdateInterface;
|
||||
use VDM\Joomla\Componentbuilder\Power\Database\Update as ExtendingUpdate;
|
||||
|
||||
|
||||
/**
|
||||
* Joomla Power Database Update
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class Update extends ExtendingUpdate implements UpdateInterface
|
||||
{
|
||||
/**
|
||||
* Table Name
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.1
|
||||
*/
|
||||
protected string $table = 'joomla_power';
|
||||
}
|
||||
|
@@ -1 +0,0 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -14,8 +14,9 @@ namespace VDM\Joomla\Componentbuilder\JoomlaPower;
|
||||
|
||||
use Joomla\DI\Container;
|
||||
use VDM\Joomla\Componentbuilder\JoomlaPower\Service\JoomlaPower as Power;
|
||||
use VDM\Joomla\Componentbuilder\Service\Database;
|
||||
use VDM\Joomla\Componentbuilder\JoomlaPower\Service\Database as PowerDatabase;
|
||||
use VDM\Joomla\Service\Database;
|
||||
use VDM\Joomla\Service\Model;
|
||||
use VDM\Joomla\Service\Data;
|
||||
use VDM\Joomla\Componentbuilder\Service\Gitea;
|
||||
use VDM\Joomla\Componentbuilder\Power\Service\Gitea as GiteaPower;
|
||||
use VDM\Joomla\Gitea\Service\Utilities as GiteaUtilities;
|
||||
@@ -77,7 +78,8 @@ abstract class Factory implements FactoryInterface
|
||||
return (new Container())
|
||||
->registerServiceProvider(new Power())
|
||||
->registerServiceProvider(new Database())
|
||||
->registerServiceProvider(new PowerDatabase())
|
||||
->registerServiceProvider(new Model())
|
||||
->registerServiceProvider(new Data())
|
||||
->registerServiceProvider(new Gitea())
|
||||
->registerServiceProvider(new GiteaPower())
|
||||
->registerServiceProvider(new GiteaUtilities());
|
||||
|
@@ -56,7 +56,9 @@ final class Grep extends ExtendingGrep implements GrepInterface
|
||||
|
||||
try
|
||||
{
|
||||
$path->index = $this->contents->get($path->owner, $path->repo, 'joomla-powers.json', $path->branch);
|
||||
$this->contents->load_($path->base ?? null, $path->token ?? null);
|
||||
$path->index = $this->contents->get($path->organisation, $path->repository, 'joomla-powers.json', $path->read_branch);
|
||||
$this->contents->reset_();
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
@@ -108,46 +110,43 @@ final class Grep extends ExtendingGrep implements GrepInterface
|
||||
*/
|
||||
protected function getRemote(object $path, string $guid): ?object
|
||||
{
|
||||
$power = null;
|
||||
if (empty($path->index->{$guid}->settings))
|
||||
{
|
||||
return null;
|
||||
return $power;
|
||||
}
|
||||
|
||||
// get the settings
|
||||
if (($power = $this->loadRemoteFile($path->owner, $path->repo, $path->index->{$guid}->settings, $path->branch)) !== null &&
|
||||
$this->contents->load_($path->base ?? null, $path->token ?? null);
|
||||
if (($power = $this->loadRemoteFile($path->organisation, $path->repository, $path->index->{$guid}->settings, $path->read_branch)) !== null &&
|
||||
isset($power->guid))
|
||||
{
|
||||
// set the git details in params
|
||||
$power->params = (object) [
|
||||
'git' => [
|
||||
'owner' => $path->owner,
|
||||
'repo' => $path->repo,
|
||||
'branch' => $path->branch
|
||||
]
|
||||
'source' => ['guid' => $path->guid ?? null]
|
||||
];
|
||||
|
||||
return $power;
|
||||
}
|
||||
$this->contents->reset_();
|
||||
|
||||
return null;
|
||||
return $power;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the remote file
|
||||
*
|
||||
* @param string $owner The repository owner
|
||||
* @param string $repo The repository name
|
||||
* @param string $path The repository path to file
|
||||
* @param string|null $branch The repository branch name
|
||||
* @param string $organisation The repository organisation
|
||||
* @param string $repository The repository name
|
||||
* @param string $path The repository path to file
|
||||
* @param string|null $branch The repository branch name
|
||||
*
|
||||
* @return mixed
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function loadRemoteFile(string $owner, string $repo, string $path, ?string $branch)
|
||||
protected function loadRemoteFile(string $organisation, string $repository, string $path, ?string $branch)
|
||||
{
|
||||
try
|
||||
{
|
||||
$data = $this->contents->get($owner, $repo, $path, $branch);
|
||||
$data = $this->contents->get($organisation, $repository, $path, $branch);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
|
@@ -1,37 +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\Model;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\ModelInterface;
|
||||
use VDM\Joomla\Componentbuilder\Power\Model\Load as ExtendingLoad;
|
||||
|
||||
|
||||
/**
|
||||
* Joomla Power Model Load
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class Load extends ExtendingLoad implements ModelInterface
|
||||
{
|
||||
/**
|
||||
* Get the current active table
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getTable(): string
|
||||
{
|
||||
return 'joomla_power';
|
||||
}
|
||||
}
|
||||
|
@@ -1,38 +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\Model;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\ModelInterface;
|
||||
use VDM\Joomla\Componentbuilder\Power\Model\Upsert as ExtendingUpsert;
|
||||
|
||||
|
||||
/**
|
||||
* Joomla Power Model Update or Insert
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class Upsert extends ExtendingUpsert implements ModelInterface
|
||||
{
|
||||
/**
|
||||
* Get the current active table
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getTable(): string
|
||||
{
|
||||
return 'joomla_power';
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1 +0,0 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -1,135 +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\Service;
|
||||
|
||||
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use VDM\Joomla\Componentbuilder\JoomlaPower\Model\Load as ModelLoad;
|
||||
use VDM\Joomla\Componentbuilder\JoomlaPower\Model\Upsert as ModelUpsert;
|
||||
use VDM\Joomla\Componentbuilder\JoomlaPower\Database\Load as LoadDatabase;
|
||||
use VDM\Joomla\Componentbuilder\JoomlaPower\Database\Insert as InsertDatabase;
|
||||
use VDM\Joomla\Componentbuilder\JoomlaPower\Database\Update as UpdateDatabase;
|
||||
|
||||
|
||||
/**
|
||||
* Database Service Provider
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Database implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->alias(ModelLoad::class, 'Joomla.Power.Model.Load')
|
||||
->share('Joomla.Power.Model.Load', [$this, 'getModelLoad'], true);
|
||||
|
||||
$container->alias(ModelUpsert::class, 'Joomla.Power.Model.Upsert')
|
||||
->share('Joomla.Power.Model.Upsert', [$this, 'getModelUpsert'], true);
|
||||
|
||||
$container->alias(LoadDatabase::class, 'Joomla.Power.Database.Load')
|
||||
->share('Joomla.Power.Database.Load', [$this, 'getLoadDatabase'], true);
|
||||
|
||||
$container->alias(InsertDatabase::class, 'Joomla.Power.Database.Insert')
|
||||
->share('Joomla.Power.Database.Insert', [$this, 'getInsertDatabase'], true);
|
||||
|
||||
$container->alias(UpdateDatabase::class, 'Joomla.Power.Database.Update')
|
||||
->share('Joomla.Power.Database.Update', [$this, 'getUpdateDatabase'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Power Model Load
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return ModelLoad
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getModelLoad(Container $container): ModelLoad
|
||||
{
|
||||
return new ModelLoad(
|
||||
$container->get('Table')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Power Model Update or Insert
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return ModelUpsert
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getModelUpsert(Container $container): ModelUpsert
|
||||
{
|
||||
return new ModelUpsert(
|
||||
$container->get('Table')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Load Database
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return LoadDatabase
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getLoadDatabase(Container $container): LoadDatabase
|
||||
{
|
||||
return new LoadDatabase(
|
||||
$container->get('Joomla.Power.Model.Load'),
|
||||
$container->get('Load')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Insert Database
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return InsertDatabase
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getInsertDatabase(Container $container): InsertDatabase
|
||||
{
|
||||
return new InsertDatabase(
|
||||
$container->get('Joomla.Power.Model.Upsert'),
|
||||
$container->get('Insert')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Update Database
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return UpdateDatabase
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getUpdateDatabase(Container $container): UpdateDatabase
|
||||
{
|
||||
return new UpdateDatabase(
|
||||
$container->get('Joomla.Power.Model.Upsert'),
|
||||
$container->get('Update')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -108,8 +108,7 @@ class JoomlaPower implements ServiceProviderInterface
|
||||
{
|
||||
return new Superpower(
|
||||
$container->get('Joomla.Power.Grep'),
|
||||
$container->get('Joomla.Power.Database.Insert'),
|
||||
$container->get('Joomla.Power.Database.Update')
|
||||
$container->get('Data.Item')
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -12,8 +12,8 @@
|
||||
namespace VDM\Joomla\Componentbuilder\JoomlaPower;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Interfaces\SuperInterface;
|
||||
use VDM\Joomla\Componentbuilder\Power\Super as ExtendingSuper;
|
||||
use VDM\Joomla\Interfaces\Data\RemoteInterface;
|
||||
use VDM\Joomla\Data\Remote;
|
||||
|
||||
|
||||
/**
|
||||
@@ -21,7 +21,7 @@ use VDM\Joomla\Componentbuilder\Power\Super as ExtendingSuper;
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class Super extends ExtendingSuper implements SuperInterface
|
||||
final class Super extends Remote implements RemoteInterface
|
||||
{
|
||||
/**
|
||||
* Table Name
|
||||
|
@@ -13,9 +13,11 @@ namespace VDM\Joomla\Componentbuilder\Power;
|
||||
|
||||
|
||||
use Joomla\Registry\Registry as JoomlaRegistry;
|
||||
use Joomla\CMS\Factory as JoomlaFactory;
|
||||
use Joomla\CMS\Factory as JoomlaFactory;
|
||||
use Joomla\Input\Input;
|
||||
use VDM\Joomla\Utilities\GetHelper;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Componentbuilder\Utilities\RepoHelper;
|
||||
use VDM\Joomla\Componentbuilder\Abstraction\BaseConfig;
|
||||
|
||||
|
||||
@@ -43,9 +45,9 @@ class Config extends BaseConfig
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Input|null $input Input
|
||||
* @param Registry|null $params The component parameters
|
||||
* @param Registry|null $config The Joomla configuration
|
||||
* @param Input|null $input Input
|
||||
* @param JoomlaRegistry|null $params The component parameters
|
||||
* @param JoomlaRegistry|null $config The Joomla configuration
|
||||
*
|
||||
* @throws \Exception
|
||||
* @since 3.2.0
|
||||
@@ -65,7 +67,7 @@ class Config extends BaseConfig
|
||||
*/
|
||||
protected function getGiteausername(): ?string
|
||||
{
|
||||
return $this->custom_gitea_username ?? $this->params->get('gitea_username');
|
||||
return $this->params->get('gitea_username');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -76,66 +78,7 @@ class Config extends BaseConfig
|
||||
*/
|
||||
protected function getGiteatoken(): ?string
|
||||
{
|
||||
return $this->custom_gitea_token ?? $this->params->get('gitea_token');
|
||||
}
|
||||
|
||||
/**
|
||||
* get Add Custom Gitea URL
|
||||
*
|
||||
* @return int the add switch
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getAddcustomgiteaurl(): int
|
||||
{
|
||||
return $this->params->get('add_custom_gitea_url', 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* get Custom Gitea URL
|
||||
*
|
||||
* @return string the custom gitea url
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getCustomgiteaurl(): ?string
|
||||
{
|
||||
if ($this->add_custom_gitea_url == 2)
|
||||
{
|
||||
return $this->params->get('custom_gitea_url');
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* get Custom Gitea Username
|
||||
*
|
||||
* @return string the custom access token
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getCustomgiteausername(): ?string
|
||||
{
|
||||
if ($this->add_custom_gitea_url == 2)
|
||||
{
|
||||
return $this->params->get('custom_gitea_username');
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* get Custom Gitea Access Token
|
||||
*
|
||||
* @return string the custom access token
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getCustomgiteatoken(): ?string
|
||||
{
|
||||
if ($this->add_custom_gitea_url == 2)
|
||||
{
|
||||
return $this->params->get('custom_gitea_token');
|
||||
}
|
||||
|
||||
return null;
|
||||
return $this->params->get('gitea_token');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -149,11 +92,6 @@ class Config extends BaseConfig
|
||||
// the VDM default organisation is [joomla]
|
||||
$organisation = 'joomla';
|
||||
|
||||
if ($this->add_custom_gitea_url == 2)
|
||||
{
|
||||
return $this->params->get('super_powers_core_organisation', $organisation);
|
||||
}
|
||||
|
||||
return $organisation;
|
||||
}
|
||||
|
||||
@@ -168,38 +106,31 @@ class Config extends BaseConfig
|
||||
// some defaults repos we need by JCB
|
||||
$repos = [];
|
||||
|
||||
// only add custom init with custom gitea
|
||||
$paths = null;
|
||||
if ($this->add_custom_gitea_url == 2)
|
||||
{
|
||||
$paths = $this->params->get('super_powers_init_repos');
|
||||
}
|
||||
|
||||
// get the users own power repo (can overwrite all)
|
||||
if (!empty($this->gitea_username))
|
||||
if ($this->gitea_username !== null)
|
||||
{
|
||||
$repos[$this->gitea_username . '.super-powers'] = (object) ['owner' => $this->gitea_username, 'repo' => 'super-powers', 'branch' => 'master'];
|
||||
$repos[$this->gitea_username . '.super-powers'] = (object) [
|
||||
'organisation' => $this->gitea_username,
|
||||
'repository' => 'super-powers',
|
||||
'read_branch' => 'master'
|
||||
];
|
||||
}
|
||||
|
||||
if (!empty($paths) && is_array($paths))
|
||||
{
|
||||
foreach ($paths as $path)
|
||||
{
|
||||
$owner = $path->owner ?? null;
|
||||
$repo = $path->repo ?? null;
|
||||
if ($owner !== null && $repo !== null)
|
||||
{
|
||||
// we make sure to get only the objects
|
||||
$repos = ["{$owner}.{$repo}" => $path] + $repos;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$repos[$this->super_powers_core_organisation . '.super-powers'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'super-powers', 'branch' => 'master'];
|
||||
$repos[$this->super_powers_core_organisation . '.gitea'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'gitea', 'branch' => 'master'];
|
||||
$repos[$this->super_powers_core_organisation . '.openai'] = (object) ['owner' => $this->super_powers_core_organisation, 'repo' => 'openai', 'branch' => 'master'];
|
||||
}
|
||||
$repos[$this->super_powers_core_organisation . '.super-powers'] = (object) [
|
||||
'organisation' => $this->super_powers_core_organisation,
|
||||
'repository' => 'super-powers',
|
||||
'read_branch' => 'master'
|
||||
];
|
||||
$repos[$this->super_powers_core_organisation . '.gitea'] = (object) [
|
||||
'organisation' => $this->super_powers_core_organisation,
|
||||
'repository' => 'gitea',
|
||||
'read_branch' => 'master'
|
||||
];
|
||||
$repos[$this->super_powers_core_organisation . '.openai'] = (object) [
|
||||
'organisation' => $this->super_powers_core_organisation,
|
||||
'repository' => 'openai',
|
||||
'read_branch' => 'master'
|
||||
];
|
||||
|
||||
return $repos;
|
||||
}
|
||||
@@ -212,9 +143,13 @@ class Config extends BaseConfig
|
||||
*/
|
||||
protected function getSuperpowerspushrepo(): ?object
|
||||
{
|
||||
if (!empty($this->gitea_username))
|
||||
if ($this->gitea_username !== null)
|
||||
{
|
||||
return (object) ['owner' => $this->gitea_username, 'repo' => 'super-powers', 'branch' => 'master'];
|
||||
return (object) [
|
||||
'organisation' => $this->gitea_username,
|
||||
'repository' => 'super-powers',
|
||||
'read_branch' => 'master'
|
||||
];
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -288,19 +223,14 @@ class Config extends BaseConfig
|
||||
// some defaults repos we need by JCB
|
||||
$approved = $this->super_powers_init_repos;
|
||||
|
||||
if (!$this->add_own_powers)
|
||||
{
|
||||
return array_values($approved);
|
||||
}
|
||||
$paths = RepoHelper::get(1); // super powers = 1
|
||||
|
||||
$paths = $this->params->get('approved_paths');
|
||||
|
||||
if (!empty($paths))
|
||||
if ($paths !== null)
|
||||
{
|
||||
foreach ($paths as $path)
|
||||
{
|
||||
$owner = $path->owner ?? null;
|
||||
$repo = $path->repo ?? null;
|
||||
$owner = $path->organisation ?? null;
|
||||
$repo = $path->repository ?? null;
|
||||
if ($owner !== null && $repo !== null)
|
||||
{
|
||||
// we make sure to get only the objects
|
||||
|
@@ -1,168 +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\Power\Database;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\ModelInterface as Model;
|
||||
use VDM\Joomla\Database\Insert as Database;
|
||||
use VDM\Joomla\Componentbuilder\Interfaces\Database\InsertInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Power Database Insert
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Insert implements InsertInterface
|
||||
{
|
||||
/**
|
||||
* Model
|
||||
*
|
||||
* @var Model
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Model $model;
|
||||
|
||||
/**
|
||||
* Database
|
||||
*
|
||||
* @var Database
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Database $database;
|
||||
|
||||
/**
|
||||
* Table Name
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.1
|
||||
*/
|
||||
protected string $table = 'power';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Model $model The set model object.
|
||||
* @param Database $database The insert database object.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(Model $model, Database $database)
|
||||
{
|
||||
$this->model = $model;
|
||||
$this->database = $database;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a value to a given table
|
||||
* Example: $this->value(Value, 'value_key', 'GUID');
|
||||
*
|
||||
* @param mixed $value The field value
|
||||
* @param string $field The field key
|
||||
* @param string $keyValue The key value
|
||||
* @param string $key The key name
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function value($value, string $field, string $keyValue, string $key = 'guid'): bool
|
||||
{
|
||||
// build the array
|
||||
$item = [];
|
||||
$item[$key] = $keyValue;
|
||||
$item[$field] = $value;
|
||||
|
||||
// Insert the column of this table
|
||||
return $this->row($item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert single row with multiple values to a given table
|
||||
* Example: $this->item(Array);
|
||||
*
|
||||
* @param array $item The item to save
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function row(array $item): bool
|
||||
{
|
||||
// check if object could be modelled
|
||||
if (($item = $this->model->row($item, $this->table)) !== null)
|
||||
{
|
||||
// Insert the column of this table
|
||||
return $this->database->row($item, $this->table);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert multiple rows to a given table
|
||||
* Example: $this->items(Array);
|
||||
*
|
||||
* @param array|null $items The items updated in database (array of arrays)
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function rows(?array $items): bool
|
||||
{
|
||||
// check if object could be modelled
|
||||
if (($items = $this->model->rows($items, $this->table)) !== null)
|
||||
{
|
||||
// Insert the column of this table
|
||||
return $this->database->rows($items, $this->table);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert single item with multiple values to a given table
|
||||
* Example: $this->item(Object);
|
||||
*
|
||||
* @param object $item The item to save
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function item(object $item): bool
|
||||
{
|
||||
// check if object could be modelled
|
||||
if (($item = $this->model->item($item, $this->table)) !== null)
|
||||
{
|
||||
// Insert the column of this table
|
||||
return $this->database->item($item, $this->table);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert multiple items to a given table
|
||||
* Example: $this->items(Array);
|
||||
*
|
||||
* @param array|null $items The items updated in database (array of objects)
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function items(?array $items): bool
|
||||
{
|
||||
// check if object could be modelled
|
||||
if (($items = $this->model->items($items, $this->table)) !== null)
|
||||
{
|
||||
// Update the column of this table using guid as the primary key.
|
||||
return $this->database->items($items, $this->table);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@@ -1,167 +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\Power\Database;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\ModelInterface as Model;
|
||||
use VDM\Joomla\Database\Load as Database;
|
||||
use VDM\Joomla\Componentbuilder\Power\Database\LoadInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Power Database Load
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
class Load implements LoadInterface
|
||||
{
|
||||
/**
|
||||
* Model Load
|
||||
*
|
||||
* @var Model
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected Model $model;
|
||||
|
||||
/**
|
||||
* Database Load
|
||||
*
|
||||
* @var Database
|
||||
* @since 2.0.1
|
||||
*/
|
||||
protected Database $load;
|
||||
|
||||
/**
|
||||
* Table Name
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.1
|
||||
*/
|
||||
protected string $table = 'power';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Table $table The core table object.
|
||||
* @param Model $model The model object.
|
||||
* @param Database $load The database object.
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function __construct(Model $model, Database $load)
|
||||
{
|
||||
$this->model = $model;
|
||||
$this->load = $load;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a value from a given table
|
||||
* Example: $this->value(
|
||||
* [
|
||||
* 'guid' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
|
||||
* ], 'value_key'
|
||||
* );
|
||||
*
|
||||
* @param array $keys The item keys
|
||||
* @param string $field The field key
|
||||
* @param string $table The table
|
||||
*
|
||||
* @return mixed
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function value(array $keys, string $field)
|
||||
{
|
||||
return $this->model->value(
|
||||
$this->load->value(
|
||||
["a.{$field}" => $field],
|
||||
['a' => $this->table],
|
||||
$this->prefix($keys)
|
||||
),
|
||||
$field,
|
||||
$this->table
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get values from a given table
|
||||
* Example: $this->item(
|
||||
* [
|
||||
* 'guid' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
|
||||
* ]
|
||||
* );
|
||||
*
|
||||
* @param array $keys The item keys
|
||||
* @param string $table The table
|
||||
*
|
||||
* @return object|null
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function item(array $keys): ?object
|
||||
{
|
||||
return $this->model->item(
|
||||
$this->load->item(
|
||||
['all' => 'a.*'],
|
||||
['a' => $this->table],
|
||||
$this->prefix($keys)
|
||||
),
|
||||
$this->table
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get values from a given table
|
||||
* Example: $this->items(
|
||||
* [
|
||||
* 'guid' => [
|
||||
* 'operator' => 'IN',
|
||||
* 'value' => [''xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'', ''xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'']
|
||||
* ]
|
||||
* ]
|
||||
* );
|
||||
* Example: $this->items($ids, 'table_name');
|
||||
*
|
||||
* @param array $keys The item keys
|
||||
* @param string $table The table
|
||||
*
|
||||
* @return array|null
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function items(array $keys): ?array
|
||||
{
|
||||
return $this->model->items(
|
||||
$this->load->items(
|
||||
['all' => 'a.*'], ['a' => $this->table], $this->prefix($keys)
|
||||
),
|
||||
$this->table
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add prefix to the keys
|
||||
*
|
||||
* @param array $keys The query keys
|
||||
*
|
||||
* @return array
|
||||
* @since 2.0.1
|
||||
*/
|
||||
private function prefix(array &$keys): array
|
||||
{
|
||||
// update the key values
|
||||
$bucket = [];
|
||||
foreach ($keys as $k => $v)
|
||||
{
|
||||
$bucket['a.' . $k] = $v;
|
||||
}
|
||||
return $bucket;
|
||||
}
|
||||
}
|
||||
|
@@ -1,75 +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\Power\Database;
|
||||
|
||||
|
||||
/**
|
||||
* Power Database Load
|
||||
*
|
||||
* @since 2.0.1
|
||||
*/
|
||||
interface LoadInterface
|
||||
{
|
||||
/**
|
||||
* Get a value from a given table
|
||||
* Example: $this->value(
|
||||
* [
|
||||
* 'guid' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
|
||||
* ], 'value_key'
|
||||
* );
|
||||
*
|
||||
* @param array $keys The item keys
|
||||
* @param string $field The field key
|
||||
* @param string $table The table
|
||||
*
|
||||
* @return mixed
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function value(array $keys, string $field);
|
||||
|
||||
/**
|
||||
* Get values from a given table
|
||||
* Example: $this->item(
|
||||
* [
|
||||
* 'guid' => 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
|
||||
* ]
|
||||
* );
|
||||
*
|
||||
* @param array $keys The item keys
|
||||
* @param string $table The table
|
||||
*
|
||||
* @return object|null
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function item(array $keys): ?object;
|
||||
|
||||
/**
|
||||
* Get values from a given table
|
||||
* Example: $this->items(
|
||||
* [
|
||||
* 'guid' => [
|
||||
* 'operator' => 'IN',
|
||||
* 'value' => [''xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'', ''xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'']
|
||||
* ]
|
||||
* ]
|
||||
* );
|
||||
* Example: $this->items($ids, 'table_name');
|
||||
*
|
||||
* @param array $keys The item keys
|
||||
* @param string $table The table
|
||||
*
|
||||
* @return array|null
|
||||
* @since 2.0.1
|
||||
*/
|
||||
public function items(array $keys): ?array;
|
||||
}
|
||||
|
@@ -1,168 +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\Power\Database;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\ModelInterface as Model;
|
||||
use VDM\Joomla\Database\Update as Database;
|
||||
use VDM\Joomla\Componentbuilder\Interfaces\Database\UpdateInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Power Database Update
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Update implements UpdateInterface
|
||||
{
|
||||
/**
|
||||
* Model
|
||||
*
|
||||
* @var Model
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Model $model;
|
||||
|
||||
/**
|
||||
* Database
|
||||
*
|
||||
* @var Database
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected Database $database;
|
||||
|
||||
/**
|
||||
* Table Name
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.1
|
||||
*/
|
||||
protected string $table = 'power';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param Model $model The set model object.
|
||||
* @param Database $database The update database object.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(Model $model, Database $database)
|
||||
{
|
||||
$this->model = $model;
|
||||
$this->database = $database;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a value to a given table
|
||||
* Example: $this->value(Value, 'value_key', 'GUID');
|
||||
*
|
||||
* @param mixed $value The field value
|
||||
* @param string $field The field key
|
||||
* @param string $keyValue The key value
|
||||
* @param string $key The key name
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function value($value, string $field, string $keyValue, string $key = 'guid'): bool
|
||||
{
|
||||
// build the array
|
||||
$item = [];
|
||||
$item[$key] = $keyValue;
|
||||
$item[$field] = $value;
|
||||
|
||||
// Update the column of this table using guid as the primary key.
|
||||
return $this->row($item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update single row with multiple values to a given table
|
||||
* Example: $this->item(Array);
|
||||
*
|
||||
* @param array $item The item to save
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function row(array $item): bool
|
||||
{
|
||||
// check if object could be modelled
|
||||
if (($item = $this->model->row($item, $this->table)) !== null)
|
||||
{
|
||||
// Update the column of this table using guid as the primary key.
|
||||
return $this->database->row($item, 'guid', $this->table);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update multiple rows to a given table
|
||||
* Example: $this->items(Array);
|
||||
*
|
||||
* @param array|null $items The items updated in database (array of arrays)
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function rows(?array $items): bool
|
||||
{
|
||||
// check if object could be modelled
|
||||
if (($items = $this->model->rows($items, $this->table)) !== null)
|
||||
{
|
||||
// Update the column of this table using guid as the primary key.
|
||||
return $this->database->rows($items, 'guid', $this->table);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update single item with multiple values to a given table
|
||||
* Example: $this->item(Object);
|
||||
*
|
||||
* @param object $item The item to save
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function item(object $item): bool
|
||||
{
|
||||
// check if object could be modelled
|
||||
if (($item = $this->model->item($item, $this->table)) !== null)
|
||||
{
|
||||
// Update the column of this table using guid as the primary key.
|
||||
return $this->database->item($item, 'guid', $this->table);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update multiple items to a given table
|
||||
* Example: $this->items(Array);
|
||||
*
|
||||
* @param array|null $items The items updated in database (array of objects)
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function items(?array $items): bool
|
||||
{
|
||||
// check if object could be modelled
|
||||
if (($items = $this->model->items($items, $this->table)) !== null)
|
||||
{
|
||||
// Update the column of this table using guid as the primary key.
|
||||
return $this->database->items($items, 'guid', $this->table);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@@ -1 +0,0 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -14,8 +14,9 @@ namespace VDM\Joomla\Componentbuilder\Power;
|
||||
|
||||
use Joomla\DI\Container;
|
||||
use VDM\Joomla\Componentbuilder\Power\Service\Power;
|
||||
use VDM\Joomla\Componentbuilder\Service\Database;
|
||||
use VDM\Joomla\Componentbuilder\Power\Service\Database as PowerDatabase;
|
||||
use VDM\Joomla\Service\Database;
|
||||
use VDM\Joomla\Service\Model;
|
||||
use VDM\Joomla\Service\Data;
|
||||
use VDM\Joomla\Componentbuilder\Power\Service\Generator;
|
||||
use VDM\Joomla\Componentbuilder\Service\Gitea;
|
||||
use VDM\Joomla\Componentbuilder\Power\Service\Gitea as GiteaPower;
|
||||
@@ -78,7 +79,8 @@ abstract class Factory implements FactoryInterface
|
||||
return (new Container())
|
||||
->registerServiceProvider(new Power())
|
||||
->registerServiceProvider(new Database())
|
||||
->registerServiceProvider(new PowerDatabase())
|
||||
->registerServiceProvider(new Model())
|
||||
->registerServiceProvider(new Data())
|
||||
->registerServiceProvider(new Generator())
|
||||
->registerServiceProvider(new Gitea())
|
||||
->registerServiceProvider(new GiteaPower())
|
||||
|
@@ -12,7 +12,7 @@
|
||||
namespace VDM\Joomla\Componentbuilder\Power\Generator;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Power\Database\Load as Database;
|
||||
use VDM\Joomla\Data\Action\Load as Database;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Power\Parser;
|
||||
use VDM\Joomla\Componentbuilder\Power\Generator\Bucket;
|
||||
use VDM\Joomla\Utilities\String\ClassfunctionHelper;
|
||||
@@ -77,7 +77,7 @@ final class Search
|
||||
{
|
||||
if (($power = $this->bucket->get("power.{$guid}")) === null)
|
||||
{
|
||||
if (($power = $this->database->item(['guid' => $guid])) === null)
|
||||
if (($power = $this->database->table('power')->item(['guid' => $guid])) === null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -255,7 +255,7 @@ final class Search
|
||||
{
|
||||
if (($service_providers = $this->bucket->get("service_providers.{$guid}")) === null)
|
||||
{
|
||||
if (($powers = $this->database->items([
|
||||
if (($powers = $this->database->table('power')->items([
|
||||
'use_selection' => [
|
||||
'operator' => 'LIKE',
|
||||
'value' => "'%{$guid}%'",
|
||||
|
@@ -48,14 +48,28 @@ final class Grep extends ExtendingGrep implements GrepInterface
|
||||
|
||||
try
|
||||
{
|
||||
$path->index = $this->contents->get($path->owner, $path->repo, 'super-powers.json', $path->branch);
|
||||
$this->contents->load_($path->base ?? null, $path->token ?? null);
|
||||
$path->index = $this->contents->get($path->organisation, $path->repository, 'super-powers.json', $path->read_branch);
|
||||
$this->contents->reset_();
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
$this->app->enqueueMessage(
|
||||
Text::sprintf('COM_COMPONENTBUILDER_PSUPER_POWERB_REPOSITORY_AT_BSSB_GAVE_THE_FOLLOWING_ERRORBR_SP', $this->contents->api(), $path->path, $e->getMessage()),
|
||||
'Error'
|
||||
);
|
||||
if ('super-powers' === $path->repository && 'joomla' !== $path->organisation && (empty($path->base) || $path->base === 'https://git.vdm.dev'))
|
||||
{
|
||||
// give heads-up about the overriding feature
|
||||
$this->app->enqueueMessage(
|
||||
Text::sprintf('COM_COMPONENTBUILDER_PSUPER_POWERB_REPOSITORY_AT_BHTTPSGITVDMDEVSB_CAN_BE_USED_TO_OVERRIDE_ANY_POWERBR_BUT_HAS_NOT_YET_BEEN_SET_IN_YOUR_ACCOUNT_AT_HTTPSGITVDMDEVSBR_SMALLTHIS_IS_AND_OPTIONAL_FEATURESMALL', $path->path, $path->organisation),
|
||||
'Message'
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
// give error
|
||||
$this->app->enqueueMessage(
|
||||
Text::sprintf('COM_COMPONENTBUILDER_PSUPER_POWERB_REPOSITORY_AT_BSSB_GAVE_THE_FOLLOWING_ERRORBR_SP', $this->contents->api(), $path->path, $e->getMessage()),
|
||||
'Error'
|
||||
);
|
||||
}
|
||||
|
||||
$path->index = null;
|
||||
}
|
||||
@@ -161,50 +175,48 @@ final class Grep extends ExtendingGrep implements GrepInterface
|
||||
*/
|
||||
protected function getRemote(object $path, string $guid): ?object
|
||||
{
|
||||
$power = null;
|
||||
if (empty($path->index->{$guid}->settings) || empty($path->index->{$guid}->code))
|
||||
{
|
||||
return null;
|
||||
return $power;
|
||||
}
|
||||
|
||||
// get the settings
|
||||
if (($power = $this->loadRemoteFile($path->owner, $path->repo, $path->index->{$guid}->settings, $path->branch)) !== null &&
|
||||
$this->contents->load_($path->base ?? null, $path->token ?? null);
|
||||
if (($power = $this->loadRemoteFile($path->organisation, $path->repository, $path->index->{$guid}->settings, $path->read_branch)) !== null &&
|
||||
isset($power->guid))
|
||||
{
|
||||
// get the code
|
||||
if (($code = $this->loadRemoteFile($path->owner, $path->repo, $path->index->{$guid}->power, $path->branch)) !== null)
|
||||
if (($code = $this->loadRemoteFile($path->organisation, $path->repository, $path->index->{$guid}->power, $path->read_branch)) !== null)
|
||||
{
|
||||
// set the git details in params
|
||||
$power->params = (object) [
|
||||
'git' => [
|
||||
'owner' => $path->owner,
|
||||
'repo' => $path->repo,
|
||||
'branch' => $path->branch
|
||||
]
|
||||
'source' => ['guid' => $path->guid ?? null]
|
||||
];
|
||||
$power->main_class_code = $code;
|
||||
return $power;
|
||||
}
|
||||
}
|
||||
$this->contents->reset_();
|
||||
|
||||
return null;
|
||||
return $power;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the remote file
|
||||
*
|
||||
* @param string $owner The repository owner
|
||||
* @param string $repo The repository name
|
||||
* @param string $path The repository path to file
|
||||
* @param string|null $branch The repository branch name
|
||||
* @param string $organisation The repository organisation
|
||||
* @param string $repository The repository name
|
||||
* @param string $path The repository path to file
|
||||
* @param string|null $branch The repository branch name
|
||||
*
|
||||
* @return mixed
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function loadRemoteFile(string $owner, string $repo, string $path, ?string $branch)
|
||||
protected function loadRemoteFile(string $organisation, string $repository, string $path, ?string $branch)
|
||||
{
|
||||
try
|
||||
{
|
||||
$data = $this->contents->get($owner, $repo, $path, $branch);
|
||||
$data = $this->contents->get($organisation, $repository, $path, $branch);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
|
@@ -1,119 +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\Power\Model;
|
||||
|
||||
|
||||
use VDM\Joomla\Abstraction\Model as AbstractionModel;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Utilities\ObjectHelper;
|
||||
use VDM\Joomla\Interfaces\ModelInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Power Model Load
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Load extends AbstractionModel implements ModelInterface
|
||||
{
|
||||
/**
|
||||
* Model the value
|
||||
* Example: $this->value(value, 'field_key', 'table_name');
|
||||
*
|
||||
* @param mixed $value The value to model
|
||||
* @param string $field The field key
|
||||
* @param string|null $table The table
|
||||
*
|
||||
* @return mixed
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function value($value, string $field, ?string $table = null)
|
||||
{
|
||||
// set the table name
|
||||
if (empty($table))
|
||||
{
|
||||
$table = $this->getTable();
|
||||
}
|
||||
|
||||
// check if this is a valid table
|
||||
if (($store = $this->table->get($table, $field, 'store')) !== null)
|
||||
{
|
||||
// open the value based on the store method
|
||||
switch($store)
|
||||
{
|
||||
case 'base64':
|
||||
$value = base64_decode((string) $value);
|
||||
break;
|
||||
case 'json':
|
||||
$value = json_decode($value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate before the value is modelled
|
||||
*
|
||||
* @param mixed $value The field value
|
||||
* @param string|null $field The field key
|
||||
* @param string|null $table The table
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function validateBefore(&$value, ?string $field = null, ?string $table = null): bool
|
||||
{
|
||||
// only strings or numbers allowed
|
||||
if (StringHelper::check($value) || is_numeric($value))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
// remove empty values
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate after the value is modelled
|
||||
*
|
||||
* @param mixed $value The field value
|
||||
* @param string|null $field The field key
|
||||
* @param string|null $table The table
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function validateAfter(&$value, ?string $field = null, ?string $table = null): bool
|
||||
{
|
||||
// only strings or numbers allowed
|
||||
if (StringHelper::check($value) || ArrayHelper::check($value, true) || ObjectHelper::check($value) || is_numeric($value))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
// remove empty values
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current active table
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getTable(): string
|
||||
{
|
||||
return 'power';
|
||||
}
|
||||
}
|
||||
|
@@ -1,120 +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\Power\Model;
|
||||
|
||||
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Utilities\ObjectHelper;
|
||||
use VDM\Joomla\Interfaces\ModelInterface;
|
||||
use VDM\Joomla\Abstraction\Model;
|
||||
|
||||
|
||||
/**
|
||||
* Power Model Update or Insert
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Upsert extends Model implements ModelInterface
|
||||
{
|
||||
/**
|
||||
* Model the value
|
||||
* Example: $this->value(value, 'field_key', 'table_name');
|
||||
*
|
||||
* @param mixed $value The value to model
|
||||
* @param string $field The field key
|
||||
* @param string|null $table The table
|
||||
*
|
||||
* @return mixed
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function value($value, string $field, ?string $table = null)
|
||||
{
|
||||
// set the table name
|
||||
if (empty($table))
|
||||
{
|
||||
$table = $this->getTable();
|
||||
}
|
||||
|
||||
// check if this is a valid table
|
||||
if (($store = $this->table->get($table, $field, 'store')) !== null)
|
||||
{
|
||||
// open the value based on the store method
|
||||
switch($store)
|
||||
{
|
||||
case 'base64':
|
||||
$value = base64_encode((string) $value);
|
||||
break;
|
||||
case 'json':
|
||||
$value = json_encode($value, JSON_FORCE_OBJECT);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate before the value is modelled
|
||||
*
|
||||
* @param mixed $value The field value
|
||||
* @param string|null $field The field key
|
||||
* @param string|null $table The table
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function validateBefore(&$value, ?string $field = null, ?string $table = null): bool
|
||||
{
|
||||
// check values
|
||||
if (StringHelper::check($value) || ArrayHelper::check($value, true) || ObjectHelper::check($value) || is_numeric($value))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
// remove empty values
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate after the value is modelled
|
||||
*
|
||||
* @param mixed $value The field value
|
||||
* @param string|null $field The field key
|
||||
* @param string|null $table The table
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function validateAfter(&$value, ?string $field = null, ?string $table = null): bool
|
||||
{
|
||||
// only strings or numbers allowed
|
||||
if (StringHelper::check($value) || is_numeric($value))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
// remove empty values
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current active table
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getTable(): string
|
||||
{
|
||||
return 'power';
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1 +0,0 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -1,135 +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\Power\Service;
|
||||
|
||||
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use VDM\Joomla\Componentbuilder\Power\Model\Load as ModelLoad;
|
||||
use VDM\Joomla\Componentbuilder\Power\Model\Upsert as ModelUpsert;
|
||||
use VDM\Joomla\Componentbuilder\Power\Database\Load as LoadDatabase;
|
||||
use VDM\Joomla\Componentbuilder\Power\Database\Insert as InsertDatabase;
|
||||
use VDM\Joomla\Componentbuilder\Power\Database\Update as UpdateDatabase;
|
||||
|
||||
|
||||
/**
|
||||
* Database Service Provider
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Database implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->alias(ModelLoad::class, 'Power.Model.Load')
|
||||
->share('Power.Model.Load', [$this, 'getModelLoad'], true);
|
||||
|
||||
$container->alias(ModelUpsert::class, 'Power.Model.Upsert')
|
||||
->share('Power.Model.Upsert', [$this, 'getModelUpsert'], true);
|
||||
|
||||
$container->alias(LoadDatabase::class, 'Power.Database.Load')
|
||||
->share('Power.Database.Load', [$this, 'getLoadDatabase'], true);
|
||||
|
||||
$container->alias(InsertDatabase::class, 'Power.Database.Insert')
|
||||
->share('Power.Database.Insert', [$this, 'getInsertDatabase'], true);
|
||||
|
||||
$container->alias(UpdateDatabase::class, 'Power.Database.Update')
|
||||
->share('Power.Database.Update', [$this, 'getUpdateDatabase'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Power Model Load
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return ModelLoad
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getModelLoad(Container $container): ModelLoad
|
||||
{
|
||||
return new ModelLoad(
|
||||
$container->get('Table')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Power Model Update or Insert
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return ModelUpsert
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getModelUpsert(Container $container): ModelUpsert
|
||||
{
|
||||
return new ModelUpsert(
|
||||
$container->get('Table')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Load Database
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return LoadDatabase
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getLoadDatabase(Container $container): LoadDatabase
|
||||
{
|
||||
return new LoadDatabase(
|
||||
$container->get('Power.Model.Load'),
|
||||
$container->get('Load')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Insert Database
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return InsertDatabase
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getInsertDatabase(Container $container): InsertDatabase
|
||||
{
|
||||
return new InsertDatabase(
|
||||
$container->get('Power.Model.Upsert'),
|
||||
$container->get('Insert')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Update Database
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return UpdateDatabase
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getUpdateDatabase(Container $container): UpdateDatabase
|
||||
{
|
||||
return new UpdateDatabase(
|
||||
$container->get('Power.Model.Upsert'),
|
||||
$container->get('Update')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -121,7 +121,7 @@ class Generator implements ServiceProviderInterface
|
||||
public function getSearch(Container $container): Search
|
||||
{
|
||||
return new Search(
|
||||
$container->get('Power.Database.Load'),
|
||||
$container->get('Data.Load'),
|
||||
$container->get('Power.Parser'),
|
||||
$container->get('Power.Generator.Bucket')
|
||||
);
|
||||
|
@@ -109,8 +109,7 @@ class Power implements ServiceProviderInterface
|
||||
{
|
||||
return new Superpower(
|
||||
$container->get('Power.Grep'),
|
||||
$container->get('Power.Database.Insert'),
|
||||
$container->get('Power.Database.Update')
|
||||
$container->get('Data.Item')
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -12,11 +12,8 @@
|
||||
namespace VDM\Joomla\Componentbuilder\Power;
|
||||
|
||||
|
||||
use VDM\Joomla\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;
|
||||
use VDM\Joomla\Interfaces\Data\RemoteInterface;
|
||||
use VDM\Joomla\Data\Remote;
|
||||
|
||||
|
||||
/**
|
||||
@@ -24,171 +21,14 @@ use VDM\Joomla\Componentbuilder\Interfaces\SuperInterface;
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Super implements SuperInterface
|
||||
final class Super extends Remote implements RemoteInterface
|
||||
{
|
||||
/**
|
||||
* The Power Search Tool
|
||||
*
|
||||
* @var Grep
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected Grep $grep;
|
||||
|
||||
/**
|
||||
* Insert Data Class
|
||||
*
|
||||
* @var Insert
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected Insert $insert;
|
||||
|
||||
/**
|
||||
* Update Data Class
|
||||
*
|
||||
* @var Update
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected Update $update;
|
||||
|
||||
/**
|
||||
* Table Name
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.1
|
||||
*/
|
||||
protected string $table = 'power';
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Grep $grep The Power Grep object.
|
||||
* @param Insert $insert The Power Database Insert object.
|
||||
* @param Update $update The Power Database Update object.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(Grep $grep, Insert $insert, Update $update)
|
||||
{
|
||||
$this->grep = $grep;
|
||||
$this->insert = $insert;
|
||||
$this->update = $update;
|
||||
}
|
||||
|
||||
/**
|
||||
* Init all power not found in database
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function init(): bool
|
||||
{
|
||||
if (($powers = $this->grep->getRemotePowersGuid()) !== null)
|
||||
{
|
||||
foreach($powers as $guid)
|
||||
{
|
||||
if ($this->action($guid) === 'insert' && ($power = $this->grep->get($guid, ['remote'])) !== null)
|
||||
{
|
||||
$this->insert($power);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the powers
|
||||
*
|
||||
* @param array $powers The global unique ids of the powers
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function reset(array $powers): bool
|
||||
{
|
||||
if ($powers === [])
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$success = true;
|
||||
|
||||
foreach($powers as $guid)
|
||||
{
|
||||
if (!$this->load($guid, ['remote']))
|
||||
{
|
||||
$success = false;
|
||||
}
|
||||
}
|
||||
|
||||
return $success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load a superpower
|
||||
*
|
||||
* @param string $guid The global unique id of the power
|
||||
* @param array $order The search order
|
||||
* @param string|null $action The action to load power
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function load(string $guid, array $order = ['remote', 'local'], ?string $action = null): bool
|
||||
{
|
||||
if (($power = $this->grep->get($guid, $order)) !== null &&
|
||||
($action !== null || ($action = $this->action($power->guid)) !== null))
|
||||
{
|
||||
return method_exists($this, $action) ? $this->{$action}($power) : false;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert a superpower
|
||||
*
|
||||
* @param object $power The power
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function insert(object $power): bool
|
||||
{
|
||||
return $this->insert->item($power);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a superpower
|
||||
*
|
||||
* @param object $power The power
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function update(object $power): bool
|
||||
{
|
||||
return $this->update->item($power);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get loading action
|
||||
*
|
||||
* @param string $guid The global unique id of the power
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function action(string $guid): string
|
||||
{
|
||||
if (($id = GuidHelper::item($guid, $this->table)) !== null && $id > 0)
|
||||
{
|
||||
return 'update';
|
||||
}
|
||||
|
||||
return 'insert';
|
||||
}
|
||||
protected string $table = 'power';
|
||||
}
|
||||
|
||||
|
@@ -1,88 +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\Service;
|
||||
|
||||
|
||||
use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use VDM\Joomla\Database\Load;
|
||||
use VDM\Joomla\Database\Insert;
|
||||
use VDM\Joomla\Database\Update;
|
||||
|
||||
|
||||
/**
|
||||
* Database Service Provider
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Database implements ServiceProviderInterface
|
||||
{
|
||||
/**
|
||||
* Registers the service provider with a DI container.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function register(Container $container)
|
||||
{
|
||||
$container->alias(Load::class, 'Load')
|
||||
->share('Load', [$this, 'getLoad'], true);
|
||||
|
||||
$container->alias(Insert::class, 'Insert')
|
||||
->share('Insert', [$this, 'getInsert'], true);
|
||||
|
||||
$container->alias(Update::class, 'Update')
|
||||
->share('Update', [$this, 'getUpdate'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Core Load Database
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Load
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getLoad(Container $container): Load
|
||||
{
|
||||
return new Load();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Core Insert Database
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Insert
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getInsert(Container $container): Insert
|
||||
{
|
||||
return new Insert();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Core Update Database
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Update
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getUpdate(Container $container): Update
|
||||
{
|
||||
return new Update();
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -465,6 +465,42 @@ abstract class FilterHelper
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* get available repositories of target area
|
||||
*
|
||||
* @param int $target The target area
|
||||
*
|
||||
* @return array|null The result ids
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public static function repositories(int $target): ?array
|
||||
{
|
||||
$db = Factory::getDbo();
|
||||
$query = $db->getQuery(true);
|
||||
$query
|
||||
->select($db->quoteName(array('repository', 'organisation')))
|
||||
->from($db->quoteName('#__componentbuilder_repository'))
|
||||
->where($db->quoteName('published') . ' >= 1')
|
||||
->where($db->quoteName('target') . ' = ' . $target)
|
||||
->order($db->quoteName('ordering') . ' desc');
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
$items = $db->loadObjectList();
|
||||
$options = [];
|
||||
foreach($items as $item)
|
||||
{
|
||||
$path = $item->organisation . '/' . $item->repository;
|
||||
$options[$path] = $path;
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a component admin views IDs
|
||||
*
|
||||
|
@@ -0,0 +1,78 @@
|
||||
<?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\Utilities;
|
||||
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
|
||||
|
||||
/**
|
||||
* Repositories Helper
|
||||
*
|
||||
* @since 3.2.2
|
||||
*/
|
||||
abstract class RepoHelper
|
||||
{
|
||||
/**
|
||||
* get available repositories of target area
|
||||
*
|
||||
* @param int $target The target area
|
||||
*
|
||||
* @return array|null The result set
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public static function get(int $target): ?array
|
||||
{
|
||||
$db = Factory::getDbo();
|
||||
$query = $db->getQuery(true);
|
||||
$query->select($db->quoteName(array(
|
||||
'type',
|
||||
'base',
|
||||
'organisation',
|
||||
'repository',
|
||||
'read_branch',
|
||||
'write_branch',
|
||||
'token',
|
||||
'username',
|
||||
'target',
|
||||
'access_repo',
|
||||
'guid'
|
||||
)))
|
||||
->from($db->quoteName('#__componentbuilder_repository'))
|
||||
->where($db->quoteName('published') . ' >= 1')
|
||||
->where($db->quoteName('target') . ' = ' . $target)
|
||||
->order($db->quoteName('ordering') . ' desc');
|
||||
$db->setQuery($query);
|
||||
$db->execute();
|
||||
|
||||
if ($db->getNumRows())
|
||||
{
|
||||
$items = $db->loadObjectList();
|
||||
$options = [];
|
||||
foreach($items as $item)
|
||||
{
|
||||
if ($item->access_repo != 1)
|
||||
{
|
||||
unset($item->username);
|
||||
unset($item->token);
|
||||
}
|
||||
unset($item->access_repo);
|
||||
$path = $item->organisation . '/' . $item->repository;
|
||||
$options[$path] = $item;
|
||||
}
|
||||
return $options;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user