update 2024-05-25 20:54:21
This commit is contained in:
parent
60fe05b75c
commit
428bbdc503
@ -54,8 +54,8 @@ This repository contains an index (see below) of all the approved powers within
|
|||||||
|
|
||||||
- **abstract class Factory** | [Details](src/a5734b9e-a72d-494c-bc72-c3bc7506015f) | [Code](src/a5734b9e-a72d-494c-bc72-c3bc7506015f/code.php) | [Settings](src/a5734b9e-a72d-494c-bc72-c3bc7506015f/settings.json) | Super__a5734b9e_a72d_494c_bc72_c3bc7506015f__Power
|
- **abstract class Factory** | [Details](src/a5734b9e-a72d-494c-bc72-c3bc7506015f) | [Code](src/a5734b9e-a72d-494c-bc72-c3bc7506015f/code.php) | [Settings](src/a5734b9e-a72d-494c-bc72-c3bc7506015f/settings.json) | Super__a5734b9e_a72d_494c_bc72_c3bc7506015f__Power
|
||||||
- **final class Generator** | [Details](src/505801ac-d3e2-44c6-a300-9a57a96170c6) | [Code](src/505801ac-d3e2-44c6-a300-9a57a96170c6/code.php) | [Settings](src/505801ac-d3e2-44c6-a300-9a57a96170c6/settings.json) | Super__505801ac_d3e2_44c6_a300_9a57a96170c6__Power
|
- **final class Generator** | [Details](src/505801ac-d3e2-44c6-a300-9a57a96170c6) | [Code](src/505801ac-d3e2-44c6-a300-9a57a96170c6/code.php) | [Settings](src/505801ac-d3e2-44c6-a300-9a57a96170c6/settings.json) | Super__505801ac_d3e2_44c6_a300_9a57a96170c6__Power
|
||||||
|
- **final class Grep** | [Details](src/6784dd52-0909-451a-a872-9a942a023c68) | [Code](src/6784dd52-0909-451a-a872-9a942a023c68/code.php) | [Settings](src/6784dd52-0909-451a-a872-9a942a023c68/settings.json) | Super__6784dd52_0909_451a_a872_9a942a023c68__Power
|
||||||
- **class Config** | [Details](src/be4ccfae-65a9-401e-bdbe-637d8c226954) | [Code](src/be4ccfae-65a9-401e-bdbe-637d8c226954/code.php) | [Settings](src/be4ccfae-65a9-401e-bdbe-637d8c226954/settings.json) | Super__be4ccfae_65a9_401e_bdbe_637d8c226954__Power
|
- **class Config** | [Details](src/be4ccfae-65a9-401e-bdbe-637d8c226954) | [Code](src/be4ccfae-65a9-401e-bdbe-637d8c226954/code.php) | [Settings](src/be4ccfae-65a9-401e-bdbe-637d8c226954/settings.json) | Super__be4ccfae_65a9_401e_bdbe_637d8c226954__Power
|
||||||
- **class Grep** | [Details](src/6784dd52-0909-451a-a872-9a942a023c68) | [Code](src/6784dd52-0909-451a-a872-9a942a023c68/code.php) | [Settings](src/6784dd52-0909-451a-a872-9a942a023c68/settings.json) | Super__6784dd52_0909_451a_a872_9a942a023c68__Power
|
|
||||||
- **class Super** | [Details](src/3ab0eba9-f37b-4b37-aec1-2e78067f2aff) | [Code](src/3ab0eba9-f37b-4b37-aec1-2e78067f2aff/code.php) | [Settings](src/3ab0eba9-f37b-4b37-aec1-2e78067f2aff/settings.json) | Super__3ab0eba9_f37b_4b37_aec1_2e78067f2aff__Power
|
- **class Super** | [Details](src/3ab0eba9-f37b-4b37-aec1-2e78067f2aff) | [Code](src/3ab0eba9-f37b-4b37-aec1-2e78067f2aff/code.php) | [Settings](src/3ab0eba9-f37b-4b37-aec1-2e78067f2aff/settings.json) | Super__3ab0eba9_f37b_4b37_aec1_2e78067f2aff__Power
|
||||||
- **Namespace**: [VDM\Joomla\Componentbuilder\Service](#vdm-joomla-componentbuilder-service)
|
- **Namespace**: [VDM\Joomla\Componentbuilder\Service](#vdm-joomla-componentbuilder-service)
|
||||||
|
|
||||||
|
@ -12,14 +12,22 @@
|
|||||||
```uml
|
```uml
|
||||||
@startuml
|
@startuml
|
||||||
class Grep << (F,LightGreen) >> #RoyalBlue {
|
class Grep << (F,LightGreen) >> #RoyalBlue {
|
||||||
- getLocal(object $path, string $guid) : ?object
|
# array $order
|
||||||
|
# remoteIndex(object $path) : void
|
||||||
|
- searchRemote(string $guid) : ?object
|
||||||
- getRemote(object $path, string $guid) : ?object
|
- getRemote(object $path, string $guid) : ?object
|
||||||
- localIndex(object $path) : void
|
- loadRemoteFile(string $owner, string $repo, ...) : mixed
|
||||||
- remoteIndex(object $path) : void
|
|
||||||
}
|
}
|
||||||
|
|
||||||
note right of Grep::getLocal
|
note right of Grep::remoteIndex
|
||||||
Get a local power
|
Load the remote repository index of powers
|
||||||
|
|
||||||
|
since: 3.2.0
|
||||||
|
return: void
|
||||||
|
end note
|
||||||
|
|
||||||
|
note right of Grep::searchRemote
|
||||||
|
Search for a remote power
|
||||||
|
|
||||||
since: 3.2.0
|
since: 3.2.0
|
||||||
return: ?object
|
return: ?object
|
||||||
@ -32,18 +40,17 @@ note right of Grep::getRemote
|
|||||||
return: ?object
|
return: ?object
|
||||||
end note
|
end note
|
||||||
|
|
||||||
note right of Grep::localIndex
|
note right of Grep::loadRemoteFile
|
||||||
Load the local repository index of powers
|
Load the remote file
|
||||||
|
|
||||||
since: 3.2.0
|
since: 3.2.0
|
||||||
return: void
|
return: mixed
|
||||||
end note
|
|
||||||
|
|
||||||
note right of Grep::remoteIndex
|
arguments:
|
||||||
Load the remote repository index of powers
|
string $owner
|
||||||
|
string $repo
|
||||||
since: 3.2.0
|
string $path
|
||||||
return: void
|
?string $branch
|
||||||
end note
|
end note
|
||||||
|
|
||||||
@enduml
|
@enduml
|
||||||
|
@ -12,10 +12,11 @@
|
|||||||
namespace VDM\Joomla\Componentbuilder\JoomlaPower;
|
namespace VDM\Joomla\Componentbuilder\JoomlaPower;
|
||||||
|
|
||||||
|
|
||||||
|
use Joomla\CMS\Language\Text;
|
||||||
use VDM\Joomla\Utilities\FileHelper;
|
use VDM\Joomla\Utilities\FileHelper;
|
||||||
use VDM\Joomla\Utilities\JsonHelper;
|
use VDM\Joomla\Utilities\JsonHelper;
|
||||||
use VDM\Joomla\Componentbuilder\Interfaces\GrepInterface;
|
use VDM\Joomla\Interfaces\GrepInterface;
|
||||||
use VDM\Joomla\Componentbuilder\Power\Grep as ExtendingGrep;
|
use VDM\Joomla\Abstraction\Grep as ExtendingGrep;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -31,30 +32,65 @@ use VDM\Joomla\Componentbuilder\Power\Grep as ExtendingGrep;
|
|||||||
final class Grep extends ExtendingGrep implements GrepInterface
|
final class Grep extends ExtendingGrep implements GrepInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Get a local power
|
* Order of global search
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @since 3.2.1
|
||||||
|
**/
|
||||||
|
protected array $order = ['remote'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load the remote repository index of powers
|
||||||
*
|
*
|
||||||
* @param object $path The repository path details
|
* @param object $path The repository path details
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
protected function remoteIndex(object &$path): void
|
||||||
|
{
|
||||||
|
if (isset($path->index))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$path->index = $this->contents->get($path->owner, $path->repo, 'joomla-powers.json', $path->branch);
|
||||||
|
}
|
||||||
|
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'
|
||||||
|
);
|
||||||
|
|
||||||
|
$path->index = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search for a remote power
|
||||||
|
*
|
||||||
* @param string $guid The global unique id of the power
|
* @param string $guid The global unique id of the power
|
||||||
*
|
*
|
||||||
* @return object|null
|
* @return object|null
|
||||||
* @since 3.2.0
|
* @since 3.2.0
|
||||||
*/
|
*/
|
||||||
private function getLocal(object $path, string $guid): ?object
|
private function searchRemote(string $guid): ?object
|
||||||
{
|
{
|
||||||
if (empty($path->local->{$guid}->settings))
|
// we can only search if we have paths
|
||||||
|
if ($this->path && $this->paths)
|
||||||
{
|
{
|
||||||
return 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the settings
|
|
||||||
if (($settings = FileHelper::getContent($path->full_path . '/' . $path->local->{$guid}->settings, null)) !== null &&
|
|
||||||
JsonHelper::check($settings))
|
|
||||||
{
|
|
||||||
$power = json_decode($settings);
|
|
||||||
|
|
||||||
if (isset($power->guid))
|
|
||||||
{
|
|
||||||
return $power;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,6 +117,15 @@ final class Grep extends ExtendingGrep implements GrepInterface
|
|||||||
if (($power = $this->loadRemoteFile($path->owner, $path->repo, $path->index->{$guid}->settings, $path->branch)) !== null &&
|
if (($power = $this->loadRemoteFile($path->owner, $path->repo, $path->index->{$guid}->settings, $path->branch)) !== null &&
|
||||||
isset($power->guid))
|
isset($power->guid))
|
||||||
{
|
{
|
||||||
|
// set the git details in params
|
||||||
|
$power->params = (object) [
|
||||||
|
'git' => [
|
||||||
|
'owner' => $path->owner,
|
||||||
|
'repo' => $path->repo,
|
||||||
|
'branch' => $path->branch
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
return $power;
|
return $power;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,59 +133,33 @@ final class Grep extends ExtendingGrep implements GrepInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the local repository index of powers
|
* Load the remote file
|
||||||
*
|
*
|
||||||
* @param object $path The repository path details
|
* @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
|
||||||
*
|
*
|
||||||
* @return void
|
* @return mixed
|
||||||
* @since 3.2.0
|
* @since 3.2.0
|
||||||
*/
|
*/
|
||||||
private function localIndex(object &$path)
|
private function loadRemoteFile(string $owner, string $repo, string $path, ?string $branch)
|
||||||
{
|
{
|
||||||
if (isset($path->local) || !isset($path->full_path))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (($content = FileHelper::getContent($path->full_path . '/joomla-powers.json', null)) !== null &&
|
|
||||||
JsonHelper::check($content))
|
|
||||||
{
|
|
||||||
$path->local = json_decode($content);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$path->local = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Load the remote repository index of powers
|
|
||||||
*
|
|
||||||
* @param object $path The repository path details
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
* @since 3.2.0
|
|
||||||
*/
|
|
||||||
private function remoteIndex(object &$path)
|
|
||||||
{
|
|
||||||
if (isset($path->index))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$path->index = $this->contents->get($path->owner, $path->repo, 'joomla-powers.json', $path->branch);
|
$data = $this->contents->get($owner, $repo, $path, $branch);
|
||||||
}
|
}
|
||||||
catch (\Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
$this->app->enqueueMessage(
|
$this->app->enqueueMessage(
|
||||||
Text::sprintf('COM_COMPONENTBUILDER_PSUPER_POWERB_REPOSITORY_AT_BSSB_GAVE_THE_FOLLOWING_ERRORBR_SP', $this->contents->api(), $path->path, $e->getMessage()),
|
Text::sprintf('COM_COMPONENTBUILDER_PFILE_AT_BSSB_GAVE_THE_FOLLOWING_ERRORBR_SP', $this->contents->api(), $path, $e->getMessage()),
|
||||||
'Error'
|
'Error'
|
||||||
);
|
);
|
||||||
|
|
||||||
$path->index = null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,28 +1,63 @@
|
|||||||
/**
|
/**
|
||||||
* Get a local power
|
* Order of global search
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @since 3.2.1
|
||||||
|
**/
|
||||||
|
protected array $order = ['remote'];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load the remote repository index of powers
|
||||||
*
|
*
|
||||||
* @param object $path The repository path details
|
* @param object $path The repository path details
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
protected function remoteIndex(object &$path): void
|
||||||
|
{
|
||||||
|
if (isset($path->index))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
$path->index = $this->contents->get($path->owner, $path->repo, 'joomla-powers.json', $path->branch);
|
||||||
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
$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->path, $e->getMessage()),
|
||||||
|
'Error'
|
||||||
|
);
|
||||||
|
|
||||||
|
$path->index = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search for a remote power
|
||||||
|
*
|
||||||
* @param string $guid The global unique id of the power
|
* @param string $guid The global unique id of the power
|
||||||
*
|
*
|
||||||
* @return object|null
|
* @return object|null
|
||||||
* @since 3.2.0
|
* @since 3.2.0
|
||||||
*/
|
*/
|
||||||
private function getLocal(object $path, string $guid): ?object
|
private function searchRemote(string $guid): ?object
|
||||||
{
|
{
|
||||||
if (empty($path->local->{$guid}->settings))
|
// we can only search if we have paths
|
||||||
|
if ($this->path && $this->paths)
|
||||||
{
|
{
|
||||||
return 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);
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the settings
|
|
||||||
if (($settings = FileHelper::getContent($path->full_path . '/' . $path->local->{$guid}->settings, null)) !== null &&
|
|
||||||
JsonHelper::check($settings))
|
|
||||||
{
|
|
||||||
$power = json_decode($settings);
|
|
||||||
|
|
||||||
if (isset($power->guid))
|
|
||||||
{
|
|
||||||
return $power;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,6 +84,15 @@
|
|||||||
if (($power = $this->loadRemoteFile($path->owner, $path->repo, $path->index->{$guid}->settings, $path->branch)) !== null &&
|
if (($power = $this->loadRemoteFile($path->owner, $path->repo, $path->index->{$guid}->settings, $path->branch)) !== null &&
|
||||||
isset($power->guid))
|
isset($power->guid))
|
||||||
{
|
{
|
||||||
|
// set the git details in params
|
||||||
|
$power->params = (object) [
|
||||||
|
'git' => [
|
||||||
|
'owner' => $path->owner,
|
||||||
|
'repo' => $path->repo,
|
||||||
|
'branch' => $path->branch
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
return $power;
|
return $power;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,57 +100,31 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the local repository index of powers
|
* Load the remote file
|
||||||
*
|
*
|
||||||
* @param object $path The repository path details
|
* @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
|
||||||
*
|
*
|
||||||
* @return void
|
* @return mixed
|
||||||
* @since 3.2.0
|
* @since 3.2.0
|
||||||
*/
|
*/
|
||||||
private function localIndex(object &$path)
|
private function loadRemoteFile(string $owner, string $repo, string $path, ?string $branch)
|
||||||
{
|
{
|
||||||
if (isset($path->local) || !isset($path->full_path))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (($content = FileHelper::getContent($path->full_path . '/joomla-powers.json', null)) !== null &&
|
|
||||||
JsonHelper::check($content))
|
|
||||||
{
|
|
||||||
$path->local = json_decode($content);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$path->local = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Load the remote repository index of powers
|
|
||||||
*
|
|
||||||
* @param object $path The repository path details
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
* @since 3.2.0
|
|
||||||
*/
|
|
||||||
private function remoteIndex(object &$path)
|
|
||||||
{
|
|
||||||
if (isset($path->index))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
$path->index = $this->contents->get($path->owner, $path->repo, 'joomla-powers.json', $path->branch);
|
$data = $this->contents->get($owner, $repo, $path, $branch);
|
||||||
}
|
}
|
||||||
catch (\Exception $e)
|
catch (\Exception $e)
|
||||||
{
|
{
|
||||||
$this->app->enqueueMessage(
|
$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->path, $e->getMessage()),
|
Text::sprintf('<p>File at <b>%s/%s</b> gave the following error!<br />%s</p>', $this->contents->api(), $path, $e->getMessage()),
|
||||||
'Error'
|
'Error'
|
||||||
);
|
);
|
||||||
|
|
||||||
$path->index = null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $data;
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"add_head": "0",
|
"add_head": "1",
|
||||||
"add_licensing_template": "2",
|
"add_licensing_template": "2",
|
||||||
"extends": "6784dd52-0909-451a-a872-9a942a023c68",
|
"extends": "1401a167-0ce4-4f4a-afee-2d8b02ed339b",
|
||||||
"guid": "355bf21a-f859-4528-9110-bcd2c6d05ea7",
|
"guid": "355bf21a-f859-4528-9110-bcd2c6d05ea7",
|
||||||
"implements": [
|
"implements": [
|
||||||
"c182506a-ab84-439c-b962-1e606b58d545"
|
"c182506a-ab84-439c-b962-1e606b58d545"
|
||||||
@ -24,6 +24,6 @@
|
|||||||
"namespace": "VDM\\Joomla\\Componentbuilder.JoomlaPower.Grep",
|
"namespace": "VDM\\Joomla\\Componentbuilder.JoomlaPower.Grep",
|
||||||
"description": "Global Resource Empowerment Platform\r\n\r\n The Grep feature will try to find your joomla power in the repositories listed in the global\r\n Options of JCB in the super powers tab, and if it can't be found there will try the global core\r\n Super powers of JCB. All searches are performed according the the [algorithm:cascading]\r\n See documentation for more details: https:\/\/git.vdm.dev\/joomla\/super-powers\/wiki\r\n\r\n@since 3.2.1",
|
"description": "Global Resource Empowerment Platform\r\n\r\n The Grep feature will try to find your joomla power in the repositories listed in the global\r\n Options of JCB in the super powers tab, and if it can't be found there will try the global core\r\n Super powers of JCB. All searches are performed according the the [algorithm:cascading]\r\n See documentation for more details: https:\/\/git.vdm.dev\/joomla\/super-powers\/wiki\r\n\r\n@since 3.2.1",
|
||||||
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/joomla\/Component-Builder>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
|
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/joomla\/Component-Builder>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
|
||||||
"head": "",
|
"head": "use Joomla\\CMS\\Language\\Text;",
|
||||||
"composer": ""
|
"composer": ""
|
||||||
}
|
}
|
@ -12,7 +12,7 @@
|
|||||||
namespace VDM\Joomla\Componentbuilder\Power;
|
namespace VDM\Joomla\Componentbuilder\Power;
|
||||||
|
|
||||||
|
|
||||||
use VDM\Joomla\Componentbuilder\Interfaces\GrepInterface as Grep;
|
use VDM\Joomla\Interfaces\GrepInterface as Grep;
|
||||||
use VDM\Joomla\Componentbuilder\Interfaces\Database\InsertInterface as Insert;
|
use VDM\Joomla\Componentbuilder\Interfaces\Database\InsertInterface as Insert;
|
||||||
use VDM\Joomla\Componentbuilder\Interfaces\Database\UpdateInterface as Update;
|
use VDM\Joomla\Componentbuilder\Interfaces\Database\UpdateInterface as Update;
|
||||||
use VDM\Joomla\Utilities\GuidHelper;
|
use VDM\Joomla\Utilities\GuidHelper;
|
||||||
|
@ -6,56 +6,29 @@
|
|||||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║
|
||||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝
|
||||||
```
|
```
|
||||||
# class Grep (Details)
|
# final class Grep (Details)
|
||||||
> namespace: **VDM\Joomla\Componentbuilder\Power**
|
> namespace: **VDM\Joomla\Componentbuilder\Power**
|
||||||
|
> extends: **ExtendingGrep**
|
||||||
```uml
|
```uml
|
||||||
@startuml
|
@startuml
|
||||||
class Grep #Gold {
|
class Grep << (F,LightGreen) >> #RoyalBlue {
|
||||||
+ ?string $path
|
# remoteIndex(object $path) : void
|
||||||
+ ?array $paths
|
|
||||||
# Contents $contents
|
|
||||||
# CMSApplication $app
|
|
||||||
+ __construct(string $path, array $paths, ...)
|
|
||||||
+ getRemotePowersGuid() : ?array
|
|
||||||
+ get(string $guid, array $order = ['local', 'remote']) : ?object
|
|
||||||
- searchLocal(string $guid) : ?object
|
- searchLocal(string $guid) : ?object
|
||||||
- searchRemote(string $guid) : ?object
|
- searchRemote(string $guid) : ?object
|
||||||
- getLocal(object $path, string $guid) : ?object
|
- getLocal(object $path, string $guid) : ?object
|
||||||
- getRemote(object $path, string $guid) : ?object
|
- getRemote(object $path, string $guid) : ?object
|
||||||
- init() : void
|
|
||||||
- localIndex(object $path) : void
|
|
||||||
- remoteIndex(object $path) : void
|
|
||||||
- loadRemoteFile(string $owner, string $repo, ...) : mixed
|
- loadRemoteFile(string $owner, string $repo, ...) : mixed
|
||||||
- getFunctionName(string $name) : ?string
|
- localIndex(object $path) : void
|
||||||
}
|
}
|
||||||
|
|
||||||
note right of Grep::__construct
|
note right of Grep::remoteIndex
|
||||||
Constructor.
|
Load the remote repository index of powers
|
||||||
|
|
||||||
since: 3.2.0
|
since: 3.2.0
|
||||||
|
return: void
|
||||||
arguments:
|
|
||||||
string $path
|
|
||||||
array $paths
|
|
||||||
Contents $contents
|
|
||||||
?CMSApplication $app = null
|
|
||||||
end note
|
end note
|
||||||
|
|
||||||
note left of Grep::getRemotePowersGuid
|
note right of Grep::searchLocal
|
||||||
Get all remote powers GUID's
|
|
||||||
|
|
||||||
since: 3.2.0
|
|
||||||
return: ?array
|
|
||||||
end note
|
|
||||||
|
|
||||||
note right of Grep::get
|
|
||||||
Get a power
|
|
||||||
|
|
||||||
since: 3.2.0
|
|
||||||
return: ?object
|
|
||||||
end note
|
|
||||||
|
|
||||||
note left of Grep::searchLocal
|
|
||||||
Search for a local power
|
Search for a local power
|
||||||
|
|
||||||
since: 3.2.0
|
since: 3.2.0
|
||||||
@ -69,7 +42,7 @@ note right of Grep::searchRemote
|
|||||||
return: ?object
|
return: ?object
|
||||||
end note
|
end note
|
||||||
|
|
||||||
note left of Grep::getLocal
|
note right of Grep::getLocal
|
||||||
Get a local power
|
Get a local power
|
||||||
|
|
||||||
since: 3.2.0
|
since: 3.2.0
|
||||||
@ -83,27 +56,6 @@ note right of Grep::getRemote
|
|||||||
return: ?object
|
return: ?object
|
||||||
end note
|
end note
|
||||||
|
|
||||||
note left of Grep::init
|
|
||||||
Set path details
|
|
||||||
|
|
||||||
since: 3.2.0
|
|
||||||
return: void
|
|
||||||
end note
|
|
||||||
|
|
||||||
note right of Grep::localIndex
|
|
||||||
Load the local repository index of powers
|
|
||||||
|
|
||||||
since: 3.2.0
|
|
||||||
return: void
|
|
||||||
end note
|
|
||||||
|
|
||||||
note left of Grep::remoteIndex
|
|
||||||
Load the remote repository index of powers
|
|
||||||
|
|
||||||
since: 3.2.0
|
|
||||||
return: void
|
|
||||||
end note
|
|
||||||
|
|
||||||
note right of Grep::loadRemoteFile
|
note right of Grep::loadRemoteFile
|
||||||
Load the remote file
|
Load the remote file
|
||||||
|
|
||||||
@ -117,11 +69,11 @@ note right of Grep::loadRemoteFile
|
|||||||
?string $branch
|
?string $branch
|
||||||
end note
|
end note
|
||||||
|
|
||||||
note left of Grep::getFunctionName
|
note right of Grep::localIndex
|
||||||
Get function name
|
Load the local repository index of powers
|
||||||
|
|
||||||
since: 3.2.0
|
since: 3.2.0
|
||||||
return: ?string
|
return: void
|
||||||
end note
|
end note
|
||||||
|
|
||||||
@enduml
|
@enduml
|
||||||
|
@ -12,14 +12,11 @@
|
|||||||
namespace VDM\Joomla\Componentbuilder\Power;
|
namespace VDM\Joomla\Componentbuilder\Power;
|
||||||
|
|
||||||
|
|
||||||
use Joomla\CMS\Factory;
|
|
||||||
use Joomla\CMS\Filesystem\Folder;
|
|
||||||
use Joomla\CMS\Application\CMSApplication;
|
|
||||||
use Joomla\CMS\Language\Text;
|
use Joomla\CMS\Language\Text;
|
||||||
use VDM\Joomla\Gitea\Repository\Contents;
|
|
||||||
use VDM\Joomla\Utilities\FileHelper;
|
use VDM\Joomla\Utilities\FileHelper;
|
||||||
use VDM\Joomla\Utilities\JsonHelper;
|
use VDM\Joomla\Utilities\JsonHelper;
|
||||||
use VDM\Joomla\Componentbuilder\Interfaces\GrepInterface;
|
use VDM\Joomla\Interfaces\GrepInterface;
|
||||||
|
use VDM\Joomla\Abstraction\Grep as ExtendingGrep;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -32,116 +29,38 @@ use VDM\Joomla\Componentbuilder\Interfaces\GrepInterface;
|
|||||||
*
|
*
|
||||||
* @since 3.2.0
|
* @since 3.2.0
|
||||||
*/
|
*/
|
||||||
class Grep implements GrepInterface
|
final class Grep extends ExtendingGrep implements GrepInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* The local path
|
* Load the remote repository index of powers
|
||||||
*
|
*
|
||||||
* @var string
|
* @param object $path The repository path details
|
||||||
* @since 3.2.0
|
|
||||||
**/
|
|
||||||
public ?string $path;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* All approved paths
|
|
||||||
*
|
*
|
||||||
* @var array
|
* @return void
|
||||||
* @since 3.2.0
|
|
||||||
**/
|
|
||||||
public ?array $paths;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gitea Repository Contents
|
|
||||||
*
|
|
||||||
* @var Contents
|
|
||||||
* @since 3.2.0
|
|
||||||
**/
|
|
||||||
protected Contents $contents;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Joomla Application object
|
|
||||||
*
|
|
||||||
* @var CMSApplication
|
|
||||||
* @since 3.2.0
|
|
||||||
**/
|
|
||||||
protected CMSApplication $app;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor.
|
|
||||||
*
|
|
||||||
* @param string $path The local path
|
|
||||||
* @param array $paths The approved paths
|
|
||||||
* @param Contents $contents The Gitea Repository Contents object.
|
|
||||||
* @param CMSApplication|null $app The CMS Application object.
|
|
||||||
*
|
|
||||||
* @throws \Exception
|
|
||||||
* @since 3.2.0
|
* @since 3.2.0
|
||||||
*/
|
*/
|
||||||
public function __construct(string $path, array $paths, Contents $contents, ?CMSApplication $app = null)
|
protected function remoteIndex(object &$path): void
|
||||||
{
|
{
|
||||||
$this->path = $path;
|
if (isset($path->index))
|
||||||
$this->paths = $paths;
|
{
|
||||||
$this->contents = $contents;
|
return;
|
||||||
$this->app = $app ?: Factory::getApplication();
|
|
||||||
|
|
||||||
$this->init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
try
|
||||||
* Get all remote powers GUID's
|
|
||||||
*
|
|
||||||
* @return array|null
|
|
||||||
* @since 3.2.0
|
|
||||||
*/
|
|
||||||
public function getRemotePowersGuid(): ?array
|
|
||||||
{
|
{
|
||||||
if (!is_array($this->paths) || $this->paths === [])
|
$path->index = $this->contents->get($path->owner, $path->repo, 'super-powers.json', $path->branch);
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
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'
|
||||||
|
);
|
||||||
|
|
||||||
$powers = [];
|
$path->index = null;
|
||||||
foreach ($this->paths as $path)
|
|
||||||
{
|
|
||||||
// Get local index
|
|
||||||
$this->remoteIndex($path);
|
|
||||||
|
|
||||||
if (isset($path->index) && is_object($path->index))
|
|
||||||
{
|
|
||||||
$powers = array_merge($powers, array_keys((array) $path->index));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return empty($powers) ? null : array_unique($powers);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a power
|
|
||||||
*
|
|
||||||
* @param string $guid The global unique id of the power
|
|
||||||
* @param array $order The search order
|
|
||||||
*
|
|
||||||
* @return object|null
|
|
||||||
* @since 3.2.0
|
|
||||||
*/
|
|
||||||
public function get(string $guid, array $order = ['local', 'remote']): ?object
|
|
||||||
{
|
|
||||||
// we can only search if we have paths
|
|
||||||
if (is_array($this->paths) && $this->paths !== [])
|
|
||||||
{
|
|
||||||
foreach ($order as $target)
|
|
||||||
{
|
|
||||||
if (($function_name = $this->getFunctionName($target)) !== null &&
|
|
||||||
($power = $this->{$function_name}($guid)) !== null)
|
|
||||||
{
|
|
||||||
return $power;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search for a local power
|
* Search for a local power
|
||||||
*
|
*
|
||||||
@ -262,100 +181,6 @@ class Grep implements GrepInterface
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set path details
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
* @since 3.2.0
|
|
||||||
*/
|
|
||||||
private function init()
|
|
||||||
{
|
|
||||||
if (is_array($this->paths) && $this->paths !== [])
|
|
||||||
{
|
|
||||||
foreach ($this->paths as $n => &$path)
|
|
||||||
{
|
|
||||||
if (isset($path->owner) && strlen($path->owner) > 1 &&
|
|
||||||
isset($path->repo) && strlen($path->repo) > 1)
|
|
||||||
{
|
|
||||||
// build the path
|
|
||||||
$path->path = trim($path->owner) . '/' . trim($path->repo);
|
|
||||||
|
|
||||||
// update the branch
|
|
||||||
if ($path->branch === 'default' || empty($path->branch))
|
|
||||||
{
|
|
||||||
$path->branch = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// set local path
|
|
||||||
if ($this->path && Folder::exists($this->path . '/' . $path->path))
|
|
||||||
{
|
|
||||||
$path->full_path = $this->path . '/' . $path->path;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
unset($this->paths[$n]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Load the local repository index of powers
|
|
||||||
*
|
|
||||||
* @param object $path The repository path details
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
* @since 3.2.0
|
|
||||||
*/
|
|
||||||
private function localIndex(object &$path)
|
|
||||||
{
|
|
||||||
if (isset($path->local) || !isset($path->full_path))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (($content = FileHelper::getContent($path->full_path . '/super-powers.json', null)) !== null &&
|
|
||||||
JsonHelper::check($content))
|
|
||||||
{
|
|
||||||
$path->local = json_decode($content);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$path->local = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Load the remote repository index of powers
|
|
||||||
*
|
|
||||||
* @param object $path The repository path details
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
* @since 3.2.0
|
|
||||||
*/
|
|
||||||
private function remoteIndex(object &$path)
|
|
||||||
{
|
|
||||||
if (isset($path->index))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
$path->index = $this->contents->get($path->owner, $path->repo, 'super-powers.json', $path->branch);
|
|
||||||
}
|
|
||||||
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'
|
|
||||||
);
|
|
||||||
|
|
||||||
$path->index = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the remote file
|
* Load the remote file
|
||||||
*
|
*
|
||||||
@ -387,18 +212,29 @@ class Grep implements GrepInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get function name
|
* Load the local repository index of powers
|
||||||
*
|
*
|
||||||
* @param string $name The targeted function name
|
* @param object $path The repository path details
|
||||||
*
|
*
|
||||||
* @return string|null
|
* @return void
|
||||||
* @since 3.2.0
|
* @since 3.2.0
|
||||||
*/
|
*/
|
||||||
private function getFunctionName(string $name): ?string
|
private function localIndex(object &$path)
|
||||||
{
|
{
|
||||||
$function_name = 'search' . ucfirst(strtolower($name));
|
if (isset($path->local) || !isset($path->full_path))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
return method_exists($this, $function_name) ? $function_name : null;
|
if (($content = FileHelper::getContent($path->full_path . '/super-powers.json', null)) !== null &&
|
||||||
|
JsonHelper::check($content))
|
||||||
|
{
|
||||||
|
$path->local = json_decode($content);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$path->local = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,111 +1,33 @@
|
|||||||
/**
|
/**
|
||||||
* The local path
|
* Load the remote repository index of powers
|
||||||
*
|
*
|
||||||
* @var string
|
* @param object $path The repository path details
|
||||||
* @since 3.2.0
|
|
||||||
**/
|
|
||||||
public ?string $path;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* All approved paths
|
|
||||||
*
|
*
|
||||||
* @var array
|
* @return void
|
||||||
* @since 3.2.0
|
|
||||||
**/
|
|
||||||
public ?array $paths;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gitea Repository Contents
|
|
||||||
*
|
|
||||||
* @var Contents
|
|
||||||
* @since 3.2.0
|
|
||||||
**/
|
|
||||||
protected Contents $contents;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Joomla Application object
|
|
||||||
*
|
|
||||||
* @var CMSApplication
|
|
||||||
* @since 3.2.0
|
|
||||||
**/
|
|
||||||
protected CMSApplication $app;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor.
|
|
||||||
*
|
|
||||||
* @param string $path The local path
|
|
||||||
* @param array $paths The approved paths
|
|
||||||
* @param Contents $contents The Gitea Repository Contents object.
|
|
||||||
* @param CMSApplication|null $app The CMS Application object.
|
|
||||||
*
|
|
||||||
* @throws \Exception
|
|
||||||
* @since 3.2.0
|
* @since 3.2.0
|
||||||
*/
|
*/
|
||||||
public function __construct(string $path, array $paths, Contents $contents, ?CMSApplication $app = null)
|
protected function remoteIndex(object &$path): void
|
||||||
{
|
{
|
||||||
$this->path = $path;
|
if (isset($path->index))
|
||||||
$this->paths = $paths;
|
{
|
||||||
$this->contents = $contents;
|
return;
|
||||||
$this->app = $app ?: Factory::getApplication();
|
|
||||||
|
|
||||||
$this->init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
try
|
||||||
* Get all remote powers GUID's
|
|
||||||
*
|
|
||||||
* @return array|null
|
|
||||||
* @since 3.2.0
|
|
||||||
*/
|
|
||||||
public function getRemotePowersGuid(): ?array
|
|
||||||
{
|
{
|
||||||
if (!is_array($this->paths) || $this->paths === [])
|
$path->index = $this->contents->get($path->owner, $path->repo, 'super-powers.json', $path->branch);
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
catch (\Exception $e)
|
||||||
|
{
|
||||||
|
$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->path, $e->getMessage()),
|
||||||
|
'Error'
|
||||||
|
);
|
||||||
|
|
||||||
$powers = [];
|
$path->index = null;
|
||||||
foreach ($this->paths as $path)
|
|
||||||
{
|
|
||||||
// Get local index
|
|
||||||
$this->remoteIndex($path);
|
|
||||||
|
|
||||||
if (isset($path->index) && is_object($path->index))
|
|
||||||
{
|
|
||||||
$powers = array_merge($powers, array_keys((array) $path->index));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return empty($powers) ? null : array_unique($powers);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get a power
|
|
||||||
*
|
|
||||||
* @param string $guid The global unique id of the power
|
|
||||||
* @param array $order The search order
|
|
||||||
*
|
|
||||||
* @return object|null
|
|
||||||
* @since 3.2.0
|
|
||||||
*/
|
|
||||||
public function get(string $guid, array $order = ['local', 'remote']): ?object
|
|
||||||
{
|
|
||||||
// we can only search if we have paths
|
|
||||||
if (is_array($this->paths) && $this->paths !== [])
|
|
||||||
{
|
|
||||||
foreach ($order as $target)
|
|
||||||
{
|
|
||||||
if (($function_name = $this->getFunctionName($target)) !== null &&
|
|
||||||
($power = $this->{$function_name}($guid)) !== null)
|
|
||||||
{
|
|
||||||
return $power;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search for a local power
|
* Search for a local power
|
||||||
*
|
*
|
||||||
@ -226,100 +148,6 @@
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Set path details
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
* @since 3.2.0
|
|
||||||
*/
|
|
||||||
private function init()
|
|
||||||
{
|
|
||||||
if (is_array($this->paths) && $this->paths !== [])
|
|
||||||
{
|
|
||||||
foreach ($this->paths as $n => &$path)
|
|
||||||
{
|
|
||||||
if (isset($path->owner) && strlen($path->owner) > 1 &&
|
|
||||||
isset($path->repo) && strlen($path->repo) > 1)
|
|
||||||
{
|
|
||||||
// build the path
|
|
||||||
$path->path = trim($path->owner) . '/' . trim($path->repo);
|
|
||||||
|
|
||||||
// update the branch
|
|
||||||
if ($path->branch === 'default' || empty($path->branch))
|
|
||||||
{
|
|
||||||
$path->branch = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// set local path
|
|
||||||
if ($this->path && Folder::exists($this->path . '/' . $path->path))
|
|
||||||
{
|
|
||||||
$path->full_path = $this->path . '/' . $path->path;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
unset($this->paths[$n]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Load the local repository index of powers
|
|
||||||
*
|
|
||||||
* @param object $path The repository path details
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
* @since 3.2.0
|
|
||||||
*/
|
|
||||||
private function localIndex(object &$path)
|
|
||||||
{
|
|
||||||
if (isset($path->local) || !isset($path->full_path))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (($content = FileHelper::getContent($path->full_path . '/super-powers.json', null)) !== null &&
|
|
||||||
JsonHelper::check($content))
|
|
||||||
{
|
|
||||||
$path->local = json_decode($content);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$path->local = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Load the remote repository index of powers
|
|
||||||
*
|
|
||||||
* @param object $path The repository path details
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
* @since 3.2.0
|
|
||||||
*/
|
|
||||||
private function remoteIndex(object &$path)
|
|
||||||
{
|
|
||||||
if (isset($path->index))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
$path->index = $this->contents->get($path->owner, $path->repo, 'super-powers.json', $path->branch);
|
|
||||||
}
|
|
||||||
catch (\Exception $e)
|
|
||||||
{
|
|
||||||
$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->path, $e->getMessage()),
|
|
||||||
'Error'
|
|
||||||
);
|
|
||||||
|
|
||||||
$path->index = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the remote file
|
* Load the remote file
|
||||||
*
|
*
|
||||||
@ -351,16 +179,27 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get function name
|
* Load the local repository index of powers
|
||||||
*
|
*
|
||||||
* @param string $name The targeted function name
|
* @param object $path The repository path details
|
||||||
*
|
*
|
||||||
* @return string|null
|
* @return void
|
||||||
* @since 3.2.0
|
* @since 3.2.0
|
||||||
*/
|
*/
|
||||||
private function getFunctionName(string $name): ?string
|
private function localIndex(object &$path)
|
||||||
{
|
{
|
||||||
$function_name = 'search' . ucfirst(strtolower($name));
|
if (isset($path->local) || !isset($path->full_path))
|
||||||
|
{
|
||||||
return method_exists($this, $function_name) ? $function_name : null;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (($content = FileHelper::getContent($path->full_path . '/super-powers.json', null)) !== null &&
|
||||||
|
JsonHelper::check($content))
|
||||||
|
{
|
||||||
|
$path->local = json_decode($content);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$path->local = null;
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"add_head": "1",
|
"add_head": "1",
|
||||||
"add_licensing_template": "2",
|
"add_licensing_template": "2",
|
||||||
"extends": "0",
|
"extends": "1401a167-0ce4-4f4a-afee-2d8b02ed339b",
|
||||||
"guid": "6784dd52-0909-451a-a872-9a942a023c68",
|
"guid": "6784dd52-0909-451a-a872-9a942a023c68",
|
||||||
"implements": [
|
"implements": [
|
||||||
"c182506a-ab84-439c-b962-1e606b58d545"
|
"c182506a-ab84-439c-b962-1e606b58d545"
|
||||||
@ -10,17 +10,13 @@
|
|||||||
"name": "Grep",
|
"name": "Grep",
|
||||||
"power_version": "1.0.0",
|
"power_version": "1.0.0",
|
||||||
"system_name": "JCB.Power.Grep",
|
"system_name": "JCB.Power.Grep",
|
||||||
"type": "class",
|
"type": "final class",
|
||||||
"use_selection": {
|
"use_selection": {
|
||||||
"use_selection0": {
|
"use_selection0": {
|
||||||
"use": "8d1baef6-fcad-49a9-848f-428009cdb989",
|
|
||||||
"as": "default"
|
|
||||||
},
|
|
||||||
"use_selection1": {
|
|
||||||
"use": "a223b31e-ea1d-4cdf-92ae-5f9becffaff0",
|
"use": "a223b31e-ea1d-4cdf-92ae-5f9becffaff0",
|
||||||
"as": "default"
|
"as": "default"
|
||||||
},
|
},
|
||||||
"use_selection2": {
|
"use_selection1": {
|
||||||
"use": "4b225c51-d293-48e4-b3f6-5136cf5c3f18",
|
"use": "4b225c51-d293-48e4-b3f6-5136cf5c3f18",
|
||||||
"as": "default"
|
"as": "default"
|
||||||
}
|
}
|
||||||
@ -28,6 +24,6 @@
|
|||||||
"namespace": "VDM\\Joomla\\Componentbuilder.Power.Grep",
|
"namespace": "VDM\\Joomla\\Componentbuilder.Power.Grep",
|
||||||
"description": "Global Resource Empowerment Platform\r\n\r\n The Grep feature will try to find your power in the repositories listed in the global\r\n Options of JCB in the super powers tab, and if it can't be found there will try the global core\r\n Super powers of JCB. All searches are performed according the the [algorithm:cascading]\r\n See documentation for more details: https:\/\/git.vdm.dev\/joomla\/super-powers\/wiki\r\n\r\n@since 3.2.0",
|
"description": "Global Resource Empowerment Platform\r\n\r\n The Grep feature will try to find your power in the repositories listed in the global\r\n Options of JCB in the super powers tab, and if it can't be found there will try the global core\r\n Super powers of JCB. All searches are performed according the the [algorithm:cascading]\r\n See documentation for more details: https:\/\/git.vdm.dev\/joomla\/super-powers\/wiki\r\n\r\n@since 3.2.0",
|
||||||
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/joomla\/Component-Builder>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
|
"licensing_template": "\/**\r\n * @package Joomla.Component.Builder\r\n *\r\n * @created 4th September, 2022\r\n * @author Llewellyn van der Merwe <https:\/\/dev.vdm.io>\r\n * @git Joomla Component Builder <https:\/\/git.vdm.dev\/joomla\/Component-Builder>\r\n * @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.\r\n * @license GNU General Public License version 2 or later; see LICENSE.txt\r\n *\/\r\n",
|
||||||
"head": "use Joomla\\CMS\\Factory;\r\nuse Joomla\\CMS\\Filesystem\\Folder;\r\nuse Joomla\\CMS\\Application\\CMSApplication;\r\nuse Joomla\\CMS\\Language\\Text;",
|
"head": "use Joomla\\CMS\\Language\\Text;",
|
||||||
"composer": ""
|
"composer": ""
|
||||||
}
|
}
|
@ -1662,7 +1662,7 @@
|
|||||||
},
|
},
|
||||||
"6784dd52-0909-451a-a872-9a942a023c68": {
|
"6784dd52-0909-451a-a872-9a942a023c68": {
|
||||||
"name": "Grep",
|
"name": "Grep",
|
||||||
"type": "class",
|
"type": "final class",
|
||||||
"namespace": "VDM\\Joomla\\Componentbuilder\\Power",
|
"namespace": "VDM\\Joomla\\Componentbuilder\\Power",
|
||||||
"code": "src\/6784dd52-0909-451a-a872-9a942a023c68\/code.php",
|
"code": "src\/6784dd52-0909-451a-a872-9a942a023c68\/code.php",
|
||||||
"power": "src\/6784dd52-0909-451a-a872-9a942a023c68\/code.power",
|
"power": "src\/6784dd52-0909-451a-a872-9a942a023c68\/code.power",
|
||||||
|
Loading…
Reference in New Issue
Block a user