Adds phpseclib version 3.
This commit is contained in:
@@ -564,8 +564,8 @@ class Customcode implements CustomcodeInterface
|
||||
var_dump($this->placeholder->active);
|
||||
}
|
||||
$code['[CUSTOM' . 'CODE=' . $key . ']'] = $placeholder['start']
|
||||
. PHP_EOL . $this->placeholder->update(
|
||||
$item['code'], $this->placeholder->active
|
||||
. PHP_EOL . $this->placeholder->update_(
|
||||
$item['code']
|
||||
) . $placeholder['end'];
|
||||
}
|
||||
// always clear the args
|
||||
@@ -596,8 +596,8 @@ class Customcode implements CustomcodeInterface
|
||||
);
|
||||
$code['[CUSTOM' . 'CODE=' . $keyPlaceholder . ']']
|
||||
= $placeholder['start'] . PHP_EOL
|
||||
. $this->placeholder->update(
|
||||
$item['code'], $this->placeholder->active
|
||||
. $this->placeholder->update_(
|
||||
$item['code']
|
||||
) . $placeholder['end'];
|
||||
}
|
||||
}
|
||||
|
@@ -13,6 +13,10 @@ namespace VDM\Joomla\Componentbuilder\Compiler;
|
||||
|
||||
|
||||
use Joomla\DI\Container;
|
||||
use VDM\Joomla\Componentbuilder\Service\Crypt;
|
||||
use VDM\Joomla\Componentbuilder\Service\Server;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Service\Database;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Service\Model;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Service\Compiler;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Service\Event;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Service\History;
|
||||
@@ -104,7 +108,11 @@ abstract class Factory implements FactoryInterface
|
||||
*/
|
||||
protected static function createContainer(): Container
|
||||
{
|
||||
$container = (new Container())
|
||||
return (new Container())
|
||||
->registerServiceProvider(new Crypt())
|
||||
->registerServiceProvider(new Server())
|
||||
->registerServiceProvider(new Database())
|
||||
->registerServiceProvider(new Model())
|
||||
->registerServiceProvider(new Compiler())
|
||||
->registerServiceProvider(new Event())
|
||||
->registerServiceProvider(new History())
|
||||
@@ -115,8 +123,6 @@ abstract class Factory implements FactoryInterface
|
||||
->registerServiceProvider(new Component())
|
||||
->registerServiceProvider(new Extension())
|
||||
->registerServiceProvider(new Field());
|
||||
|
||||
return $container;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -246,13 +246,13 @@ class Data
|
||||
$field->initiator_on_save_model
|
||||
);
|
||||
$field->initiator_save = explode(
|
||||
PHP_EOL, $this->placeholder->update(
|
||||
$this->customcode->update(
|
||||
base64_decode(
|
||||
$field->initiator_on_save_model
|
||||
PHP_EOL, $this->placeholder->update_(
|
||||
$this->customcode->update(
|
||||
base64_decode(
|
||||
$field->initiator_on_save_model
|
||||
)
|
||||
)
|
||||
), $this->placeholder->active
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
if (StringHelper::check(
|
||||
@@ -263,29 +263,29 @@ class Data
|
||||
$field->initiator_on_get_model
|
||||
);
|
||||
$field->initiator_get = explode(
|
||||
PHP_EOL, $this->placeholder->update(
|
||||
$this->customcode->update(
|
||||
base64_decode(
|
||||
$field->initiator_on_get_model
|
||||
PHP_EOL, $this->placeholder->update_(
|
||||
$this->customcode->update(
|
||||
base64_decode(
|
||||
$field->initiator_on_get_model
|
||||
)
|
||||
)
|
||||
), $this->placeholder->active
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
// set the field modelling
|
||||
$field->model_field['save'] = explode(
|
||||
PHP_EOL, $this->placeholder->update(
|
||||
$this->customcode->update(
|
||||
base64_decode($field->on_save_model_field)
|
||||
), $this->placeholder->active
|
||||
)
|
||||
PHP_EOL, $this->placeholder->update_(
|
||||
$this->customcode->update(
|
||||
base64_decode($field->on_save_model_field)
|
||||
)
|
||||
)
|
||||
);
|
||||
$field->model_field['get'] = explode(
|
||||
PHP_EOL, $this->placeholder->update(
|
||||
$this->customcode->update(
|
||||
base64_decode($field->on_get_model_field)
|
||||
), $this->placeholder->active
|
||||
)
|
||||
PHP_EOL, $this->placeholder->update_(
|
||||
$this->customcode->update(
|
||||
base64_decode($field->on_get_model_field)
|
||||
)
|
||||
)
|
||||
);
|
||||
// remove the original values
|
||||
unset(
|
||||
|
@@ -133,8 +133,8 @@ class Name
|
||||
|| strpos($requeSt_id, '_request_catid') !== false)
|
||||
{
|
||||
// keep it then, don't change
|
||||
$name = $this->placeholder->update(
|
||||
$requeSt_id, $this->placeholder->active
|
||||
$name = $this->placeholder->update_(
|
||||
$requeSt_id
|
||||
);
|
||||
}
|
||||
else
|
||||
@@ -146,20 +146,20 @@ class Name
|
||||
if (StringHelper::check($listViewName))
|
||||
{
|
||||
// check if we should use another Text Name as this views name
|
||||
$otherName = $this->placeholder->update(
|
||||
$otherName = $this->placeholder->update_(
|
||||
GetHelper::between(
|
||||
$field['settings']->xml, 'othername="', '"'
|
||||
), $this->placeholder->active
|
||||
)
|
||||
);
|
||||
$otherViews = $this->placeholder->update(
|
||||
$otherViews = $this->placeholder->update_(
|
||||
GetHelper::between(
|
||||
$field['settings']->xml, 'views="', '"'
|
||||
), $this->placeholder->active
|
||||
)
|
||||
);
|
||||
$otherView = $this->placeholder->update(
|
||||
$otherView = $this->placeholder->update_(
|
||||
GetHelper::between(
|
||||
$field['settings']->xml, 'view="', '"'
|
||||
), $this->placeholder->active
|
||||
)
|
||||
);
|
||||
// This is to link other view category
|
||||
if (StringHelper::check($otherName)
|
||||
@@ -198,10 +198,10 @@ class Name
|
||||
{
|
||||
// get value from xml
|
||||
$xml = FieldHelper::safe(
|
||||
$this->placeholder->update(
|
||||
$this->placeholder->update_(
|
||||
GetHelper::between(
|
||||
$field['settings']->xml, 'name="', '"'
|
||||
), $this->placeholder->active
|
||||
)
|
||||
)
|
||||
);
|
||||
// check if a value was found
|
||||
|
@@ -130,12 +130,12 @@ class Validation
|
||||
// open and set the validation rule
|
||||
$this->registry->set("validation.rules.${validation_rule}",
|
||||
$this->gui->set(
|
||||
$this->placeholder->update(
|
||||
$this->placeholder->update_(
|
||||
$this->customcode->update(
|
||||
base64_decode(
|
||||
$php_code
|
||||
)
|
||||
), $this->placeholder->active
|
||||
)
|
||||
),
|
||||
array(
|
||||
'table' => 'validation_rule',
|
||||
|
@@ -117,7 +117,7 @@ class Extractor
|
||||
if (ArrayHelper::check($lang_string_targets))
|
||||
{
|
||||
// insure string is not broken
|
||||
$content = $this->placeholder->update($content, $this->placeholder->active);
|
||||
$content = $this->placeholder->update_($content);
|
||||
// reset some buckets
|
||||
$lang_holders = array();
|
||||
$lang_check = array();
|
||||
|
@@ -242,9 +242,8 @@ class Power implements PowerInterface
|
||||
$this->active[$guid]->key = $this->active[$guid]->id . '_' . $this->active[$guid]->target_type;
|
||||
|
||||
// now set the name
|
||||
$this->active[$guid]->name = $this->placeholder->update(
|
||||
$this->customcode->update($this->active[$guid]->name),
|
||||
$this->placeholder->active
|
||||
$this->active[$guid]->name = $this->placeholder->update_(
|
||||
$this->customcode->update($this->active[$guid]->name)
|
||||
);
|
||||
|
||||
// now set the code_name and class name
|
||||
@@ -295,12 +294,12 @@ class Power implements PowerInterface
|
||||
$guiMapper['field'] = 'licensing_template';
|
||||
// base64 Decode code
|
||||
$this->active[$guid]->licensing_template = $this->gui->set(
|
||||
$this->placeholder->update(
|
||||
$this->placeholder->update_(
|
||||
$this->customcode->update(
|
||||
base64_decode(
|
||||
$this->active[$guid]->licensing_template
|
||||
)
|
||||
), $this->placeholder->active
|
||||
)
|
||||
),
|
||||
$guiMapper
|
||||
);
|
||||
@@ -319,12 +318,12 @@ class Power implements PowerInterface
|
||||
|
||||
// base64 Decode code
|
||||
$this->active[$guid]->head = $this->gui->set(
|
||||
$this->placeholder->update(
|
||||
$this->placeholder->update_(
|
||||
$this->customcode->update(
|
||||
base64_decode(
|
||||
$this->active[$guid]->head
|
||||
)
|
||||
), $this->placeholder->active
|
||||
)
|
||||
),
|
||||
$guiMapper
|
||||
) . PHP_EOL;
|
||||
@@ -338,9 +337,8 @@ class Power implements PowerInterface
|
||||
$this->setComposer($guid);
|
||||
|
||||
// now set the description
|
||||
$this->active[$guid]->description = (StringHelper::check($this->active[$guid]->description)) ? $this->placeholder->update(
|
||||
$this->active[$guid]->description = (StringHelper::check($this->active[$guid]->description)) ? $this->placeholder->update_(
|
||||
$this->customcode->update($this->active[$guid]->description),
|
||||
$this->placeholder->active
|
||||
) : '';
|
||||
|
||||
// add the main code if set
|
||||
@@ -350,12 +348,12 @@ class Power implements PowerInterface
|
||||
$guiMapper['field'] = 'main_class_code';
|
||||
// base64 Decode code
|
||||
$this->active[$guid]->main_class_code = $this->gui->set(
|
||||
$this->placeholder->update(
|
||||
$this->placeholder->update_(
|
||||
$this->customcode->update(
|
||||
base64_decode(
|
||||
$this->active[$guid]->main_class_code
|
||||
)
|
||||
), $this->placeholder->active
|
||||
)
|
||||
),
|
||||
$guiMapper
|
||||
);
|
||||
@@ -399,8 +397,8 @@ class Power implements PowerInterface
|
||||
protected function setNamespace(string $guid)
|
||||
{
|
||||
// set namespace
|
||||
$this->active[$guid]->namespace = $this->placeholder->update(
|
||||
$this->active[$guid]->namespace, $this->placeholder->active
|
||||
$this->active[$guid]->namespace = $this->placeholder->update_(
|
||||
$this->active[$guid]->namespace
|
||||
);
|
||||
|
||||
// validate namespace
|
||||
@@ -614,8 +612,23 @@ class Power implements PowerInterface
|
||||
if (isset($_namespace['use']) && StringHelper::check($_namespace['use']) &&
|
||||
strpos($_namespace['use'], '\\') !== false)
|
||||
{
|
||||
// trim possible use or ; added to the namespace
|
||||
$namespace = $this->getCleanNamespace($_namespace['use']);
|
||||
// add the namespace to this access point
|
||||
$as = 'default';
|
||||
if (strpos($_namespace['use'], ' as ') !== false)
|
||||
{
|
||||
$namespace_as = explode(' as ', $_namespace['use']);
|
||||
// make sure the AS value is set
|
||||
if (count($namespace_as) == 2)
|
||||
{
|
||||
$as = trim(trim($namespace_as[1], ';'));
|
||||
}
|
||||
$namespace = $this->getCleanNamespace($namespace_as[0], false);
|
||||
}
|
||||
else
|
||||
{
|
||||
// trim possible use or ; added to the namespace
|
||||
$namespace = $this->getCleanNamespace($_namespace['use'], false);
|
||||
}
|
||||
|
||||
// check if still valid
|
||||
if (!StringHelper::check($namespace))
|
||||
@@ -624,13 +637,7 @@ class Power implements PowerInterface
|
||||
}
|
||||
|
||||
// add to the header of the class
|
||||
$this->addToHeader($guid, $this->getUseNamespace($namespace));
|
||||
|
||||
// add the namespace to this access point
|
||||
if (strpos($namespace, ' as ') !== false)
|
||||
{
|
||||
$namespace = $this->getCleanNamespace(explode(' as ', $namespace)[0]);
|
||||
}
|
||||
$this->addToHeader($guid, $this->getUseNamespace($namespace, $as));
|
||||
|
||||
// add composer namespaces for autoloader
|
||||
$this->composer[$namespace] = $composer['access_point'];
|
||||
@@ -669,9 +676,8 @@ class Power implements PowerInterface
|
||||
if ($implement == -1
|
||||
&& StringHelper::check($this->active[$guid]->implements_custom))
|
||||
{
|
||||
$this->active[$guid]->implement_names[] = $this->placeholder->update(
|
||||
$this->customcode->update($this->active[$guid]->implements_custom),
|
||||
$this->placeholder->active
|
||||
$this->active[$guid]->implement_names[] = $this->placeholder->update_(
|
||||
$this->customcode->update($this->active[$guid]->implements_custom)
|
||||
);
|
||||
// just add this once
|
||||
unset($this->active[$guid]->implements_custom);
|
||||
@@ -710,9 +716,8 @@ class Power implements PowerInterface
|
||||
if ($this->active[$guid]->extends == -1
|
||||
&& StringHelper::check($this->active[$guid]->extends_custom))
|
||||
{
|
||||
$this->active[$guid]->extends_name = $this->placeholder->update(
|
||||
$this->customcode->update($this->active[$guid]->extends_custom),
|
||||
$this->placeholder->active
|
||||
$this->active[$guid]->extends_name = $this->placeholder->update_(
|
||||
$this->customcode->update($this->active[$guid]->extends_custom)
|
||||
);
|
||||
// just add once
|
||||
unset($this->active[$guid]->extends_custom);
|
||||
@@ -771,15 +776,16 @@ class Power implements PowerInterface
|
||||
/**
|
||||
* Get Clean Namespace without use or ; as part of the name space
|
||||
*
|
||||
* @param string $namespace The actual name space
|
||||
* @param string $namespace The actual name space
|
||||
* @input bool $removeNumbers The switch to remove numers
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getCleanNamespace(string $namespace): string
|
||||
protected function getCleanNamespace(string $namespace, bool $removeNumbers = true): string
|
||||
{
|
||||
// trim possible (use) or (;) or (starting or ending \) added to the namespace
|
||||
return NamespaceHelper::safe(str_replace(['use ', ';'], '', $namespace));
|
||||
return NamespaceHelper::safe(str_replace(['use ', ';'], '', $namespace), $removeNumbers);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -90,34 +90,34 @@ class Autoloader
|
||||
$use_plugin = $this->content->exist('PLUGIN_POWER_AUTOLOADER');
|
||||
|
||||
// build the methods
|
||||
$autoloadNotSiteMethod = array();
|
||||
$autoloadMethod = array();
|
||||
$autoload_not_site_method = [];
|
||||
$autoload_method = [];
|
||||
|
||||
// add only if we are not using a plugin
|
||||
$tab_space = 2;
|
||||
if (!$use_plugin)
|
||||
{
|
||||
$autoloadNotSiteMethod[] = PHP_EOL . PHP_EOL;
|
||||
$autoload_not_site_method[] = PHP_EOL . PHP_EOL;
|
||||
$tab_space = 0;
|
||||
}
|
||||
elseif (!$loadSite)
|
||||
{
|
||||
// we add code to prevent this plugin from triggering on the site area
|
||||
$autoloadNotSiteMethod[] = PHP_EOL . Indent::_(2) . '//'
|
||||
$autoload_not_site_method[] = PHP_EOL . Indent::_(2) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' do not run the autoloader in the site area';
|
||||
$autoloadNotSiteMethod[] = Indent::_(2) . 'if ($this->app->isClient(\'site\'))';
|
||||
$autoloadNotSiteMethod[] = Indent::_(2) . '{';
|
||||
$autoloadNotSiteMethod[] = Indent::_(3) . 'return;';
|
||||
$autoloadNotSiteMethod[] = Indent::_(2) . '}' . PHP_EOL;
|
||||
$autoload_not_site_method[] = Indent::_(2) . 'if ($this->app->isClient(\'site\'))';
|
||||
$autoload_not_site_method[] = Indent::_(2) . '{';
|
||||
$autoload_not_site_method[] = Indent::_(3) . 'return;';
|
||||
$autoload_not_site_method[] = Indent::_(2) . '}' . PHP_EOL;
|
||||
}
|
||||
|
||||
// we start building the spl_autoload_register function call
|
||||
$autoloadMethod[] = Indent::_($tab_space) . '//'
|
||||
$autoload_method[] = Indent::_($tab_space) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' register this component namespace';
|
||||
$autoloadMethod[] = Indent::_($tab_space) . 'spl_autoload_register(function ($class) {';
|
||||
$autoloadMethod[] = Indent::_($tab_space) . Indent::_(1) . '//'
|
||||
$autoload_method[] = Indent::_($tab_space) . 'spl_autoload_register(function ($class) {';
|
||||
$autoload_method[] = Indent::_($tab_space) . Indent::_(1) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' project-specific base directories and namespace prefix';
|
||||
$autoloadMethod[] = Indent::_($tab_space) . Indent::_(1) . '$search = array(';
|
||||
$autoload_method[] = Indent::_($tab_space) . Indent::_(1) . '$search = [';
|
||||
|
||||
// ==== IMPORTANT NOTICE =====
|
||||
// make sure the name space values are sorted from the longest string to the shortest
|
||||
@@ -142,62 +142,73 @@ class Autoloader
|
||||
// don't add the ending comma on last value
|
||||
if ($size == $counter)
|
||||
{
|
||||
$autoloadMethod[] = Indent::_($tab_space) . Indent::_(2) . "'" . $this->config->get('jcb_powers_path', 'libraries/jcb_powers') . "/$base_dir' => '" . implode('\\\\', $prefix) . "'";
|
||||
$autoload_method[] = Indent::_($tab_space) . Indent::_(2) . "'" . $this->config->get('jcb_powers_path', 'libraries/jcb_powers') . "/$base_dir' => '" . implode('\\\\', $prefix) . "'";
|
||||
}
|
||||
else
|
||||
{
|
||||
$autoloadMethod[] = Indent::_($tab_space) . Indent::_(2) . "'" . $this->config->get('jcb_powers_path', 'libraries/jcb_powers') . "/$base_dir' => '" . implode('\\\\', $prefix) . "',";
|
||||
$autoload_method[] = Indent::_($tab_space) . Indent::_(2) . "'" . $this->config->get('jcb_powers_path', 'libraries/jcb_powers') . "/$base_dir' => '" . implode('\\\\', $prefix) . "',";
|
||||
}
|
||||
$counter++;
|
||||
}
|
||||
$autoloadMethod[] = Indent::_($tab_space) . Indent::_(1) . ');';
|
||||
$autoloadMethod[] = Indent::_($tab_space) . Indent::_(1) . '// Start the search and load if found';
|
||||
$autoloadMethod[] = Indent::_($tab_space) . Indent::_(1) . '$found = false;';
|
||||
$autoloadMethod[] = Indent::_($tab_space) . Indent::_(1) . '$found_base_dir = "";';
|
||||
$autoloadMethod[] = Indent::_($tab_space) . Indent::_(1) . '$found_len = 0;';
|
||||
$autoloadMethod[] = Indent::_($tab_space) . Indent::_(1) . 'foreach ($search as $base_dir => $prefix)';
|
||||
$autoloadMethod[] = Indent::_($tab_space) . Indent::_(1) . '{';
|
||||
$autoloadMethod[] = Indent::_($tab_space) . Indent::_(2) . '//'
|
||||
$autoload_method[] = Indent::_($tab_space) . Indent::_(1) . '];';
|
||||
$autoload_method[] = Indent::_($tab_space) . Indent::_(1) . '// Start the search and load if found';
|
||||
$autoload_method[] = Indent::_($tab_space) . Indent::_(1) . '$found = false;';
|
||||
$autoload_method[] = Indent::_($tab_space) . Indent::_(1) . '$found_base_dir = "";';
|
||||
$autoload_method[] = Indent::_($tab_space) . Indent::_(1) . '$found_len = 0;';
|
||||
$autoload_method[] = Indent::_($tab_space) . Indent::_(1) . 'foreach ($search as $base_dir => $prefix)';
|
||||
$autoload_method[] = Indent::_($tab_space) . Indent::_(1) . '{';
|
||||
$autoload_method[] = Indent::_($tab_space) . Indent::_(2) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' does the class use the namespace prefix?';
|
||||
$autoloadMethod[] = Indent::_($tab_space) . Indent::_(2) . '$len = strlen($prefix);';
|
||||
$autoloadMethod[] = Indent::_($tab_space) . Indent::_(2) . 'if (strncmp($prefix, $class, $len) === 0)';
|
||||
$autoloadMethod[] = Indent::_($tab_space) . Indent::_(2) . '{';
|
||||
$autoloadMethod[] = Indent::_($tab_space) . Indent::_(3) . '//'
|
||||
$autoload_method[] = Indent::_($tab_space) . Indent::_(2) . '$len = strlen($prefix);';
|
||||
$autoload_method[] = Indent::_($tab_space) . Indent::_(2) . 'if (strncmp($prefix, $class, $len) === 0)';
|
||||
$autoload_method[] = Indent::_($tab_space) . Indent::_(2) . '{';
|
||||
$autoload_method[] = Indent::_($tab_space) . Indent::_(3) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' we have a match so load the values';
|
||||
$autoloadMethod[] = Indent::_($tab_space) . Indent::_(3) . '$found = true;';
|
||||
$autoloadMethod[] = Indent::_($tab_space) . Indent::_(3) . '$found_base_dir = $base_dir;';
|
||||
$autoloadMethod[] = Indent::_($tab_space) . Indent::_(3) . '$found_len = $len;';
|
||||
$autoloadMethod[] = Indent::_($tab_space) . Indent::_(3) . '//'
|
||||
$autoload_method[] = Indent::_($tab_space) . Indent::_(3) . '$found = true;';
|
||||
$autoload_method[] = Indent::_($tab_space) . Indent::_(3) . '$found_base_dir = $base_dir;';
|
||||
$autoload_method[] = Indent::_($tab_space) . Indent::_(3) . '$found_len = $len;';
|
||||
$autoload_method[] = Indent::_($tab_space) . Indent::_(3) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' done here';
|
||||
$autoloadMethod[] = Indent::_($tab_space) . Indent::_(3) . 'break;';
|
||||
$autoloadMethod[] = Indent::_($tab_space) . Indent::_(2) . '}';
|
||||
$autoloadMethod[] = Indent::_($tab_space) . Indent::_(1) . '}';
|
||||
$autoloadMethod[] = Indent::_($tab_space) . Indent::_(1) . '//'
|
||||
$autoload_method[] = Indent::_($tab_space) . Indent::_(3) . 'break;';
|
||||
$autoload_method[] = Indent::_($tab_space) . Indent::_(2) . '}';
|
||||
$autoload_method[] = Indent::_($tab_space) . Indent::_(1) . '}';
|
||||
|
||||
$autoload_method[] = Indent::_($tab_space) . Indent::_(1) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' check if we found a match';
|
||||
$autoloadMethod[] = Indent::_($tab_space) . Indent::_(1) . 'if (!$found)';
|
||||
$autoloadMethod[] = Indent::_($tab_space) . Indent::_(1) . '{';
|
||||
$autoloadMethod[] = Indent::_($tab_space) . Indent::_(2) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' no, move to the next registered autoloader';
|
||||
$autoloadMethod[] = Indent::_($tab_space) . Indent::_(2) . 'return;';
|
||||
$autoloadMethod[] = Indent::_($tab_space) . Indent::_(1) . '}';
|
||||
$autoloadMethod[] = Indent::_($tab_space) . Indent::_(1) . '//'
|
||||
$autoload_method[] = Indent::_($tab_space) . Indent::_(1) . 'if (!$found)';
|
||||
$autoload_method[] = Indent::_($tab_space) . Indent::_(1) . '{';
|
||||
|
||||
$autoload_method[] = Indent::_($tab_space) . Indent::_(2) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' not found so move to the next registered autoloader';
|
||||
$autoload_method[] = Indent::_($tab_space) . Indent::_(2) . 'return;';
|
||||
|
||||
$autoload_method[] = Indent::_($tab_space) . Indent::_(1) . '}';
|
||||
|
||||
$autoload_method[] = Indent::_($tab_space) . Indent::_(1) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' get the relative class name';
|
||||
$autoloadMethod[] = Indent::_($tab_space) . Indent::_(1) . '$relative_class = substr($class, $found_len);';
|
||||
$autoloadMethod[] = Indent::_($tab_space) . Indent::_(1) . '//'
|
||||
$autoload_method[] = Indent::_($tab_space) . Indent::_(1) . '$relative_class = substr($class, $found_len);';
|
||||
$autoload_method[] = Indent::_($tab_space) . Indent::_(1) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' replace the namespace prefix with the base directory, replace namespace';
|
||||
$autoloadMethod[] = Indent::_($tab_space) . Indent::_(1) . '// separators with directory separators in the relative class name, append';
|
||||
$autoloadMethod[] = Indent::_($tab_space) . Indent::_(1) . '// with .php';
|
||||
$autoloadMethod[] = Indent::_($tab_space) . Indent::_(1) . "\$file = JPATH_ROOT . '/' . \$found_base_dir . '/src' . str_replace('\\\\', '/', \$relative_class) . '.php';";
|
||||
$autoloadMethod[] = Indent::_($tab_space) . Indent::_(1) . '//'
|
||||
$autoload_method[] = Indent::_($tab_space) . Indent::_(1) . '// separators with directory separators in the relative class name, append';
|
||||
$autoload_method[] = Indent::_($tab_space) . Indent::_(1) . '// with .php';
|
||||
$autoload_method[] = Indent::_($tab_space) . Indent::_(1) . "\$file = JPATH_ROOT . '/' . \$found_base_dir . '/src' . str_replace('\\\\', '/', \$relative_class) . '.php';";
|
||||
$autoload_method[] = Indent::_($tab_space) . Indent::_(1) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' if the file exists, require it';
|
||||
$autoloadMethod[] = Indent::_($tab_space) . Indent::_(1) . 'if (file_exists($file))';
|
||||
$autoloadMethod[] = Indent::_($tab_space) . Indent::_(1) . '{';
|
||||
$autoloadMethod[] = Indent::_($tab_space) . Indent::_(2) . 'require $file;';
|
||||
$autoloadMethod[] = Indent::_($tab_space) . Indent::_(1) . '}';
|
||||
$autoloadMethod[] = Indent::_($tab_space) . '});';
|
||||
$autoload_method[] = Indent::_($tab_space) . Indent::_(1) . 'if (file_exists($file))';
|
||||
$autoload_method[] = Indent::_($tab_space) . Indent::_(1) . '{';
|
||||
$autoload_method[] = Indent::_($tab_space) . Indent::_(2) . 'require $file;';
|
||||
$autoload_method[] = Indent::_($tab_space) . Indent::_(1) . '}';
|
||||
$autoload_method[] = Indent::_($tab_space) . '});';
|
||||
|
||||
// add the composer stuff here
|
||||
$autoload_composer = '';
|
||||
if (ArrayHelper::check($this->power->composer))
|
||||
{
|
||||
$autoload_composer = $this->getComposer($tab_space);
|
||||
}
|
||||
|
||||
// create the method string
|
||||
$autoloader = implode(PHP_EOL, $autoloadNotSiteMethod) . implode(PHP_EOL, $autoloadMethod);
|
||||
$autoloader = $autoload_composer . implode(PHP_EOL, $autoload_not_site_method) . implode(PHP_EOL, $autoload_method);
|
||||
|
||||
// check if we are using a plugin
|
||||
if ($use_plugin)
|
||||
@@ -216,9 +227,53 @@ class Autoloader
|
||||
}
|
||||
|
||||
// to add to custom files
|
||||
$this->content->add('CUSTOM_POWER_AUTOLOADER', PHP_EOL . implode(PHP_EOL, $autoloadMethod));
|
||||
$this->content->add('CUSTOM_POWER_AUTOLOADER', PHP_EOL . implode(PHP_EOL, $autoload_method));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the composer autoloader routine
|
||||
*
|
||||
* @param string $tabSpace The dynamic tab spacer
|
||||
*
|
||||
* @return string
|
||||
* @since 3.2.0
|
||||
*/
|
||||
protected function getComposer(string $tabSpace): string
|
||||
{
|
||||
// load the composer routine
|
||||
$composer_routine = [];
|
||||
|
||||
// counter to manage the comma in the actual array
|
||||
$add_once = [];
|
||||
foreach ($this->power->composer as $access_point)
|
||||
{
|
||||
// don't add the ending comma on last value
|
||||
if (empty($add_once[$access_point]))
|
||||
{
|
||||
$composer_routine[] = Indent::_($tabSpace) . "\$composer_autoloader = JPATH_LIBRARIES . '/$access_point';";
|
||||
$composer_routine[] = Indent::_($tabSpace) . 'if (file_exists($composer_autoloader))';
|
||||
$composer_routine[] = Indent::_($tabSpace) . "{";
|
||||
$composer_routine[] = Indent::_($tabSpace) . Indent::_(1) . 'require_once $composer_autoloader;';
|
||||
$composer_routine[] = Indent::_($tabSpace) . "}";
|
||||
|
||||
$add_once[$access_point] = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (count($add_once) == 1)
|
||||
{
|
||||
array_unshift($composer_routine, PHP_EOL . PHP_EOL . Indent::_($tabSpace) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' add the autoloader for the composer classes');
|
||||
}
|
||||
else
|
||||
{
|
||||
array_unshift($composer_routine, PHP_EOL . PHP_EOL . Indent::_($tabSpace) . '//'
|
||||
. Line::_(__Line__, __Class__) . ' add the autoloaders for the composer classes');
|
||||
}
|
||||
|
||||
return implode(PHP_EOL, $composer_routine);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user