Release of v4.0.1-beta1
Fix subform set methods. Improved the Joomla Power Push path. Fix the metadata, metadesc, metakey database issue.
This commit is contained in:
@@ -23,7 +23,7 @@ use VDM\Joomla\Utilities\String\FieldHelper;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Config;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Placeholder\Reverse;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Power\Parser;
|
||||
use VDM\Joomla\Componentbuilder\Power\Parser;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Customcode\GuiInterface;
|
||||
|
||||
|
||||
|
@@ -10476,14 +10476,30 @@ class Interpretation extends Fields
|
||||
// check if default field was overwritten
|
||||
if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.metadesc'))
|
||||
{
|
||||
$db_ .= PHP_EOL . Indent::_(1)
|
||||
. "`metadesc` TEXT NOT NULL,";
|
||||
if (CFactory::_('Config')->get('joomla_version', 3) == 3)
|
||||
{
|
||||
$db_ .= PHP_EOL . Indent::_(1)
|
||||
. "`metadesc` TEXT NOT NULL,";
|
||||
}
|
||||
else
|
||||
{
|
||||
$db_ .= PHP_EOL . Indent::_(1)
|
||||
. "`metadesc` TEXT,";
|
||||
}
|
||||
}
|
||||
// check if default field was overwritten
|
||||
if (!CFactory::_('Compiler.Builder.Field.Names')->isString($view . '.metadata'))
|
||||
{
|
||||
$db_ .= PHP_EOL . Indent::_(1)
|
||||
. "`metadata` TEXT NOT NULL,";
|
||||
if (CFactory::_('Config')->get('joomla_version', 3) == 3)
|
||||
{
|
||||
$db_ .= PHP_EOL . Indent::_(1)
|
||||
. "`metadata` TEXT NOT NULL,";
|
||||
}
|
||||
else
|
||||
{
|
||||
$db_ .= PHP_EOL . Indent::_(1)
|
||||
. "`metadata` TEXT,";
|
||||
}
|
||||
}
|
||||
// add to component dynamic fields
|
||||
CFactory::_('Compiler.Builder.Component.Fields')->set($view . '.metakey',
|
||||
@@ -10495,8 +10511,7 @@ class Interpretation extends Fields
|
||||
'store' => NULL,
|
||||
'tab_name' => 'publishing',
|
||||
'db' => [
|
||||
'type' => 'TEXT',
|
||||
'default' => ''
|
||||
'type' => 'TEXT'
|
||||
]
|
||||
]
|
||||
);
|
||||
@@ -10509,8 +10524,7 @@ class Interpretation extends Fields
|
||||
'store' => NULL,
|
||||
'tab_name' => 'publishing',
|
||||
'db' => [
|
||||
'type' => 'TEXT',
|
||||
'default' => ''
|
||||
'type' => 'TEXT'
|
||||
]
|
||||
]
|
||||
);
|
||||
@@ -10523,8 +10537,7 @@ class Interpretation extends Fields
|
||||
'store' => 'json',
|
||||
'tab_name' => 'publishing',
|
||||
'db' => [
|
||||
'type' => 'TEXT',
|
||||
'default' => ''
|
||||
'type' => 'TEXT'
|
||||
]
|
||||
]
|
||||
);
|
||||
|
@@ -19,7 +19,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Config;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
|
||||
use VDM\Joomla\Componentbuilder\JoomlaPower\Super as SuperPower;
|
||||
use VDM\Joomla\Componentbuilder\JoomlaPower\Remote\Get as SuperPower;
|
||||
use VDM\Joomla\Utilities\ArrayHelper;
|
||||
use VDM\Joomla\Utilities\JsonHelper;
|
||||
use VDM\Joomla\Utilities\GuidHelper;
|
||||
@@ -377,7 +377,7 @@ final class JoomlaPower implements PowerInterface
|
||||
*/
|
||||
private function handlePowerNotFound(string $guid): bool
|
||||
{
|
||||
if (empty($this->retry[$guid]) && $this->superpower->load($guid, ['remote', 'local']))
|
||||
if (empty($this->retry[$guid]) && $this->superpower->item($guid, ['remote', 'local']))
|
||||
{
|
||||
// Retry loading the power
|
||||
unset($this->state[$guid]);
|
||||
|
@@ -25,7 +25,7 @@ use VDM\Joomla\Componentbuilder\Compiler\Config;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Customcode;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Gui;
|
||||
use VDM\Joomla\Componentbuilder\Power\Super as Superpower;
|
||||
use VDM\Joomla\Componentbuilder\Power\Remote\Get as Superpower;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\PowerInterface;
|
||||
|
||||
|
||||
@@ -1148,7 +1148,7 @@ class Power implements PowerInterface
|
||||
$repo = $global_path . '/' . $path;
|
||||
|
||||
// set SuperPowerKey (spk)
|
||||
$spk = 'Super_'.'_' . str_replace('-', '_', $guid) . '_'.'_Power';
|
||||
$spk = 'Super---' . str_replace('-', '_', $guid) . '---Power';
|
||||
|
||||
// set the global super power
|
||||
$this->superpowers[$repo][$guid] = [
|
||||
|
@@ -78,9 +78,17 @@ class Autoloader
|
||||
$this->content->set('ADMIN_POWER_HELPER', '');
|
||||
$this->content->set('SITE_POWER_HELPER', '');
|
||||
$this->content->set('PLUGIN_POWER_AUTOLOADER', '');
|
||||
$this->content->set('CUSTOM_POWER_AUTOLOADER', '');
|
||||
$this->content->set('SITE_PLUGIN_POWER_AUTOLOADER', '');
|
||||
$this->content->set('SITE_CUSTOM_POWER_AUTOLOADER', '');
|
||||
$this->content->set('POWER_AUTOLOADER', '');
|
||||
$this->content->set('ONE_POWER_AUTOLOADER', '');
|
||||
$this->content->set('TWO_POWER_AUTOLOADER', '');
|
||||
$this->content->set('THREE_POWER_AUTOLOADER', '');
|
||||
$this->content->set('FOUR_POWER_AUTOLOADER', '');
|
||||
$this->content->set('SITE_POWER_AUTOLOADER', '');
|
||||
$this->content->set('SITE_ONE_POWER_AUTOLOADER', '');
|
||||
$this->content->set('SITE_TWO_POWER_AUTOLOADER', '');
|
||||
$this->content->set('SITE_THREE_POWER_AUTOLOADER', '');
|
||||
$this->content->set('SITE_FOUR_POWER_AUTOLOADER', '');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -91,13 +99,25 @@ class Autoloader
|
||||
*/
|
||||
public function setFiles()
|
||||
{
|
||||
// check if we are using a plugin
|
||||
// for plugins
|
||||
$this->content->set('PLUGIN_POWER_AUTOLOADER', PHP_EOL . PHP_EOL . $this->getAutoloaderFile(2));
|
||||
$this->content->set('SITE_PLUGIN_POWER_AUTOLOADER', PHP_EOL . PHP_EOL . $this->getAutoloaderFile(2, 'JPATH_SITE'));
|
||||
|
||||
// for site spaced special cases
|
||||
$this->content->set('SITE_ONE_POWER_AUTOLOADER', $this->getAutoloaderFile(1, 'JPATH_SITE'));
|
||||
$this->content->set('SITE_TWO_POWER_AUTOLOADER', $this->getAutoloaderFile(2, 'JPATH_SITE'));
|
||||
$this->content->set('SITE_THREE_POWER_AUTOLOADER', $this->getAutoloaderFile(3, 'JPATH_SITE'));
|
||||
$this->content->set('SITE_FOUR_POWER_AUTOLOADER', $this->getAutoloaderFile(4, 'JPATH_SITE'));
|
||||
|
||||
// for admin spaced special cases
|
||||
$this->content->set('ONE_POWER_AUTOLOADER', $this->getAutoloaderFile(1));
|
||||
$this->content->set('TWO_POWER_AUTOLOADER', $this->getAutoloaderFile(2));
|
||||
$this->content->set('THREE_POWER_AUTOLOADER', $this->getAutoloaderFile(3));
|
||||
$this->content->set('FOUR_POWER_AUTOLOADER', $this->getAutoloaderFile(4));
|
||||
|
||||
// to add to custom files
|
||||
$this->content->add('CUSTOM_POWER_AUTOLOADER', $this->getAutoloaderFile(0));
|
||||
$this->content->add('SITE_CUSTOM_POWER_AUTOLOADER', $this->getAutoloaderFile(0, 'JPATH_SITE'));
|
||||
$this->content->add('POWER_AUTOLOADER', $this->getAutoloaderFile(0));
|
||||
$this->content->add('SITE_POWER_AUTOLOADER', $this->getAutoloaderFile(0, 'JPATH_SITE'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -16,9 +16,9 @@ use VDM\Joomla\Componentbuilder\Compiler\Config;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Power;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentOne as Content;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Builder\ContentMulti as Contents;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Power\Parser;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Power\Repo\Readme as RepoReadme;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Power\Repos\Readme as ReposReadme;
|
||||
use VDM\Joomla\Componentbuilder\Power\Parser;
|
||||
use VDM\Joomla\Interfaces\Readme\ItemInterface as ItemReadme;
|
||||
use VDM\Joomla\Interfaces\Readme\MainInterface as MainReadme;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\EventInterface as Event;
|
||||
use VDM\Joomla\Utilities\StringHelper;
|
||||
@@ -75,18 +75,18 @@ class Infusion
|
||||
/**
|
||||
* The Readme Class.
|
||||
*
|
||||
* @var RepoReadme
|
||||
* @var ItemReadme
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected RepoReadme $reporeadme;
|
||||
protected ItemReadme $itemreadme;
|
||||
|
||||
/**
|
||||
* The Readme Class.
|
||||
*
|
||||
* @var ReposReadme
|
||||
* @var MainReadme
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected ReposReadme $reposreadme;
|
||||
protected MainReadme $mainreadme;
|
||||
|
||||
/**
|
||||
* The Placeholder Class.
|
||||
@@ -165,16 +165,16 @@ class Infusion
|
||||
* @param Content $content The ContentOne Class.
|
||||
* @param Contents $contents The ContentMulti Class.
|
||||
* @param Parser $parser The Parser Class.
|
||||
* @param RepoReadme $reporeadme The Readme Class.
|
||||
* @param ReposReadme $reposreadme The Readme Class.
|
||||
* @param ItemReadme $itemreadme The Readme Class.
|
||||
* @param MainReadme $mainreadme The Readme Class.
|
||||
* @param Placeholder $placeholder The Placeholder Class.
|
||||
* @param Event $event The EventInterface Class.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(Config $config, Power $power, Content $content,
|
||||
Contents $contents, Parser $parser, RepoReadme $reporeadme,
|
||||
ReposReadme $reposreadme, Placeholder $placeholder,
|
||||
Contents $contents, Parser $parser, ItemReadme $itemreadme,
|
||||
MainReadme $mainreadme, Placeholder $placeholder,
|
||||
Event $event)
|
||||
{
|
||||
$this->config = $config;
|
||||
@@ -182,8 +182,8 @@ class Infusion
|
||||
$this->content = $content;
|
||||
$this->contents = $contents;
|
||||
$this->parser = $parser;
|
||||
$this->reporeadme = $reporeadme;
|
||||
$this->reposreadme = $reposreadme;
|
||||
$this->itemreadme = $itemreadme;
|
||||
$this->mainreadme = $mainreadme;
|
||||
$this->placeholder = $placeholder;
|
||||
$this->event = $event;
|
||||
}
|
||||
@@ -273,7 +273,7 @@ class Infusion
|
||||
}
|
||||
|
||||
// POWERREADME
|
||||
$this->contents->set("{$key}|POWERREADME", $this->reposreadme->get($powers));
|
||||
$this->contents->set("{$key}|POWERREADME", $this->mainreadme->get($powers));
|
||||
|
||||
// sort all powers
|
||||
$this->sortPowers($powers);
|
||||
@@ -355,7 +355,7 @@ class Infusion
|
||||
$this->contents->set("{$power->key}|POWERLINKER", $this->linker($power));
|
||||
|
||||
// POWERLINKER
|
||||
$this->contents->set("{$power->key}|POWERREADME", $this->reporeadme->get($power));
|
||||
$this->contents->set("{$power->key}|POWERREADME", $this->itemreadme->get($power));
|
||||
|
||||
// Trigger Event: jcb_ce_onAfterInfusePowerData
|
||||
$this->event->trigger(
|
||||
|
@@ -14,7 +14,7 @@ namespace VDM\Joomla\Componentbuilder\Compiler\Power;
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\PowerInterface as Power;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Power\ExtractorInterface as Extractor;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Power\Parser;
|
||||
use VDM\Joomla\Componentbuilder\Power\Parser;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Placeholder;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Power\InjectorInterface;
|
||||
|
||||
|
@@ -1,107 +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\Compiler\Power\Repo;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Power;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Power\Plantuml;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Power Repo Readme
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Readme
|
||||
{
|
||||
/**
|
||||
* Power Objects
|
||||
*
|
||||
* @var Power
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected Power $power;
|
||||
|
||||
/**
|
||||
* Compiler Powers Plantuml Builder
|
||||
*
|
||||
* @var Plantuml
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected Plantuml $plantuml;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Power|null $power The power object.
|
||||
* @param Plantuml|null $plantuml The powers plantuml builder object.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(?Power $power = null, ?Plantuml $plantuml = null)
|
||||
{
|
||||
$this->power = $power ?: Compiler::_('Power');
|
||||
$this->plantuml = $plantuml ?: Compiler::_('Power.Plantuml');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a Power Readme
|
||||
*
|
||||
* @param object $power A power details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(object $power): string
|
||||
{
|
||||
// build readme
|
||||
$readme = ["```
|
||||
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||
```"];
|
||||
// add the class diagram
|
||||
$parsed_class_code = [];
|
||||
if (isset($power->parsed_class_code) && is_array($power->parsed_class_code))
|
||||
{
|
||||
$parsed_class_code = $power->parsed_class_code;
|
||||
}
|
||||
|
||||
$readme[] = "# " . $power->type . " " . $power->code_name . " (Details)";
|
||||
$readme[] = "> namespace: **" . $power->_namespace . "**";
|
||||
if ($power->extends != 0)
|
||||
{
|
||||
$readme[] = "> extends: **" . $power->extends_name . "**";
|
||||
}
|
||||
$readme[] = "```uml\n@startuml" . $this->plantuml->classDetailedDiagram(
|
||||
['name' => $power->code_name, 'type' => $power->type],
|
||||
$parsed_class_code
|
||||
) . " \n@enduml\n```";
|
||||
|
||||
// yes you can remove this, but why?
|
||||
$readme[] = "\n---\n```
|
||||
██╗ ██████╗██████╗
|
||||
██║██╔════╝██╔══██╗
|
||||
██║██║ ██████╔╝
|
||||
██ ██║██║ ██╔══██╗
|
||||
╚█████╔╝╚██████╗██████╔╝
|
||||
╚════╝ ╚═════╝╚═════╝
|
||||
```\n> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)\n\n";
|
||||
|
||||
return implode("\n", $readme);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -16,7 +16,7 @@ use Joomla\DI\Container;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\JoomlaPower as Powers;
|
||||
use VDM\Joomla\Componentbuilder\JoomlaPower\Grep;
|
||||
use VDM\Joomla\Componentbuilder\JoomlaPower\Super as Superpower;
|
||||
use VDM\Joomla\Componentbuilder\JoomlaPower\Remote\Get;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\JoomlaPower\Extractor;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\JoomlaPower\Injector;
|
||||
|
||||
@@ -41,8 +41,8 @@ class JoomlaPower implements ServiceProviderInterface
|
||||
$container->alias(Powers::class, 'Joomla.Power')
|
||||
->share('Joomla.Power', [$this, 'getPowers'], true);
|
||||
|
||||
$container->alias(Superpower::class, 'Joomlapower')
|
||||
->share('Joomlapower', [$this, 'getSuperpower'], true);
|
||||
$container->alias(Get::class, 'Joomla.Power.Remote.Get')
|
||||
->share('Joomla.Power.Remote.Get', [$this, 'getRemoteGet'], true);
|
||||
|
||||
$container->alias(Grep::class, 'Joomla.Power.Grep')
|
||||
->share('Joomla.Power.Grep', [$this, 'getGrep'], true);
|
||||
@@ -69,21 +69,21 @@ class JoomlaPower implements ServiceProviderInterface
|
||||
$container->get('Placeholder'),
|
||||
$container->get('Customcode'),
|
||||
$container->get('Customcode.Gui'),
|
||||
$container->get('Joomlapower')
|
||||
$container->get('Joomla.Power.Remote.Get')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Superpower
|
||||
* Get the Remote Get
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Superpower
|
||||
* @return Get
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getSuperpower(Container $container): Superpower
|
||||
public function getRemoteGet(Container $container): Get
|
||||
{
|
||||
return new Superpower(
|
||||
return new Get(
|
||||
$container->get('Joomla.Power.Grep'),
|
||||
$container->get('Data.Item')
|
||||
);
|
||||
|
@@ -15,15 +15,15 @@ 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\Super as Superpower;
|
||||
use VDM\Joomla\Componentbuilder\Power\Remote\Get;
|
||||
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;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Power\Repo\Readme as RepoReadme;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Power\Repos\Readme as ReposReadme;
|
||||
use VDM\Joomla\Componentbuilder\Power\Parser;
|
||||
use VDM\Joomla\Componentbuilder\Power\Plantuml;
|
||||
use VDM\Joomla\Componentbuilder\Power\Readme\Item as ItemReadme;
|
||||
use VDM\Joomla\Componentbuilder\Power\Readme\Main as MainReadme;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Power\Extractor;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Power\Injector;
|
||||
|
||||
@@ -48,8 +48,8 @@ class Power implements ServiceProviderInterface
|
||||
$container->alias(Powers::class, 'Power')
|
||||
->share('Power', [$this, 'getPowers'], true);
|
||||
|
||||
$container->alias(Superpower::class, 'Superpower')
|
||||
->share('Superpower', [$this, 'getSuperpower'], true);
|
||||
$container->alias(Get::class, 'Power.Remote.Get')
|
||||
->share('Power.Remote.Get', [$this, 'getRemoteGet'], true);
|
||||
|
||||
$container->alias(Grep::class, 'Power.Grep')
|
||||
->share('Power.Grep', [$this, 'getGrep'], true);
|
||||
@@ -69,11 +69,11 @@ class Power implements ServiceProviderInterface
|
||||
$container->alias(Plantuml::class, 'Power.Plantuml')
|
||||
->share('Power.Plantuml', [$this, 'getPlantuml'], true);
|
||||
|
||||
$container->alias(RepoReadme::class, 'Power.Repo.Readme')
|
||||
->share('Power.Repo.Readme', [$this, 'getRepoReadme'], true);
|
||||
$container->alias(ItemReadme::class, 'Power.Readme.Item')
|
||||
->share('Power.Readme.Item', [$this, 'getItemReadme'], true);
|
||||
|
||||
$container->alias(ReposReadme::class, 'Power.Repos.Readme')
|
||||
->share('Power.Repos.Readme', [$this, 'getReposReadme'], true);
|
||||
$container->alias(MainReadme::class, 'Power.Readme.Main')
|
||||
->share('Power.Readme.Main', [$this, 'getMainReadme'], true);
|
||||
|
||||
$container->alias(Extractor::class, 'Power.Extractor')
|
||||
->share('Power.Extractor', [$this, 'getExtractor'], true);
|
||||
@@ -97,21 +97,21 @@ class Power implements ServiceProviderInterface
|
||||
$container->get('Placeholder'),
|
||||
$container->get('Customcode'),
|
||||
$container->get('Customcode.Gui'),
|
||||
$container->get('Superpower')
|
||||
$container->get('Power.Remote.Get')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Super Class.
|
||||
* Get The Remote Get Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Superpower
|
||||
* @return Get
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getSuperpower(Container $container): Superpower
|
||||
public function getRemoteGet(Container $container): Get
|
||||
{
|
||||
return new Superpower(
|
||||
return new Get(
|
||||
$container->get('Power.Grep'),
|
||||
$container->get('Data.Item')
|
||||
);
|
||||
@@ -167,8 +167,8 @@ class Power implements ServiceProviderInterface
|
||||
$container->get('Compiler.Builder.Content.One'),
|
||||
$container->get('Compiler.Builder.Content.Multi'),
|
||||
$container->get('Power.Parser'),
|
||||
$container->get('Power.Repo.Readme'),
|
||||
$container->get('Power.Repos.Readme'),
|
||||
$container->get('Power.Readme.Item'),
|
||||
$container->get('Power.Readme.Main'),
|
||||
$container->get('Placeholder'),
|
||||
$container->get('Event')
|
||||
);
|
||||
@@ -228,13 +228,12 @@ class Power implements ServiceProviderInterface
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return RepoReadme
|
||||
* @return ItemReadme
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getRepoReadme(Container $container): RepoReadme
|
||||
public function getItemReadme(Container $container): ItemReadme
|
||||
{
|
||||
return new RepoReadme(
|
||||
$container->get('Power'),
|
||||
return new ItemReadme(
|
||||
$container->get('Power.Plantuml')
|
||||
);
|
||||
}
|
||||
@@ -244,15 +243,12 @@ class Power implements ServiceProviderInterface
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return ReposReadme
|
||||
* @return MainReadme
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getReposReadme(Container $container): ReposReadme
|
||||
public function getMainReadme(Container $container): MainReadme
|
||||
{
|
||||
return new ReposReadme(
|
||||
$container->get('Power'),
|
||||
$container->get('Power.Plantuml')
|
||||
);
|
||||
return new MainReadme();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -13,8 +13,6 @@ namespace VDM\Joomla\Componentbuilder\JoomlaPower;
|
||||
|
||||
|
||||
use Joomla\CMS\Language\Text;
|
||||
use VDM\Joomla\Utilities\FileHelper;
|
||||
use VDM\Joomla\Utilities\JsonHelper;
|
||||
use VDM\Joomla\Interfaces\GrepInterface;
|
||||
use VDM\Joomla\Abstraction\Grep as ExtendingGrep;
|
||||
|
||||
@@ -24,7 +22,7 @@ use VDM\Joomla\Abstraction\Grep as ExtendingGrep;
|
||||
*
|
||||
* The Grep feature will try to find your joomla power in the repositories listed in the global
|
||||
* Options of JCB in the super powers tab, and if it can't be found there will try the global core
|
||||
* Super powers of JCB. All searches are performed according the the [algorithm:cascading]
|
||||
* Super powers of JCB. All searches are performed according the [algorithm:cascading]
|
||||
* See documentation for more details: https://git.vdm.dev/joomla/super-powers/wiki
|
||||
*
|
||||
* @since 3.2.1
|
||||
@@ -40,76 +38,19 @@ final class Grep extends ExtendingGrep implements GrepInterface
|
||||
protected array $order = ['remote'];
|
||||
|
||||
/**
|
||||
* Load the remote repository index of powers
|
||||
* Search for a remote item
|
||||
*
|
||||
* @param object $path The repository path details
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function remoteIndex(object &$path): void
|
||||
{
|
||||
if (isset($path->index))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$path->index = null;
|
||||
|
||||
// update the branch
|
||||
$branch_field = $this->getBranchField();
|
||||
$branch = $path->{$branch_field} ?? $path->read_branch ?? 'master';
|
||||
|
||||
try
|
||||
{
|
||||
$this->contents->load_($path->base ?? null, $path->token ?? null);
|
||||
$source = $this->contents->metadata($path->organisation, $path->repository, 'src', $branch);
|
||||
if ($source && is_array($source))
|
||||
{
|
||||
$path->index = new \stdClass();
|
||||
foreach ($source as $index)
|
||||
{
|
||||
if (is_object($index) && isset($index->name))
|
||||
{
|
||||
$path->index->{$index->name} = $index;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->contents->reset_();
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
$this->app->enqueueMessage(
|
||||
Text::sprintf('COM_COMPONENTBUILDER_PJOOMLA_POWERB_REPOSITORY_AT_BSSB_GAVE_THE_FOLLOWING_ERRORBR_SP', $this->contents->api(), $path->path, $e->getMessage()),
|
||||
'Error'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Search for a remote power
|
||||
*
|
||||
* @param string $guid The global unique id of the power
|
||||
* @param string $guid The global unique id of the item
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function searchRemote(string $guid): ?object
|
||||
{
|
||||
// we can only search if we have paths
|
||||
if (is_array($this->paths))
|
||||
// check if it exists remotely
|
||||
if (($path = $this->existsRemotely($guid)) !== null)
|
||||
{
|
||||
foreach ($this->paths as $path)
|
||||
{
|
||||
// get local index
|
||||
$this->remoteIndex($path);
|
||||
|
||||
if (!empty($path->index) && isset($path->index->{$guid}))
|
||||
{
|
||||
return $this->getRemote($path, $guid);
|
||||
}
|
||||
}
|
||||
return $this->getRemote($path, $guid);
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -133,11 +74,12 @@ final class Grep extends ExtendingGrep implements GrepInterface
|
||||
}
|
||||
|
||||
// get the branch name
|
||||
$branch_field = $this->getBranchField();
|
||||
$branch = $path->{$branch_field} ?? $path->read_branch ?? 'master';
|
||||
$branch = $this->getBranchName($path);
|
||||
|
||||
// load the base and token if set
|
||||
$this->contents->load_($path->base ?? null, $path->token ?? null);
|
||||
|
||||
// get the settings
|
||||
$this->contents->load_($path->base ?? null, $path->token ?? null);
|
||||
if (($power = $this->loadRemoteFile($path->organisation, $path->repository, $path->index->{$guid}->path . '/item.json', $branch)) !== null &&
|
||||
isset($power->guid))
|
||||
{
|
||||
@@ -145,56 +87,65 @@ final class Grep extends ExtendingGrep implements GrepInterface
|
||||
$path_guid = $path->guid ?? null;
|
||||
if ($path_guid !== null)
|
||||
{
|
||||
// get the Settings meta
|
||||
if (($meta = $this->contents->metadata($path->organisation, $path->repository, $path->index->{$guid}->path . '/item.json', $branch)) !== null &&
|
||||
isset($meta->sha))
|
||||
{
|
||||
if (isset($power->params) && is_object($power->params) &&
|
||||
isset($power->params->source) && is_array($power->params->source))
|
||||
{
|
||||
$power->params->source[$path_guid] = $meta->sha;
|
||||
$power->params->source[$path_guid . '-settings'] = $meta->sha;
|
||||
}
|
||||
else
|
||||
{
|
||||
$power->params = (object)[
|
||||
'source' => [$path_guid => $meta->sha]
|
||||
$power->params = (object) [
|
||||
'source' => [$path_guid . '-settings' => $meta->sha]
|
||||
];
|
||||
}
|
||||
}
|
||||
// get the README meta
|
||||
if (($meta = $this->contents->metadata($path->organisation, $path->repository, $path->index->{$guid}->path . '/README.md', $branch)) !== null &&
|
||||
isset($meta->sha))
|
||||
{
|
||||
if (isset($power->params) && is_object($power->params) &&
|
||||
isset($power->params->source) && is_array($power->params->source))
|
||||
{
|
||||
$power->params->source[$path_guid . '-readme'] = $meta->sha;
|
||||
}
|
||||
else
|
||||
{
|
||||
$power->params = (object) [
|
||||
'source' => [$path_guid . '-readme' => $meta->sha]
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// reset back to the global base and token
|
||||
$this->contents->reset_();
|
||||
|
||||
return $power;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the remote file
|
||||
* Set repository messages and errors based on given conditions.
|
||||
*
|
||||
* @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
|
||||
* @param string $message The message to set (if error)
|
||||
* @param string $path Path value
|
||||
* @param string $repository Repository name
|
||||
* @param string $organisation Organisation name
|
||||
* @param string|null $base Base URL
|
||||
*
|
||||
* @return mixed
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function loadRemoteFile(string $organisation, string $repository, string $path, ?string $branch)
|
||||
protected function setRemoteIndexMessage(string $message, string $path, string $repository, string $organisation, ?string $base): void
|
||||
{
|
||||
try
|
||||
{
|
||||
$data = $this->contents->get($organisation, $repository, $path, $branch);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
$this->app->enqueueMessage(
|
||||
Text::sprintf('COM_COMPONENTBUILDER_PFILE_AT_BSSB_GAVE_THE_FOLLOWING_ERRORBR_SP', $this->contents->api(), $path, $e->getMessage()),
|
||||
'Error'
|
||||
);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return $data;
|
||||
$this->app->enqueueMessage(
|
||||
Text::sprintf('COM_COMPONENTBUILDER_PJOOMLA_POWERB_REPOSITORY_AT_BSSB_GAVE_THE_FOLLOWING_ERRORBR_SP', $this->contents->api(), $path, $message),
|
||||
'Error'
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,66 @@
|
||||
<?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\Readme;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Readme\ItemInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Joomla Power Item Readme
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class Item implements ItemInterface
|
||||
{
|
||||
/**
|
||||
* Get an item readme
|
||||
*
|
||||
* @param object $item An item details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function get(object $item): string
|
||||
{
|
||||
// build readme
|
||||
$readme = ["```
|
||||
██╗ ██████╗ ██████╗ ███╗ ███╗██╗ █████╗ ██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||
██║██╔═══██╗██╔═══██╗████╗ ████║██║ ██╔══██╗ ██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||
██║██║ ██║██║ ██║██╔████╔██║██║ ███████║ ██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||
██ ██║██║ ██║██║ ██║██║╚██╔╝██║██║ ██╔══██║ ██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||
╚█████╔╝╚██████╔╝╚██████╔╝██║ ╚═╝ ██║███████╗██║ ██║ ██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||
╚════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||
```"];
|
||||
// system name
|
||||
$readme[] = "# " . $item->system_name;
|
||||
|
||||
if (!empty($item->description))
|
||||
{
|
||||
$readme[] = "\n" . $item->description;
|
||||
}
|
||||
|
||||
$readme[] = "\nThe Joomla! Power feature allows you to use Joomla classes in your project without manually managing their namespaces. JCB will automatically add the correct namespaces to your files. If Joomla classes change in future versions, such as from Joomla 3 to 5, JCB will update them for you.\n\nHowever, if there are breaking changes in function names, you may need to make some manual adjustments. The Joomla Power Key (JPK) helps you easily search for these classes.\n\nBy using the JPK (Joomla Power Key) in your custom code (replacing the class name in your code with the JPK), JCB will automatically pull the Joomla! Power from the repository into your project.\n\nTo add this specific power to your project in JCB:\n\n> simply use this JPK\n```\n" . 'Joomla---' . str_replace('-', '_', $item->guid) . '---Power' . "\n```\n> remember to replace the `---` with `___` to activate this Joomla! Power in your code";
|
||||
|
||||
// yes you can remove this, but why?
|
||||
$readme[] = "\n---\n```
|
||||
██╗ ██████╗██████╗
|
||||
██║██╔════╝██╔══██╗
|
||||
██║██║ ██████╔╝
|
||||
██ ██║██║ ██╔══██╗
|
||||
╚█████╔╝╚██████╗██████╔╝
|
||||
╚════╝ ╚═════╝╚═════╝
|
||||
```\n> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)\n\n";
|
||||
|
||||
return implode("\n", $readme);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,234 @@
|
||||
<?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\Readme;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Readme\MainInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Power Main Readme
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class Main implements MainInterface
|
||||
{
|
||||
/**
|
||||
* Get Main Readme
|
||||
*
|
||||
* @param array $items All items of this repository.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(array $items): string
|
||||
{
|
||||
// build readme
|
||||
$readme = ["```
|
||||
██╗ ██████╗ ██████╗ ███╗ ███╗██╗ █████╗
|
||||
██║██╔═══██╗██╔═══██╗████╗ ████║██║ ██╔══██╗
|
||||
██║██║ ██║██║ ██║██╔████╔██║██║ ███████║
|
||||
██ ██║██║ ██║██║ ██║██║╚██╔╝██║██║ ██╔══██║
|
||||
╚█████╔╝╚██████╔╝╚██████╔╝██║ ╚═╝ ██║███████╗██║ ██║
|
||||
╚════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
██████╗ ██████╗ ██╗ ██╗███████╗██████╗ ███████╗
|
||||
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗██╔════╝
|
||||
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝███████╗
|
||||
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗╚════██║
|
||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║███████║
|
||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝╚══════╝
|
||||
```"];
|
||||
|
||||
// default description of super powers
|
||||
$readme[] = "\n### What is JCB Joomla Powers?\nThe Joomla Component Builder (JCB) Joomla Power features are designed to enhance JCB's functionality and streamline the development process. The Joomla powers enable developers to effectively leverage Joomla classes in their custom code without needing to manually add the `use` statements for those classes to the file headers. JCB automatically updates these `use` statements in the necessary headers when it detects a Joomla power key in the custom code.\n
|
||||
\n
|
||||
By doing this, we can control the `use` statements dynamically from a central point. This is particularly beneficial when transitioning from Joomla 3 to Joomla 4, as it allows us to seamlessly switch from certain classes to their respective Joomla framework classes and vice versa. Maintaining these `use` statements in the Joomla Power area ensures that JCB handles the inclusion and updating of class names to prevent conflicts with other classes.\n
|
||||
\n
|
||||
This approach is convenient and allows developers to focus on the bespoke parts of their application logic without worrying about class declarations.\n
|
||||
\nThis repository contains an index (see below) of all the Joomla! Powers within the JCB core GUI. These Joomla! Powers are automatically added to the repository by our maintainers, ensuring a well-organized and accessible collection of Joomla Classes are maintained.\n";
|
||||
|
||||
// get the readme body
|
||||
$readme[] = $this->readmeBuilder($items);
|
||||
|
||||
// yes you can remove this, but why?
|
||||
$readme[] = "\n---\n```
|
||||
██╗ ██████╗ ██████╗ ███╗ ███╗██╗ █████╗
|
||||
██║██╔═══██╗██╔═══██╗████╗ ████║██║ ██╔══██╗
|
||||
██║██║ ██║██║ ██║██╔████╔██║██║ ███████║
|
||||
██ ██║██║ ██║██║ ██║██║╚██╔╝██║██║ ██╔══██║
|
||||
╚█████╔╝╚██████╔╝╚██████╔╝██║ ╚═╝ ██║███████╗██║ ██║
|
||||
╚════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝╚═╝ ╚═╝
|
||||
██████╗ ██████╗ ███╗ ███╗██████╗ ██████╗ ███╗ ██╗███████╗███╗ ██╗████████╗
|
||||
██╔════╝██╔═══██╗████╗ ████║██╔══██╗██╔═══██╗████╗ ██║██╔════╝████╗ ██║╚══██╔══╝
|
||||
██║ ██║ ██║██╔████╔██║██████╔╝██║ ██║██╔██╗ ██║█████╗ ██╔██╗ ██║ ██║
|
||||
██║ ██║ ██║██║╚██╔╝██║██╔═══╝ ██║ ██║██║╚██╗██║██╔══╝ ██║╚██╗██║ ██║
|
||||
╚██████╗╚██████╔╝██║ ╚═╝ ██║██║ ╚██████╔╝██║ ╚████║███████╗██║ ╚████║ ██║
|
||||
╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝╚═╝ ╚═══╝ ╚═╝
|
||||
██████╗ ██╗ ██╗██╗██╗ ██████╗ ███████╗██████╗
|
||||
██╔══██╗██║ ██║██║██║ ██╔══██╗██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║██║ ██║ ██║█████╗ ██████╔╝
|
||||
██╔══██╗██║ ██║██║██║ ██║ ██║██╔══╝ ██╔══██╗
|
||||
██████╔╝╚██████╔╝██║███████╗██████╔╝███████╗██║ ██║
|
||||
╚═════╝ ╚═════╝ ╚═╝╚══════╝╚═════╝ ╚══════╝╚═╝ ╚═╝
|
||||
```\n> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)\n\n";
|
||||
|
||||
return implode("\n", $readme);
|
||||
}
|
||||
|
||||
/**
|
||||
* The readme builder
|
||||
*
|
||||
* @param array $classes The powers.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function readmeBuilder(array &$items): string
|
||||
{
|
||||
$classes = [];
|
||||
foreach ($items as $guid => $power)
|
||||
{
|
||||
// add to the sort bucket
|
||||
$classes[] = [
|
||||
'name' => $power['name'],
|
||||
'link' => $this->indexLinkPower($power)
|
||||
];
|
||||
}
|
||||
|
||||
return $this->readmeModel($classes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort and model the readme classes
|
||||
*
|
||||
* @param array $classes The powers.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function readmeModel(array &$classes): string
|
||||
{
|
||||
$this->sortClasses($classes);
|
||||
|
||||
return $this->generateIndex($classes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate the index string for classes
|
||||
*
|
||||
* @param array $classes The sorted classes
|
||||
*
|
||||
* @return string The index string
|
||||
*/
|
||||
private function generateIndex(array &$classes): string
|
||||
{
|
||||
$result = "# Index of Joomla! Powers\n";
|
||||
|
||||
foreach ($classes as $class)
|
||||
{
|
||||
// Add the class details
|
||||
$result .= "\n - " . $class['link'];
|
||||
}
|
||||
|
||||
$result .= "\n> remember to replace the `---` with `___` in the JPK to activate that Joomla! Power in your code";
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort the flattened array using a single sorting function
|
||||
*
|
||||
* @param array $classes The classes to sort
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function sortClasses(array &$classes): void
|
||||
{
|
||||
usort($classes, function ($a, $b) {
|
||||
return $this->compareName($a, $b);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare the name of two classes
|
||||
*
|
||||
* @param array $a First class
|
||||
* @param array $b Second class
|
||||
*
|
||||
* @return int Comparison result
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function compareName(array $a, array $b): int
|
||||
{
|
||||
return strcmp($a['name'], $b['name']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Link to the power in this repository
|
||||
*
|
||||
* @param array $power The power details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function indexLinkPower(array &$power): string
|
||||
{
|
||||
$name = $power['name'] ?? 'error';
|
||||
return '**' . $name . "** | "
|
||||
. $this->linkPowerRepo($power) . ' | '
|
||||
. $this->linkPowerSettings($power) . ' | JPK: `'
|
||||
. $this->linkPowerJPK($power) .'`';
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Link to the power in this repository
|
||||
*
|
||||
* @param array $power The power details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function linkPowerRepo(array &$power): string
|
||||
{
|
||||
$path = $power['path'] ?? 'error';
|
||||
return '[Details](' . $path . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the Link to the power settings in this repository
|
||||
*
|
||||
* @param array $power The power details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function linkPowerSettings(array &$power): string
|
||||
{
|
||||
$settings = $power['settings'] ?? 'error';
|
||||
return '[Settings](' . $settings . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the JoomlaPowerKey (JPK)
|
||||
*
|
||||
* @param array $power The power details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function linkPowerJPK(array &$power): string
|
||||
{
|
||||
$jpk = $power['jpk'] ?? 'error';
|
||||
return $jpk;
|
||||
}
|
||||
}
|
||||
|
@@ -9,19 +9,19 @@
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\JoomlaPower;
|
||||
namespace VDM\Joomla\Componentbuilder\JoomlaPower\Remote;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Data\RemoteInterface;
|
||||
use VDM\Joomla\Data\Remote;
|
||||
use VDM\Joomla\Interfaces\Remote\GetInterface;
|
||||
use VDM\Joomla\Abstraction\Remote\Get as ExtendingGet;
|
||||
|
||||
|
||||
/**
|
||||
* Super Joomla Power of JCB
|
||||
* Remote Get Joomla Power of JCB
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class Super extends Remote implements RemoteInterface
|
||||
final class Get extends ExtendingGet implements GetInterface
|
||||
{
|
||||
/**
|
||||
* Table Name
|
@@ -0,0 +1,182 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\JoomlaPower\Remote;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Remote\SetInterface;
|
||||
use VDM\Joomla\Abstraction\Remote\Set as ExtendingSet;
|
||||
|
||||
|
||||
/**
|
||||
* Set JoomlaPower based on global unique ids to remote repository
|
||||
*
|
||||
* @since 3.2.2
|
||||
*/
|
||||
final class Set extends ExtendingSet implements SetInterface
|
||||
{
|
||||
/**
|
||||
* Table Name
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.1
|
||||
*/
|
||||
protected string $table = 'joomla_power';
|
||||
|
||||
/**
|
||||
* Area Name
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.1
|
||||
*/
|
||||
protected string $area = 'Joomla Power';
|
||||
|
||||
/**
|
||||
* Prefix Key
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected string $prefix_key = 'Joomla---';
|
||||
|
||||
/**
|
||||
* The item map
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected array $map = [
|
||||
'system_name' => 'system_name',
|
||||
'settings' => 'settings',
|
||||
'guid' => 'guid',
|
||||
'description' => 'description'
|
||||
];
|
||||
|
||||
/**
|
||||
* The index map
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected array $index_map = [
|
||||
'name' => 'index_map_IndexName',
|
||||
'settings' => 'index_map_IndexSettingsPath',
|
||||
'path' => 'index_map_IndexPath',
|
||||
'jpk' => 'index_map_IndexKey',
|
||||
'guid' => 'index_map_IndexGUID'
|
||||
];
|
||||
|
||||
/**
|
||||
* update an existing item (if changed)
|
||||
*
|
||||
* @param object $item
|
||||
* @param object $existing
|
||||
* @param object $repo
|
||||
*
|
||||
* @return bool
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected function updateItem(object $item, object $existing, object $repo): bool
|
||||
{
|
||||
// make sure there was a change
|
||||
$sha = $existing->params->source[$repo->guid . '-settings'] ?? null;
|
||||
$existing = $this->mapItem($existing);
|
||||
if ($sha === null || $this->areObjectsEqual($item, $existing))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->git->update(
|
||||
$repo->organisation, // The owner name.
|
||||
$repo->repository, // The repository name.
|
||||
'src/' . $item->guid . '/' . $this->getSettingsPath(), // The file path.
|
||||
json_encode($item, JSON_PRETTY_PRINT), // The file content.
|
||||
'Update ' . $item->system_name, // The commit message.
|
||||
$sha, // The blob SHA of the old file.
|
||||
$repo->write_branch // The branch name.
|
||||
);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* create a new item
|
||||
*
|
||||
* @param object $item
|
||||
* @param object $repo
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected function createItem(object $item, object $repo): void
|
||||
{
|
||||
$this->git->create(
|
||||
$repo->organisation, // The owner name.
|
||||
$repo->repository, // The repository name.
|
||||
'src/' . $item->guid . '/' . $this->getSettingsPath(), // The file path.
|
||||
json_encode($item, JSON_PRETTY_PRINT), // The file content.
|
||||
'Create ' . $item->system_name, // The commit message.
|
||||
$repo->write_branch // The branch name.
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* update an existing item readme
|
||||
*
|
||||
* @param object $item
|
||||
* @param object $existing
|
||||
* @param object $repo
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected function updateItemReadme(object $item, object $existing, object $repo): void
|
||||
{
|
||||
// make sure there was a change
|
||||
$sha = $existing->params->source[$repo->guid . '-readme'] ?? null;
|
||||
if ($sha === null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$this->git->update(
|
||||
$repo->organisation, // The owner name.
|
||||
$repo->repository, // The repository name.
|
||||
'src/' . $item->guid . '/README.md', // The file path.
|
||||
$this->itemReadme->get($item), // The file content.
|
||||
'Update ' . $item->system_name . ' readme file', // The commit message.
|
||||
$sha, // The blob SHA of the old file.
|
||||
$repo->write_branch // The branch name.
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* create a new item readme
|
||||
*
|
||||
* @param object $item
|
||||
* @param object $repo
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected function createItemReadme(object $item, object $repo): void
|
||||
{
|
||||
$this->git->create(
|
||||
$repo->organisation, // The owner name.
|
||||
$repo->repository, // The repository name.
|
||||
'src/' . $item->guid . '/README.md', // The file path.
|
||||
$this->itemReadme->get($item), // The file content.
|
||||
'Create ' . $item->system_name . ' readme file', // The commit message.
|
||||
$repo->write_branch // The branch name.
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@@ -1,46 +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;
|
||||
|
||||
|
||||
use VDM\Joomla\Data\Repository as ExtendingRepository;
|
||||
|
||||
|
||||
/**
|
||||
* Set JoomlaPower based on global unique ids to remote repository
|
||||
*
|
||||
* @since 3.2.2
|
||||
*/
|
||||
final class Repository extends ExtendingRepository
|
||||
{
|
||||
/**
|
||||
* Table Name
|
||||
*
|
||||
* @var string
|
||||
* @since 3.2.1
|
||||
*/
|
||||
protected string $table = 'joomla_power';
|
||||
|
||||
/**
|
||||
* The item map
|
||||
*
|
||||
* @var array
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected array $map = [
|
||||
'system_name' => 'system_name',
|
||||
'settings' => 'settings',
|
||||
'guid' => 'guid',
|
||||
'description' => 'description'
|
||||
];
|
||||
}
|
||||
|
@@ -17,9 +17,10 @@ use Joomla\DI\ServiceProviderInterface;
|
||||
use VDM\Joomla\Componentbuilder\JoomlaPower\Config;
|
||||
use VDM\Joomla\Componentbuilder\Table;
|
||||
use VDM\Joomla\Componentbuilder\JoomlaPower\Grep;
|
||||
use VDM\Joomla\Componentbuilder\JoomlaPower\Super as Superpower;
|
||||
use VDM\Joomla\Componentbuilder\JoomlaPower\Repository;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Power\Parser;
|
||||
use VDM\Joomla\Componentbuilder\JoomlaPower\Remote\Get;
|
||||
use VDM\Joomla\Componentbuilder\JoomlaPower\Remote\Set;
|
||||
use VDM\Joomla\Componentbuilder\JoomlaPower\Readme\Item as ItemReadme;
|
||||
use VDM\Joomla\Componentbuilder\JoomlaPower\Readme\Main as MainReadme;
|
||||
|
||||
|
||||
/**
|
||||
@@ -48,14 +49,17 @@ class JoomlaPower implements ServiceProviderInterface
|
||||
$container->alias(Grep::class, 'Joomla.Power.Grep')
|
||||
->share('Joomla.Power.Grep', [$this, 'getGrep'], true);
|
||||
|
||||
$container->alias(Superpower::class, 'Joomlapower')
|
||||
->share('Joomlapower', [$this, 'getSuperpower'], true);
|
||||
$container->alias(Get::class, 'Joomla.Power.Remote.Get')
|
||||
->share('Joomla.Power.Remote.Get', [$this, 'getRemoteGet'], true);
|
||||
|
||||
$container->alias(Repository::class, 'Joomla.Power.Repository')
|
||||
->share('Joomla.Power.Repository', [$this, 'getRepository'], true);
|
||||
$container->alias(Set::class, 'Joomla.Power.Remote.Set')
|
||||
->share('Joomla.Power.Remote.Set', [$this, 'getRemoteSet'], true);
|
||||
|
||||
$container->alias(Parser::class, 'Power.Parser')
|
||||
->share('Power.Parser', [$this, 'getParser'], true);
|
||||
$container->alias(ItemReadme::class, 'Joomla.Power.Readme.Item')
|
||||
->share('Joomla.Power.Readme.Item', [$this, 'getItemReadme'], true);
|
||||
|
||||
$container->alias(MainReadme::class, 'Joomla.Power.Readme.Main')
|
||||
->share('Joomla.Power.Readme.Main', [$this, 'getMainReadme'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -101,50 +105,65 @@ class JoomlaPower implements ServiceProviderInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Super Class.
|
||||
* Get The Remote Get Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Superpower
|
||||
* @return Get
|
||||
* @since 3.2.1
|
||||
*/
|
||||
public function getSuperpower(Container $container): Superpower
|
||||
public function getRemoteGet(Container $container): Get
|
||||
{
|
||||
return new Superpower(
|
||||
return new Get(
|
||||
$container->get('Joomla.Power.Grep'),
|
||||
$container->get('Data.Item')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Repository Class.
|
||||
* Get The Remote Set Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Repository
|
||||
* @return Set
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function getRepository(Container $container): Repository
|
||||
public function getRemoteSet(Container $container): Set
|
||||
{
|
||||
return new Repository(
|
||||
return new Set(
|
||||
$container->get('Config')->approved_joomla_paths,
|
||||
$container->get('Joomla.Power.Grep'),
|
||||
$container->get('Data.Items'),
|
||||
$container->get('Joomla.Power.Readme.Item'),
|
||||
$container->get('Joomla.Power.Readme.Main'),
|
||||
$container->get('Gitea.Repository.Contents')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Parser Class.
|
||||
* Get The Item Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Parser
|
||||
* @return ItemReadme
|
||||
* @since 3.2.1
|
||||
*/
|
||||
public function getParser(Container $container): Parser
|
||||
public function getItemReadme(Container $container): ItemReadme
|
||||
{
|
||||
return new Parser();
|
||||
return new ItemReadme();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Main Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return MainReadme
|
||||
* @since 3.2.1
|
||||
*/
|
||||
public function getMainReadme(Container $container): MainReadme
|
||||
{
|
||||
return new MainReadme();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -13,7 +13,7 @@ namespace VDM\Joomla\Componentbuilder\Power\Generator;
|
||||
|
||||
|
||||
use VDM\Joomla\Data\Action\Load as Database;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Power\Parser;
|
||||
use VDM\Joomla\Componentbuilder\Power\Parser;
|
||||
use VDM\Joomla\Componentbuilder\Power\Generator\Bucket;
|
||||
use VDM\Joomla\Utilities\String\ClassfunctionHelper;
|
||||
|
||||
|
@@ -32,100 +32,46 @@ use VDM\Joomla\Abstraction\Grep as ExtendingGrep;
|
||||
final class Grep extends ExtendingGrep implements GrepInterface
|
||||
{
|
||||
/**
|
||||
* Load the remote repository index of powers
|
||||
* The index file path
|
||||
*
|
||||
* @param object $path The repository path details
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
* @var string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected function remoteIndex(object &$path): void
|
||||
{
|
||||
if (isset($path->index))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
protected string $index_path = 'super-powers.json';
|
||||
|
||||
/**
|
||||
* Search for a local power
|
||||
* Search for a local item
|
||||
*
|
||||
* @param string $guid The global unique id of the power
|
||||
* @param string $guid The global unique id of the item
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function searchLocal(string $guid): ?object
|
||||
{
|
||||
// we can only search if we have paths
|
||||
if ($this->path && $this->paths)
|
||||
// check if it exists locally
|
||||
if (($path = $this->existsLocally($guid)) !== null)
|
||||
{
|
||||
foreach ($this->paths as $path)
|
||||
{
|
||||
// get local index
|
||||
$this->localIndex($path);
|
||||
|
||||
if (!empty($path->local) && isset($path->local->{$guid}))
|
||||
{
|
||||
return $this->getLocal($path, $guid);
|
||||
}
|
||||
}
|
||||
return $this->getLocal($path, $guid);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Search for a remote power
|
||||
* Search for a remote item
|
||||
*
|
||||
* @param string $guid The global unique id of the power
|
||||
* @param string $guid The global unique id of the item
|
||||
*
|
||||
* @return object|null
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function searchRemote(string $guid): ?object
|
||||
{
|
||||
// we can only search if we have paths
|
||||
if ($this->path && $this->paths)
|
||||
// check if it exists remotely
|
||||
if (($path = $this->existsRemotely($guid)) !== null)
|
||||
{
|
||||
foreach ($this->paths as $path)
|
||||
{
|
||||
// get local index
|
||||
$this->remoteIndex($path);
|
||||
|
||||
if (!empty($path->index) && isset($path->index->{$guid}))
|
||||
{
|
||||
return $this->getRemote($path, $guid);
|
||||
}
|
||||
}
|
||||
return $this->getRemote($path, $guid);
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -181,80 +127,69 @@ final class Grep extends ExtendingGrep implements GrepInterface
|
||||
return $power;
|
||||
}
|
||||
|
||||
// get the settings
|
||||
// get the branch name
|
||||
$branch = $this->getBranchName($path);
|
||||
|
||||
// load the base and token if set
|
||||
$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 &&
|
||||
|
||||
// get the settings
|
||||
if (($power = $this->loadRemoteFile($path->organisation, $path->repository, $path->index->{$guid}->settings, $branch)) !== null &&
|
||||
isset($power->guid))
|
||||
{
|
||||
// get the code
|
||||
if (($code = $this->loadRemoteFile($path->organisation, $path->repository, $path->index->{$guid}->power, $path->read_branch)) !== null)
|
||||
if (($code = $this->loadRemoteFile($path->organisation, $path->repository, $path->index->{$guid}->power, $branch)) !== null)
|
||||
{
|
||||
// set the git details in params
|
||||
$power->params = (object) [
|
||||
'source' => ['guid' => $path->guid ?? null]
|
||||
];
|
||||
$power->main_class_code = $code;
|
||||
}
|
||||
}
|
||||
|
||||
// reset back to the global base and token
|
||||
$this->contents->reset_();
|
||||
|
||||
return $power;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the remote file
|
||||
* Set repository messages and errors based on given conditions.
|
||||
*
|
||||
* @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 $organisation, string $repository, string $path, ?string $branch)
|
||||
{
|
||||
try
|
||||
{
|
||||
$data = $this->contents->get($organisation, $repository, $path, $branch);
|
||||
}
|
||||
catch (\Exception $e)
|
||||
{
|
||||
$this->app->enqueueMessage(
|
||||
Text::sprintf('COM_COMPONENTBUILDER_PFILE_AT_BSSB_GAVE_THE_FOLLOWING_ERRORBR_SP', $this->contents->api(), $path, $e->getMessage()),
|
||||
'Error'
|
||||
);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the local repository index of powers
|
||||
*
|
||||
* @param object $path The repository path details
|
||||
* @param string $message The message to set (if error)
|
||||
* @param string $path Path value
|
||||
* @param string $repository Repository name
|
||||
* @param string $organisation Organisation name
|
||||
* @param string|null $base Base URL
|
||||
*
|
||||
* @return void
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function localIndex(object &$path)
|
||||
protected function setRemoteIndexMessage(string $message, string $path, string $repository, string $organisation, ?string $base): void
|
||||
{
|
||||
if (isset($path->local) || !isset($path->full_path))
|
||||
if ($repository === 'super-powers' && $organisation !== 'joomla' && (empty($base) || $base === 'https://git.vdm.dev'))
|
||||
{
|
||||
return;
|
||||
// Give heads-up about the overriding feature
|
||||
$this->app->enqueueMessage(
|
||||
Text::sprintf(
|
||||
'<p>Super Power</b> repository at <b>https://git.vdm.dev/%s</b> can be used to override any power!<br />But has not yet been set in your account at https://git.vdm.dev/%s<br /><small>This is an optional feature.</small>',
|
||||
$path,
|
||||
$organisation
|
||||
),
|
||||
'Message'
|
||||
);
|
||||
}
|
||||
|
||||
if (($content = FileHelper::getContent($path->full_path . '/super-powers.json', null)) !== null &&
|
||||
JsonHelper::check($content))
|
||||
else
|
||||
{
|
||||
$path->local = json_decode($content);
|
||||
|
||||
return;
|
||||
// Give error
|
||||
$this->app->enqueueMessage(
|
||||
Text::sprintf(
|
||||
'<p>Super Power</b> repository at <b>%s/%s</b> gave the following error!<br />%s</p>',
|
||||
$this->contents->api(),
|
||||
$path,
|
||||
$message
|
||||
),
|
||||
'Error'
|
||||
);
|
||||
}
|
||||
|
||||
$path->local = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -9,7 +9,7 @@
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Power;
|
||||
namespace VDM\Joomla\Componentbuilder\Power;
|
||||
|
||||
|
||||
/**
|
@@ -9,11 +9,11 @@
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Power;
|
||||
namespace VDM\Joomla\Componentbuilder\Power;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Power Plantuml Builder
|
||||
* Power Plantuml Builder
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Plantuml
|
@@ -0,0 +1,97 @@
|
||||
<?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\Readme;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Power\Plantuml;
|
||||
use VDM\Joomla\Interfaces\Readme\ItemInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Power Item Readme
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class Item implements ItemInterface
|
||||
{
|
||||
/**
|
||||
* Compiler Powers Plantuml Builder
|
||||
*
|
||||
* @var Plantuml
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected Plantuml $plantuml;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Plantuml $plantuml The powers plantuml builder object.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(Plantuml $plantuml)
|
||||
{
|
||||
$this->plantuml = $plantuml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an item readme
|
||||
*
|
||||
* @param object $item An item details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
public function get(object $item): string
|
||||
{
|
||||
// build readme
|
||||
$readme = ["```
|
||||
██████╗ ██████╗ ██╗ ██╗███████╗██████╗
|
||||
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗
|
||||
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝
|
||||
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗
|
||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||
```"];
|
||||
// add the class diagram
|
||||
$parsed_class_code = [];
|
||||
if (isset($item->parsed_class_code) && is_array($item->parsed_class_code))
|
||||
{
|
||||
$parsed_class_code = $item->parsed_class_code;
|
||||
}
|
||||
|
||||
$readme[] = "# " . $item->type . " " . $item->code_name . " (Details)";
|
||||
$readme[] = "> namespace: **" . $item->_namespace . "**";
|
||||
if (!empty($item->extends_name))
|
||||
{
|
||||
$readme[] = "> extends: **" . $item->extends_name . "**";
|
||||
}
|
||||
$readme[] = "\n```uml\n@startuml" . $this->plantuml->classDetailedDiagram(
|
||||
['name' => $item->code_name, 'type' => $item->type],
|
||||
$parsed_class_code
|
||||
) . " \n@enduml\n```";
|
||||
|
||||
$readme[] = "\nThe Power feature in JCB allows you to write PHP classes and their implementations, making it easy to include them in your Joomla project. JCB handles linking, autoloading, namespacing, and folder structure creation for you.\n\nBy using the SPK (Super Power Key) in your custom code (replacing the class name in your code with the SPK), JCB will automatically pull the power from the repository into your project. This makes it available in your JCB instance, allowing you to edit it and include the class in your generated Joomla component.\n\nJCB uses placeholders like [[[`NamespacePrefix`]]] and [[[`ComponentNamespace`]]] in namespacing to prevent collisions and improve reusability across different JCB systems. You can also set the **JCB powers path** globally or per component under the **Dynamic Integration** tab, providing flexibility and easy maintainability.\n\nTo add this specific Power to your project in JCB:\n\n> simply use this SPK\n```\n" . 'Super---' . str_replace('-', '_', $item->guid) . '---Power' . "\n```\n> remember to replace the `---` with `___` to activate this Power in your code";
|
||||
|
||||
// yes you can remove this, but why?
|
||||
$readme[] = "\n---\n```
|
||||
██╗ ██████╗██████╗
|
||||
██║██╔════╝██╔══██╗
|
||||
██║██║ ██████╔╝
|
||||
██ ██║██║ ██╔══██╗
|
||||
╚█████╔╝╚██████╗██████╔╝
|
||||
╚════╝ ╚═════╝╚═════╝
|
||||
```\n> Build with [Joomla Component Builder](https://git.vdm.dev/joomla/Component-Builder)\n\n";
|
||||
|
||||
return implode("\n", $readme);
|
||||
}
|
||||
}
|
||||
|
@@ -9,59 +9,27 @@
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Power\Repos;
|
||||
namespace VDM\Joomla\Componentbuilder\Power\Readme;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Power;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Power\Plantuml;
|
||||
use VDM\Joomla\Interfaces\Readme\MainInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Power Repos Readme
|
||||
* Compiler Power Main Readme
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Readme
|
||||
final class Main implements MainInterface
|
||||
{
|
||||
/**
|
||||
* Power Objects
|
||||
* Get Main Readme
|
||||
*
|
||||
* @var Power
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected Power $power;
|
||||
|
||||
/**
|
||||
* Compiler Powers Plantuml Builder
|
||||
*
|
||||
* @var Plantuml
|
||||
* @since 3.2.0
|
||||
**/
|
||||
protected Plantuml $plantuml;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Power|null $power The power object.
|
||||
* @param Plantuml|null $plantuml The powers plantuml builder object.
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function __construct(?Power $power = null, ?Plantuml $plantuml = null)
|
||||
{
|
||||
$this->power = $power ?: Compiler::_('Power');
|
||||
$this->plantuml = $plantuml ?: Compiler::_('Power.Plantuml');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Super Power Readme
|
||||
*
|
||||
* @param array $powers All powers of this super power.
|
||||
* @param array $items All items of this repository.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(array $powers): string
|
||||
public function get(array $items): string
|
||||
{
|
||||
// build readme
|
||||
$readme = ["```
|
||||
@@ -83,7 +51,7 @@ class Readme
|
||||
$readme[] = "\n### What is JCB Super Powers?\nThe Joomla Component Builder (JCB) Super Power features are designed to enhance JCB's functionality and streamline the development process. These Super Powers enable developers to efficiently manage and share their custom powers across multiple JCB instances through repositories hosted on [https://git.vdm.dev/[username]/[repository-name]](https://git.vdm.dev). JCB Super Powers are managed using a combination of layers, events, tasks, methods, switches, and algorithms, which work together to provide powerful customization and extensibility options. More details on JCB Super Powers can be found in the [Super Powers Documentation](https://git.vdm.dev/joomla/super-powers/wiki).\n\nIn summary, JCB Super Powers offer a flexible and efficient way to manage and share functionalities between JCB instances. By utilizing a sophisticated system of layers, events, tasks, methods, switches, and algorithms, developers can seamlessly integrate JCB core powers and their custom powers. For more information on how to work with JCB Super Powers, refer to the [Super Powers User Guide](https://git.vdm.dev/joomla/super-powers/wiki).\n\n### What can I find here?\nThis repository contains an index (see below) of all the approved powers within the JCB GUI. During the compilation of a component, these powers are automatically added to the repository, ensuring a well-organized and accessible collection of functionalities.\n";
|
||||
|
||||
// get the readme body
|
||||
$readme[] = $this->readmeBuilder($powers);
|
||||
$readme[] = $this->readmeBuilder($items);
|
||||
|
||||
// yes you can remove this, but why?
|
||||
$readme[] = "\n---\n```
|
||||
@@ -118,10 +86,10 @@ class Readme
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function readmeBuilder(array &$powers): string
|
||||
private function readmeBuilder(array &$items): string
|
||||
{
|
||||
$classes = [];
|
||||
foreach ($powers as $guid => $power)
|
||||
foreach ($items as $guid => $power)
|
||||
{
|
||||
// add to the sort bucket
|
||||
$classes[] = [
|
||||
@@ -175,6 +143,8 @@ class Readme
|
||||
$result .= "\n - " . $class['link'];
|
||||
}
|
||||
|
||||
$result .= "\n> remember to replace the `---` with `___` in the SPK to activate that Power in your code";
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@@ -290,8 +260,8 @@ class Readme
|
||||
return '**' . $type . ' ' . $name . "** | "
|
||||
. $this->linkPowerRepo($power) . ' | '
|
||||
. $this->linkPowerCode($power) . ' | '
|
||||
. $this->linkPowerSettings($power) . ' | '
|
||||
. $this->linkPowerSPK($power);
|
||||
. $this->linkPowerSettings($power) . ' | SPK: `'
|
||||
. $this->linkPowerSPK($power) .'`';
|
||||
}
|
||||
|
||||
/**
|
@@ -9,19 +9,19 @@
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Power;
|
||||
namespace VDM\Joomla\Componentbuilder\Power\Remote;
|
||||
|
||||
|
||||
use VDM\Joomla\Interfaces\Data\RemoteInterface;
|
||||
use VDM\Joomla\Data\Remote;
|
||||
use VDM\Joomla\Interfaces\Remote\GetInterface;
|
||||
use VDM\Joomla\Abstraction\Remote\Get as ExtendingGet;
|
||||
|
||||
|
||||
/**
|
||||
* Superpower of JCB
|
||||
* Remote Get Power of JCB
|
||||
*
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class Super extends Remote implements RemoteInterface
|
||||
final class Get extends ExtendingGet implements GetInterface
|
||||
{
|
||||
/**
|
||||
* Table Name
|
@@ -0,0 +1 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -17,8 +17,8 @@ use Joomla\DI\ServiceProviderInterface;
|
||||
use VDM\Joomla\Componentbuilder\Power\Config;
|
||||
use VDM\Joomla\Componentbuilder\Table;
|
||||
use VDM\Joomla\Componentbuilder\Power\Grep;
|
||||
use VDM\Joomla\Componentbuilder\Power\Super as Superpower;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Power\Parser;
|
||||
use VDM\Joomla\Componentbuilder\Power\Remote\Get;
|
||||
use VDM\Joomla\Componentbuilder\Power\Parser;
|
||||
|
||||
|
||||
/**
|
||||
@@ -47,8 +47,8 @@ class Power implements ServiceProviderInterface
|
||||
$container->alias(Grep::class, 'Power.Grep')
|
||||
->share('Power.Grep', [$this, 'getGrep'], true);
|
||||
|
||||
$container->alias(Superpower::class, 'Superpower')
|
||||
->share('Superpower', [$this, 'getSuperpower'], true);
|
||||
$container->alias(Get::class, 'Power.Remote.Get')
|
||||
->share('Power.Remote.Get', [$this, 'getRemoteGet'], true);
|
||||
|
||||
$container->alias(Parser::class, 'Power.Parser')
|
||||
->share('Power.Parser', [$this, 'getParser'], true);
|
||||
@@ -98,16 +98,16 @@ class Power implements ServiceProviderInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The Super Class.
|
||||
* Get The Remote Get Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return Superpower
|
||||
* @return Get
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getSuperpower(Container $container): Superpower
|
||||
public function getRemoteGet(Container $container): Get
|
||||
{
|
||||
return new Superpower(
|
||||
return new Get(
|
||||
$container->get('Power.Grep'),
|
||||
$container->get('Data.Item')
|
||||
);
|
||||
|
@@ -1558,7 +1558,6 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'tab_name' => 'publishing',
|
||||
'db' => [
|
||||
'type' => 'TEXT',
|
||||
'default' => '',
|
||||
],
|
||||
],
|
||||
'metadesc' => [
|
||||
@@ -1570,7 +1569,6 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'tab_name' => 'publishing',
|
||||
'db' => [
|
||||
'type' => 'TEXT',
|
||||
'default' => '',
|
||||
],
|
||||
],
|
||||
'metadata' => [
|
||||
@@ -1582,7 +1580,6 @@ final class Table extends BaseTable implements Tableinterface
|
||||
'tab_name' => 'publishing',
|
||||
'db' => [
|
||||
'type' => 'TEXT',
|
||||
'default' => '',
|
||||
],
|
||||
],
|
||||
],
|
||||
|
@@ -0,0 +1,72 @@
|
||||
<?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\Table;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Table;
|
||||
use VDM\Joomla\Componentbuilder\Table\Schema;
|
||||
use VDM\Joomla\Interfaces\SchemaCheckerInterface;
|
||||
use VDM\Joomla\Abstraction\SchemaChecker as ExtendingSchemaChecker;
|
||||
|
||||
|
||||
/**
|
||||
* Componentbuilder Tables Schema Checker
|
||||
*
|
||||
* @since 3.2.2
|
||||
*/
|
||||
final class SchemaChecker extends ExtendingSchemaChecker implements SchemaCheckerInterface
|
||||
{
|
||||
/**
|
||||
* Get the targeted component code
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected function getCode(): string
|
||||
{
|
||||
return 'componentbuilder';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the targeted component power path
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected function getPowerPath(): string
|
||||
{
|
||||
return 'src/Helper/PowerloaderHelper.php';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fully qualified name of the schema class.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected function getSchemaClass(): string
|
||||
{
|
||||
return Schema::class;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the fully qualified name of the table class.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.2
|
||||
*/
|
||||
protected function getTableClass(): string
|
||||
{
|
||||
return Table::class;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user