Release of v5.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,644 +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;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Power Parser
|
||||
* Very basic php class methods parser, does not catch all edge-cases!
|
||||
* Use this only on code that are following standard good practices
|
||||
* Suggested improvements are welcome
|
||||
* @since 3.2.0
|
||||
*/
|
||||
final class Parser
|
||||
{
|
||||
/**
|
||||
* Get properties and method declarations and other details from the given code.
|
||||
*
|
||||
* @param string $code The code containing class properties & methods
|
||||
*
|
||||
* @return array An array of properties & method declarations of the given code
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function code(string $code): array
|
||||
{
|
||||
return [
|
||||
'properties' => $this->properties($code),
|
||||
'methods' => $this->methods($code)
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the class body
|
||||
*
|
||||
* @param string $code The class as a string
|
||||
*
|
||||
* @return string|null The class body, or null if not found
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function getClassCode(string $code): ?string
|
||||
{
|
||||
// Match class, final class, abstract class, interface, and trait
|
||||
$pattern = '/(?:class|final class|abstract class|interface|trait)\s+[a-zA-Z0-9_]+\s*(?:extends\s+[a-zA-Z0-9_]+\s*)?(?:implements\s+[a-zA-Z0-9_]+(?:\s*,\s*[a-zA-Z0-9_]+)*)?\s*\{/s';
|
||||
|
||||
// Split the input code based on the class declaration pattern
|
||||
$parts = preg_split($pattern, $code, 2, PREG_SPLIT_DELIM_CAPTURE);
|
||||
$body = $parts[1] ?? '';
|
||||
|
||||
if ($body !== '')
|
||||
{
|
||||
// Remove leading and trailing white space
|
||||
$body = trim($body);
|
||||
|
||||
// Remove the first opening curly brace if it exists
|
||||
if (mb_substr($body, 0, 1) === '{')
|
||||
{
|
||||
$body = mb_substr($body, 1);
|
||||
}
|
||||
|
||||
// Remove the last closing curly brace if it exists
|
||||
if (mb_substr($body, -1) === '}')
|
||||
{
|
||||
$body = mb_substr($body, 0, -1);
|
||||
}
|
||||
|
||||
return $body;
|
||||
}
|
||||
|
||||
// No class body found, return null
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the class license
|
||||
*
|
||||
* @param string $code The class as a string
|
||||
*
|
||||
* @return string|null The class license, or null if not found
|
||||
* @since 3.2.0
|
||||
**/
|
||||
public function getClassLicense(string $code): ?string
|
||||
{
|
||||
// Check if the file starts with '<?php'
|
||||
if (substr($code, 0, 5) !== '<?php')
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// Trim the '<?php' part
|
||||
$code = ltrim(substr($code, 5));
|
||||
|
||||
// Check if the next part starts with '/*'
|
||||
if (substr($code, 0, 2) !== '/*')
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
// Find the position of the closing comment '*/'
|
||||
$endCommentPos = strpos($code, '*/');
|
||||
|
||||
// If the closing comment '*/' is found, extract and return the license
|
||||
if ($endCommentPos !== false)
|
||||
{
|
||||
$license = substr($code, 2, $endCommentPos - 2);
|
||||
return trim($license);
|
||||
}
|
||||
|
||||
// No license found, return null
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the first consecutive `use` statements from the given PHP class.
|
||||
*
|
||||
* @param string $code The PHP class as a string
|
||||
*
|
||||
* @return array|null An array of consecutive `use` statements
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getUseStatements(string $code): ?array
|
||||
{
|
||||
// Match class, final class, abstract class, interface, and trait
|
||||
$pattern = '/(?:class|final class|abstract class|interface|trait)\s+[a-zA-Z0-9_]+\s*(?:extends\s+[a-zA-Z0-9_]+\s*)?(?:implements\s+[a-zA-Z0-9_]+(?:\s*,\s*[a-zA-Z0-9_]+)*)?\s*\{/s';
|
||||
|
||||
// Split the input code based on the class declaration pattern
|
||||
$parts = preg_split($pattern, $code, 2, PREG_SPLIT_DELIM_CAPTURE);
|
||||
$header = $parts[0] ?? '';
|
||||
|
||||
$use_statements = [];
|
||||
$found_first_use = false;
|
||||
|
||||
if ($header !== '')
|
||||
{
|
||||
$lines = explode(PHP_EOL, $header);
|
||||
|
||||
foreach ($lines as $line)
|
||||
{
|
||||
if (strpos($line, 'use ') === 0)
|
||||
{
|
||||
$use_statements[] = trim($line);
|
||||
$found_first_use = true;
|
||||
}
|
||||
elseif ($found_first_use && trim($line) === '')
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $found_first_use ? $use_statements : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts trait use statements from the given code.
|
||||
*
|
||||
* @param string $code The code containing class traits
|
||||
*
|
||||
* @return array|null An array of trait names
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function getTraits(string $code): ?array
|
||||
{
|
||||
// regex to target trait use statements
|
||||
$traitPattern = '/^\s*use\s+[\p{L}0-9\\\\_]+(?:\s*,\s*[\p{L}0-9\\\\_]+)*\s*;/mu';
|
||||
|
||||
preg_match_all($traitPattern, $code, $matches, PREG_SET_ORDER);
|
||||
|
||||
if ($matches != [])
|
||||
{
|
||||
$traitNames = [];
|
||||
|
||||
foreach ($matches as $n => $match)
|
||||
{
|
||||
$declaration = $match[0] ?? null;
|
||||
|
||||
if ($declaration !== null)
|
||||
{
|
||||
$names = preg_replace('/\s*use\s+/', '', $declaration);
|
||||
$names = preg_replace('/\s*;/', '', $names);
|
||||
$names = preg_split('/\s*,\s*/', $names);
|
||||
|
||||
$traitNames = array_merge($traitNames, $names);
|
||||
}
|
||||
}
|
||||
|
||||
return $traitNames;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts properties declarations and other details from the given code.
|
||||
*
|
||||
* @param string $code The code containing class properties
|
||||
*
|
||||
* @return array|null An array of properties declarations and details
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function properties(string $code): ?array
|
||||
{
|
||||
// regex to target all properties
|
||||
$access = '(?<access>var|public|protected|private)';
|
||||
$type = '(?<type>(?:\?|)[\p{L}0-9\\\\]*\s+)?';
|
||||
$static = '(?<static>static)?';
|
||||
$name = '\$(?<name>\p{L}[\p{L}0-9]*)';
|
||||
$default = '(?:\s*=\s*(?<default>\[[^\]]*\]|\d+|\'[^\']*?\'|"[^"]*?"|false|true|null))?';
|
||||
$property_pattern = "/\b{$access}\s*{$type}{$static}\s*{$name}{$default};/u";
|
||||
|
||||
preg_match_all($property_pattern, $code, $matches, PREG_SET_ORDER);
|
||||
|
||||
if ($matches != [])
|
||||
{
|
||||
$properties = [];
|
||||
foreach ($matches as $n => $match)
|
||||
{
|
||||
$declaration = $match[0] ?? null;
|
||||
|
||||
if (is_string($declaration))
|
||||
{
|
||||
$comment = $this->extractDocBlock($code, $declaration);
|
||||
$declaration = trim(preg_replace('/\s{2,}/', ' ',
|
||||
preg_replace('/[\r\n]+/', ' ', $declaration)));
|
||||
|
||||
$properties[] = [
|
||||
'name' => isset($match['name']) ? '$' . $match['name'] : 'error',
|
||||
'access' => $match['access'] ?? 'public',
|
||||
'type' => isset($match['type']) ? trim($match['type']) : null,
|
||||
'static' => (bool) $match['static'] ?? false,
|
||||
'default' => $match['default'] ?? null,
|
||||
'comment' => $comment,
|
||||
'declaration' => $declaration
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $properties;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts method declarations and other details from the given code.
|
||||
*
|
||||
* @param string $code The code containing class methods
|
||||
*
|
||||
* @return array|null An array of method declarations and details
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function methods(string $code): ?array
|
||||
{
|
||||
// regex to target all methods/functions
|
||||
$final_modifier = '(?P<final_modifier>final)?\s*';
|
||||
$abstract_modifier = '(?P<abstract_modifier>abstract)?\s*';
|
||||
$access_modifier = '(?P<access_modifier>public|protected|private)?\s*';
|
||||
$static_modifier = '(?P<static_modifier>static)?\s*';
|
||||
$modifier = "{$final_modifier}{$abstract_modifier}{$access_modifier}{$static_modifier}";
|
||||
$name = '(?P<name>\w+)';
|
||||
$arguments = '(?P<arguments>\(.*?\))?';
|
||||
$return_type = '(?P<return_type>\s*:\s*(?:\?[\w\\\\]+|\\\\?[\w\\\\]+(?:\|\s*(?:\?[\w\\\\]+|\\\\?[\w\\\\]+))*)?)?';
|
||||
$method_pattern = "/(^\s*?\b{$modifier}function\s+{$name}{$arguments}{$return_type})/sm";
|
||||
|
||||
preg_match_all($method_pattern, $code, $matches, PREG_SET_ORDER);
|
||||
|
||||
if ($matches != [])
|
||||
{
|
||||
$methods = [];
|
||||
foreach ($matches as $n => $match)
|
||||
{
|
||||
$full_declaration = $match[0] ?? null;
|
||||
|
||||
if (is_string($full_declaration))
|
||||
{
|
||||
$comment = $this->extractDocBlock($code, $full_declaration);
|
||||
|
||||
$full_declaration = trim(preg_replace('/\s{2,}/', ' ',
|
||||
preg_replace('/[\r\n]+/', ' ', $full_declaration)));
|
||||
|
||||
// extract method's body
|
||||
$start_pos = strpos($code, $full_declaration) + strlen($full_declaration);
|
||||
$method_body = $this->extractMethodBody($code, $start_pos);
|
||||
|
||||
// now load what we found
|
||||
$methods[] = [
|
||||
'name' => $match['name'] ?? 'error',
|
||||
'access' => $match['access_modifier'] ?? 'public',
|
||||
'static' => (bool) $match['static_modifier'] ?? false,
|
||||
'final' => (bool) $match['final_modifier'] ?? false,
|
||||
'abstract' => (bool) $match['abstract_modifier'] ?? false,
|
||||
'return_type' => $this->extractReturnType($match['return_type'] ?? null, $comment),
|
||||
'since' => $this->extractSinceVersion($comment),
|
||||
'deprecated' => $this->extractDeprecatedVersion($comment),
|
||||
'arguments' => $this->extractFunctionArgumentDetails($comment, $match['arguments'] ?? null),
|
||||
'comment' => $comment,
|
||||
'declaration' => str_replace(["\r\n", "\r", "\n"], '', $full_declaration),
|
||||
'body' => $method_body
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
return $methods;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the PHPDoc block for a given function declaration.
|
||||
*
|
||||
* @param string $code The source code containing the function
|
||||
* @param string $declaration The part of the function declaration
|
||||
*
|
||||
* @return string|null The PHPDoc block, or null if not found
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function extractDocBlock(string $code, string $declaration): ?string
|
||||
{
|
||||
// Split the code string with the function declaration
|
||||
$parts = explode($declaration, $code);
|
||||
if (count($parts) < 2)
|
||||
{
|
||||
// Function declaration not found in the code
|
||||
return null;
|
||||
}
|
||||
|
||||
// Get the part with the comment (if any)
|
||||
$comment = $parts[0];
|
||||
|
||||
// Split the last part using the comment block start marker
|
||||
$commentParts = preg_split('/(})?\s+(?=\s*\/\*)(\*)?/', $comment);
|
||||
|
||||
// Get the last comment block
|
||||
$lastCommentPart = end($commentParts);
|
||||
|
||||
// Search for the comment block in the last comment part
|
||||
if (preg_match('/(\/\*\*[\s\S]*?\*\/)\s*$/u', $lastCommentPart, $matches))
|
||||
{
|
||||
$comment = $matches[1] ?? null;
|
||||
// check if we actually have a comment
|
||||
if ($comment)
|
||||
{
|
||||
return $this->removeWhiteSpaceFromComment($comment);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts method body based on starting position of method declaration.
|
||||
*
|
||||
* @param string $code The class code
|
||||
* @param string $startPos The starting position of method declaration
|
||||
*
|
||||
* @return string|null Method body or null if not found
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function extractMethodBody(string $code, int $startPos): ?string
|
||||
{
|
||||
$braces_count = 0;
|
||||
$in_method = false;
|
||||
$method_body = "";
|
||||
|
||||
for ($i = $startPos; $i < strlen($code); $i++) {
|
||||
if ($code[$i] === '{')
|
||||
{
|
||||
$braces_count++;
|
||||
if (!$in_method)
|
||||
{
|
||||
$in_method = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if ($code[$i] === '}')
|
||||
{
|
||||
$braces_count--;
|
||||
}
|
||||
|
||||
if ($in_method)
|
||||
{
|
||||
$method_body .= $code[$i];
|
||||
}
|
||||
|
||||
if ($braces_count <= 0 && $in_method)
|
||||
{
|
||||
// remove the closing brace
|
||||
$method_body = substr($method_body, 0, -1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $in_method ? $method_body : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the function argument details.
|
||||
*
|
||||
* @param string|null $comment The function comment if found
|
||||
* @param string|null $arguments The arguments found on function declaration
|
||||
*
|
||||
* @return array|null The function argument details
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function extractFunctionArgumentDetails(?string $comment, ?string $arguments): ?array
|
||||
{
|
||||
$arg_types_from_declaration = $this->extractArgTypesArguments($arguments);
|
||||
$arg_types_from_comments = null;
|
||||
|
||||
if ($comment)
|
||||
{
|
||||
$arg_types_from_comments = $this->extractArgTypesFromComment($comment);
|
||||
}
|
||||
|
||||
// merge the types
|
||||
if ($arg_types_from_declaration)
|
||||
{
|
||||
return $this->mergeArgumentTypes($arg_types_from_declaration, $arg_types_from_comments);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the function return type.
|
||||
*
|
||||
* @param string|null $returnType The return type found in declaration
|
||||
* @param string|null $comment The function comment if found
|
||||
*
|
||||
* @return string|null The function return type
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function extractReturnType(?string $returnType, ?string $comment): ?string
|
||||
{
|
||||
if ($returnType === null && $comment)
|
||||
{
|
||||
return $this->extractReturnTypeFromComment($comment);
|
||||
}
|
||||
|
||||
return trim(trim($returnType, ':'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts argument types from a given comment.
|
||||
*
|
||||
* @param string $comment The comment containing the argument types
|
||||
*
|
||||
* @return array|null An array of argument types
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function extractArgTypesFromComment(string $comment): ?array
|
||||
{
|
||||
preg_match_all('/@param\s+((?:[^\s|]+(?:\|)?)+)?\s+\$([^\s]+)/', $comment, $matches, PREG_SET_ORDER);
|
||||
|
||||
if ($matches !== [])
|
||||
{
|
||||
$arg_types = [];
|
||||
|
||||
foreach ($matches as $match)
|
||||
{
|
||||
$arg = $match[2] ?? null;
|
||||
$type = $match[1] ?: null;
|
||||
if (is_string($arg))
|
||||
{
|
||||
$arg_types['$' .$arg] = $type;
|
||||
}
|
||||
}
|
||||
|
||||
return $arg_types;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts argument types from a given declaration.
|
||||
*
|
||||
* @param string|null $arguments The arguments found on function declaration
|
||||
*
|
||||
* @return array|null An array of argument types
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function extractArgTypesArguments(?string $arguments): ?array
|
||||
{
|
||||
if ($arguments)
|
||||
{
|
||||
$args = preg_split('/,(?![^()\[\]]*(\)|\]))/', trim($arguments, '()'));
|
||||
if ($args !== [])
|
||||
{
|
||||
$argument_types = [];
|
||||
foreach ($args as $arg)
|
||||
{
|
||||
$eqPos = strpos($arg, '=');
|
||||
|
||||
if ($eqPos !== false)
|
||||
{
|
||||
$arg_parts = [
|
||||
substr($arg, 0, $eqPos),
|
||||
substr($arg, $eqPos + 1)
|
||||
];
|
||||
}
|
||||
else
|
||||
{
|
||||
$arg_parts = [$arg];
|
||||
}
|
||||
|
||||
if (preg_match('/(?:(\??(?:\w+|\\\\[\w\\\\]+)(?:\|\s*\??(?:\w+|\\\\[\w\\\\]+))*)\s+)?\$(\w+)/', $arg_parts[0], $arg_matches))
|
||||
{
|
||||
$type = $arg_matches[1] ?: null;
|
||||
$name = $arg_matches[2] ?: null;
|
||||
$default = isset($arg_parts[1]) ? preg_replace('/\s{2,}/', ' ',
|
||||
preg_replace('/[\r\n]+/', ' ', trim($arg_parts[1]))) : null;
|
||||
|
||||
if (is_string($name))
|
||||
{
|
||||
$argument_types['$' . $name] = [
|
||||
'type' => $type,
|
||||
'default' => $default,
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $argument_types;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts return type from a given declaration.
|
||||
*
|
||||
* @param string $comment The comment containing the return type
|
||||
*
|
||||
* @return string|null The return type
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function extractReturnTypeFromComment(string $comment): ?string
|
||||
{
|
||||
if (preg_match('/@return\s+((?:[^\s|]+(?:\|)?)+)/', $comment, $matches))
|
||||
{
|
||||
return $matches[1] ?: null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the version number from the @since tag in the given comment.
|
||||
*
|
||||
* @param string|null $comment The comment containing the @since tag and version number
|
||||
*
|
||||
* @return string|null The extracted version number or null if not found
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function extractSinceVersion(?string $comment): ?string
|
||||
{
|
||||
if (is_string($comment) && preg_match('/@since\s+(v?\d+(?:\.\d+)*(?:-(?:alpha|beta|rc)\d*)?)/', $comment, $matches))
|
||||
{
|
||||
return $matches[1] ?: null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the version number from the deprecated tag in the given comment.
|
||||
*
|
||||
* @param string|null $comment The comment containing the deprecated tag and version number
|
||||
*
|
||||
* @return string|null The extracted version number or null if not found
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function extractDeprecatedVersion(?string $comment): ?string
|
||||
{
|
||||
if (is_string($comment) && preg_match('/@deprecated\s+(v?\d+(?:\.\d+)*(?:-(?:alpha|beta|rc)\d*)?)/', $comment, $matches))
|
||||
{
|
||||
return $matches[1] ?: null;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove all white space from each line of the comment
|
||||
*
|
||||
* @param string $comment The function declaration containing the return type
|
||||
*
|
||||
* @return string The return comment
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function removeWhiteSpaceFromComment(string $comment): string
|
||||
{
|
||||
// Remove comment markers and leading/trailing whitespace
|
||||
$comment = preg_replace('/^\/\*\*[\r\n\s]*|[\r\n\s]*\*\/$/m', '', $comment);
|
||||
$comment = preg_replace('/^[\s]*\*[\s]?/m', '', $comment);
|
||||
|
||||
// Split the comment into lines
|
||||
$lines = preg_split('/\r\n|\r|\n/', $comment);
|
||||
|
||||
// Remove white spaces from each line
|
||||
$trimmedLines = array_map('trim', $lines);
|
||||
|
||||
// Join the lines back together
|
||||
return implode("\n", array_filter($trimmedLines));
|
||||
}
|
||||
|
||||
/**
|
||||
* Merges the types from the comments and the arguments.
|
||||
*
|
||||
* @param array $argTypesFromDeclaration An array of argument types and default values from the declaration
|
||||
* @param array|null $argTypesFromComments An array of argument types from the comments
|
||||
*
|
||||
* @return array A merged array of argument information
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function mergeArgumentTypes(array $argTypesFromDeclaration, ?array $argTypesFromComments): array
|
||||
{
|
||||
$mergedArguments = [];
|
||||
|
||||
foreach ($argTypesFromDeclaration as $name => $declarationInfo)
|
||||
{
|
||||
$mergedArguments[$name] = [
|
||||
'name' => $name,
|
||||
'type' => $declarationInfo['type'] ?: $argTypesFromComments[$name] ?? null,
|
||||
'default' => $declarationInfo['default'] ?: null,
|
||||
];
|
||||
}
|
||||
|
||||
return $mergedArguments;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,459 +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;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Power Plantuml Builder
|
||||
* @since 3.2.0
|
||||
*/
|
||||
class Plantuml
|
||||
{
|
||||
/**
|
||||
* Get a namespace diagram of a group of class
|
||||
*
|
||||
* @param string $namespace the namespace name
|
||||
* @param string $classes the ready build class uml
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function namespaceDiagram(string $namespace, string $classes): string
|
||||
{
|
||||
$namespace_depth = substr_count($namespace, '\\');
|
||||
$namespace_color = $this->getNamespaceColor($namespace_depth);
|
||||
|
||||
// Set the scale of the diagram
|
||||
// $plant_uml = "scale 0.8\n\n";
|
||||
|
||||
// Add namespace
|
||||
$plant_uml = "namespace $namespace #$namespace_color {\n\n";
|
||||
|
||||
// Add class
|
||||
$plant_uml .= $classes;
|
||||
|
||||
$plant_uml .= "}\n";
|
||||
|
||||
return $plant_uml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a class basic diagram of a class
|
||||
*
|
||||
* @param array $power the class being built
|
||||
* @param array $code the class code being built
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function classBasicDiagram(array $power, array $code): string
|
||||
{
|
||||
// Set some global values
|
||||
$class_name = $power['name'];
|
||||
$class_type = $power['type'];
|
||||
|
||||
// set the class color
|
||||
$class_color = $this->getClassColor($class_type);
|
||||
|
||||
// set the class type label
|
||||
$type_label = $this->getClassTypeLable($class_type);
|
||||
|
||||
// set the class type tag
|
||||
$type_tag = $this->getClassTypeTag($class_type);
|
||||
|
||||
// Add class
|
||||
$plant_uml = "\n $type_label $class_name $type_tag #$class_color {\n";
|
||||
|
||||
// Add properties
|
||||
if (isset($code['properties']) && is_array($code['properties']))
|
||||
{
|
||||
$plant_uml .= $this->generatePropertiesPlantUML($code['properties'], ' ');
|
||||
}
|
||||
|
||||
// Add methods
|
||||
if (isset($code['methods']) && is_array($code['methods']))
|
||||
{
|
||||
$plant_uml .= $this->generateBasicMethodsPlantUML($code['methods']);
|
||||
}
|
||||
|
||||
$plant_uml .= " }\n";
|
||||
|
||||
return $plant_uml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a class detailed diagram of a class
|
||||
*
|
||||
* @param array $power the class being built
|
||||
* @param array $code the class code being built
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function classDetailedDiagram(array $power, array $code): string
|
||||
{
|
||||
// Set some global values
|
||||
$class_name = $power['name'];
|
||||
$class_type = $power['type'];
|
||||
|
||||
// set the class color
|
||||
$class_color = $this->getClassColor($class_type);
|
||||
|
||||
// set the class type label
|
||||
$type_label = $this->getClassTypeLable($class_type);
|
||||
|
||||
// set the class type tag
|
||||
$type_tag = $this->getClassTypeTag($class_type);
|
||||
|
||||
// Add class
|
||||
$plant_uml = "\n$type_label $class_name $type_tag #$class_color {\n";
|
||||
|
||||
// Add properties
|
||||
if (isset($code['properties']) && is_array($code['properties']))
|
||||
{
|
||||
$plant_uml .= $this->generatePropertiesPlantUML($code['properties'], ' ');
|
||||
}
|
||||
|
||||
// Add methods
|
||||
if (isset($code['methods']) && is_array($code['methods']))
|
||||
{
|
||||
list($methods_plant_uml, $notes) = $this->generateDetailedMethodsPlantUML($code['methods'], $class_name);
|
||||
$plant_uml .= $methods_plant_uml;
|
||||
}
|
||||
|
||||
$plant_uml .= "}\n";
|
||||
|
||||
if (!empty($notes))
|
||||
{
|
||||
$plant_uml .= $this->generateNotesPlantUML($notes);
|
||||
}
|
||||
|
||||
return $plant_uml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate properties PlantUML
|
||||
*
|
||||
* @param array $properties
|
||||
* @param string $space
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function generatePropertiesPlantUML(array $properties, string $space): string
|
||||
{
|
||||
$plant_uml = "";
|
||||
|
||||
foreach ($properties as $property)
|
||||
{
|
||||
$access_sign = $this->getAccessSign($property['access']);
|
||||
$static = $property['static'] ? '{static} ' : '';
|
||||
$type = $property['type'] ? $property['type'] . ' ' : '';
|
||||
$plant_uml .= "{$space}$access_sign $static{$type}{$property['name']}\n";
|
||||
}
|
||||
|
||||
return $plant_uml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate detailed methods PlantUML
|
||||
*
|
||||
* @param array $methods
|
||||
* @param string $class_name
|
||||
*
|
||||
* @return array
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function generateDetailedMethodsPlantUML(array $methods, string $class_name): array
|
||||
{
|
||||
$plant_uml = "";
|
||||
$notes = [];
|
||||
|
||||
foreach ($methods as $method)
|
||||
{
|
||||
$notes = $this->generateMethodNotes($method, $class_name, $notes);
|
||||
|
||||
$access_sign = $this->getAccessSign($method['access']);
|
||||
|
||||
$arguments = '';
|
||||
if ($method['arguments'])
|
||||
{
|
||||
$arguments = $this->generateMethodArgumentsAndNotes(
|
||||
$method['arguments'], $class_name, $method['name'], $notes);
|
||||
|
||||
$arguments = implode(', ', $arguments);
|
||||
}
|
||||
|
||||
$static = $method['static'] ? '{static} ' : '';
|
||||
$abstract = $method['abstract'] ? '{abstract} ' : '';
|
||||
$return_type = $method['return_type'] ? " : {$method['return_type']}" : '';
|
||||
|
||||
$plant_uml .= " $access_sign {$abstract}$static{$method['name']}({$arguments})$return_type\n";
|
||||
}
|
||||
|
||||
return [$plant_uml, $notes];
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate basic methods PlantUML
|
||||
*
|
||||
* @param array $properties
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function generateBasicMethodsPlantUML(array $methods): string
|
||||
{
|
||||
$plant_uml = "";
|
||||
|
||||
foreach ($methods as $method)
|
||||
{
|
||||
$access_sign = $this->getAccessSign($method['access']);
|
||||
$static = $method['static'] ? '{static} ' : '';
|
||||
$abstract = $method['abstract'] ? '{abstract} ' : '';
|
||||
$return_type = $method['return_type'] ? " : {$method['return_type']}" : '';
|
||||
$plant_uml .= " $access_sign {$abstract}$static{$method['name']}()$return_type\n";
|
||||
}
|
||||
|
||||
return $plant_uml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate method arguments and notes
|
||||
*
|
||||
* @param array $arguments
|
||||
* @param string $class_name
|
||||
* @param string $method_name
|
||||
* @param array $notes
|
||||
*
|
||||
* @return array
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function generateMethodArgumentsAndNotes(array $arguments, string $class_name,
|
||||
string $method_name, array &$notes): array
|
||||
{
|
||||
$formatted_arguments = [];
|
||||
$notes_bucket = [];
|
||||
$limit = 2;
|
||||
|
||||
foreach ($arguments as $name => $arg)
|
||||
{
|
||||
$arg_type = $arg['type'] ? "{$arg['type']} " : '';
|
||||
$arg_default = $arg['default'] ? " = {$arg['default']}" : '';
|
||||
$arg_statment = "{$arg_type}$name{$arg_default}";
|
||||
|
||||
if ($limit == 0)
|
||||
{
|
||||
$formatted_arguments[] = "...";
|
||||
$limit = -1;
|
||||
}
|
||||
elseif ($limit > 0)
|
||||
{
|
||||
$formatted_arguments[] = $arg_statment;
|
||||
$limit--;
|
||||
}
|
||||
|
||||
$notes_bucket[] = $arg_statment;
|
||||
}
|
||||
|
||||
if ($limit == -1)
|
||||
{
|
||||
$notes["{$class_name}::{$method_name}"][] = "\n arguments:\n " . implode("\n ", $notes_bucket);
|
||||
}
|
||||
|
||||
return $formatted_arguments;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate method notes
|
||||
*
|
||||
* @param array $method
|
||||
* @param string $class_name
|
||||
* @param array $notes
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
private function generateMethodNotes(array $method, string $class_name, array &$notes): array
|
||||
{
|
||||
$notes_key = "{$class_name}::{$method['name']}";
|
||||
|
||||
if (is_string($method['comment']) && strlen($method['comment']) > 4)
|
||||
{
|
||||
$notes[$notes_key][] = trim(preg_replace("/^@.*[\r\n]*/m", '', $method['comment'])) . "\n";
|
||||
}
|
||||
|
||||
if (is_string($method['since']) && strlen($method['since']) > 3)
|
||||
{
|
||||
$notes[$notes_key][] = "since: {$method['since']}";
|
||||
}
|
||||
|
||||
if (is_string($method['return_type']) && strlen($method['return_type']) > 1)
|
||||
{
|
||||
$notes[$notes_key][] = "return: {$method['return_type']}";
|
||||
}
|
||||
|
||||
if (is_string($method['deprecated']) && strlen($method['deprecated']) > 3)
|
||||
{
|
||||
$notes[$notes_key][] = "deprecated: {$method['deprecated']}";
|
||||
}
|
||||
|
||||
return $notes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate notes PlantUML
|
||||
*
|
||||
* @param array $notes
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function generateNotesPlantUML(array $notes): string
|
||||
{
|
||||
$plant_uml = "";
|
||||
$note_count = count($notes);
|
||||
|
||||
$positions = ['right', 'left'];
|
||||
$position_index = 0;
|
||||
|
||||
foreach ($notes as $area => $note)
|
||||
{
|
||||
if ($note_count <= 7)
|
||||
{
|
||||
$position = 'right';
|
||||
}
|
||||
else
|
||||
{
|
||||
$position = $positions[$position_index % 2];
|
||||
$position_index++;
|
||||
}
|
||||
|
||||
$plant_uml .= "\nnote $position of {$area}\n";
|
||||
$plant_uml .= " " . implode("\n ", $note) . "\n";
|
||||
$plant_uml .= "end note\n";
|
||||
}
|
||||
|
||||
return $plant_uml;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the access sign based on the access level.
|
||||
*
|
||||
* @param string $access The access level.
|
||||
*
|
||||
* @return string The corresponding access sign.
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function getAccessSign(string $access): string
|
||||
{
|
||||
switch ($access)
|
||||
{
|
||||
case 'private':
|
||||
return '-';
|
||||
case 'protected':
|
||||
return '#';
|
||||
case 'public':
|
||||
return '+';
|
||||
case 'var':
|
||||
return '+';
|
||||
default:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the correct class type.
|
||||
*
|
||||
* @param string $type The class type.
|
||||
*
|
||||
* @return string The correct class type label.
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function getClassTypeLable(string $type): string
|
||||
{
|
||||
$class_type_updater = [
|
||||
'final class' => 'class',
|
||||
'abstract class' => 'abstract',
|
||||
'trait' => 'class'
|
||||
];
|
||||
|
||||
return $class_type_updater[$type] ?? $type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the extra class type tag.
|
||||
*
|
||||
* @param string $type The class type.
|
||||
*
|
||||
* @return string The correct class type label.
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function getClassTypeTag(string $type): string
|
||||
{
|
||||
$class_type_updater = [
|
||||
'final class' => '<< (F,LightGreen) >>',
|
||||
'trait' => '<< (T,Orange) >>'
|
||||
];
|
||||
|
||||
return $class_type_updater[$type] ?? '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get class color based on class type.
|
||||
*
|
||||
* @param string $classType The class type.
|
||||
*
|
||||
* @return string The corresponding color.
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function getClassColor(string $classType): string
|
||||
{
|
||||
$class_colors = [
|
||||
'class' => 'Gold',
|
||||
'final class' => 'RoyalBlue',
|
||||
'abstract class' => 'Orange',
|
||||
'interface' => 'Lavender',
|
||||
'trait' => 'Turquoise'
|
||||
];
|
||||
|
||||
return $class_colors[$classType] ?? 'Green';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get namespace color based on namespace depth.
|
||||
*
|
||||
* @param int $namespaceDepth The depth of the namespace.
|
||||
*
|
||||
* @return string The corresponding color.
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function getNamespaceColor(int $namespaceDepth): string
|
||||
{
|
||||
$namespace_colors = [
|
||||
'lightgrey',
|
||||
'Azure',
|
||||
'DarkCyan',
|
||||
'Olive',
|
||||
'LightGreen',
|
||||
'DeepSkyBlue',
|
||||
'Wheat',
|
||||
'Coral',
|
||||
'Beige',
|
||||
'DeepPink',
|
||||
'DeepSkyBlue'
|
||||
];
|
||||
|
||||
return $namespace_colors[$namespaceDepth % count($namespace_colors)] ?? 'lightgrey';
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1 +0,0 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -1,353 +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\Repos;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Factory as Compiler;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Power;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Power\Plantuml;
|
||||
|
||||
|
||||
/**
|
||||
* Compiler Power Repos 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 Super Power Readme
|
||||
*
|
||||
* @param array $powers All powers of this super power.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public function get(array $powers): string
|
||||
{
|
||||
// build readme
|
||||
$readme = ["```
|
||||
███████╗██╗ ██╗██████╗ ███████╗██████╗
|
||||
██╔════╝██║ ██║██╔══██╗██╔════╝██╔══██╗
|
||||
███████╗██║ ██║██████╔╝█████╗ ██████╔╝
|
||||
╚════██║██║ ██║██╔═══╝ ██╔══╝ ██╔══██╗
|
||||
███████║╚██████╔╝██║ ███████╗██║ ██║
|
||||
╚══════╝ ╚═════╝ ╚═╝ ╚══════╝╚═╝ ╚═╝
|
||||
██████╗ ██████╗ ██╗ ██╗███████╗██████╗ ███████╗
|
||||
██╔══██╗██╔═══██╗██║ ██║██╔════╝██╔══██╗██╔════╝
|
||||
██████╔╝██║ ██║██║ █╗ ██║█████╗ ██████╔╝███████╗
|
||||
██╔═══╝ ██║ ██║██║███╗██║██╔══╝ ██╔══██╗╚════██║
|
||||
██║ ╚██████╔╝╚███╔███╔╝███████╗██║ ██║███████║
|
||||
╚═╝ ╚═════╝ ╚══╝╚══╝ ╚══════╝╚═╝ ╚═╝╚══════╝
|
||||
```"];
|
||||
|
||||
// default description of super powers
|
||||
$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);
|
||||
|
||||
// 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 &$powers): string
|
||||
{
|
||||
$classes = [];
|
||||
foreach ($powers as $guid => $power)
|
||||
{
|
||||
// add to the sort bucket
|
||||
$classes[] = [
|
||||
'namespace' => $power['namespace'],
|
||||
'type' => $power['type'],
|
||||
'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, $this->defineTypeOrder());
|
||||
|
||||
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 powers\n";
|
||||
$current_namespace = null;
|
||||
|
||||
foreach ($classes as $class)
|
||||
{
|
||||
if ($class['namespace'] !== $current_namespace)
|
||||
{
|
||||
$current_namespace = $class['namespace'];
|
||||
$result .= "\n- **Namespace**: [{$current_namespace}](#" .
|
||||
strtolower(str_replace('\\', '-', $current_namespace)) . ")\n";
|
||||
}
|
||||
|
||||
// Add the class details
|
||||
$result .= "\n - " . $class['link'];
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the order of types for sorting purposes
|
||||
*
|
||||
* @return array The order of types
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function defineTypeOrder(): array
|
||||
{
|
||||
return [
|
||||
'interface' => 1,
|
||||
'abstract' => 2,
|
||||
'abstract class' => 2,
|
||||
'final' => 3,
|
||||
'final class' => 3,
|
||||
'class' => 4,
|
||||
'trait' => 5
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Sort the flattened array using a single sorting function
|
||||
*
|
||||
* @param array $classes The classes to sort
|
||||
* @param array $typeOrder The order of types
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function sortClasses(array &$classes, array $typeOrder): void
|
||||
{
|
||||
usort($classes, function ($a, $b) use ($typeOrder) {
|
||||
$namespaceDiff = $this->compareNamespace($a, $b);
|
||||
|
||||
if ($namespaceDiff !== 0)
|
||||
{
|
||||
return $namespaceDiff;
|
||||
}
|
||||
|
||||
$typeDiff = $this->compareType($a, $b, $typeOrder);
|
||||
|
||||
if ($typeDiff !== 0)
|
||||
{
|
||||
return $typeDiff;
|
||||
}
|
||||
|
||||
return $this->compareName($a, $b);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare the namespace of two classes
|
||||
*
|
||||
* @param array $a First class
|
||||
* @param array $b Second class
|
||||
*
|
||||
* @return int Comparison result
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function compareNamespace(array $a, array $b): int
|
||||
{
|
||||
$namespaceDepthDiff = substr_count($a['namespace'], '\\') - substr_count($b['namespace'], '\\');
|
||||
|
||||
if ($namespaceDepthDiff === 0)
|
||||
{
|
||||
return strcmp($a['namespace'], $b['namespace']);
|
||||
}
|
||||
|
||||
return $namespaceDepthDiff;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compare the type of two classes
|
||||
*
|
||||
* @param array $a First class
|
||||
* @param array $b Second class
|
||||
* @param array $typeOrder The order of types
|
||||
*
|
||||
* @return int Comparison result
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function compareType(array $a, array $b, array $typeOrder): int
|
||||
{
|
||||
return $typeOrder[$a['type']] <=> $typeOrder[$b['type']];
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
$type = $power['type'] ?? 'error';
|
||||
$name = $power['name'] ?? 'error';
|
||||
return '**' . $type . ' ' . $name . "** | "
|
||||
. $this->linkPowerRepo($power) . ' | '
|
||||
. $this->linkPowerCode($power) . ' | '
|
||||
. $this->linkPowerSettings($power) . ' | '
|
||||
. $this->linkPowerSPK($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 linkPowerCode(array &$power): string
|
||||
{
|
||||
$code = $power['code'] ?? 'error';
|
||||
return '[Code](' . $code . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 SuperPowerKey (SPK)
|
||||
*
|
||||
* @param array $power The power details.
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
private function linkPowerSPK(array &$power): string
|
||||
{
|
||||
$spk = $power['spk'] ?? 'error';
|
||||
return $spk;
|
||||
}
|
||||
}
|
||||
|
@@ -1 +0,0 @@
|
||||
<html><body bgcolor="#FFFFFF"></body></html>
|
@@ -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();
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user