forked from joomla/Component-Builder
Release of v3.2.3-alpha3
Fix database mySql update in J4+. Remove phpspreadsheet completely from Joomla 4+. Add option to use powers in preflight event in the installer class.
This commit is contained in:
parent
c55fc67db4
commit
51e786a197
13
CHANGELOG.md
13
CHANGELOG.md
@ -1,9 +1,8 @@
|
|||||||
# v3.2.3-alpha2
|
# v3.2.3-alpha3
|
||||||
|
|
||||||
- Fix missing scripts and styles fields and methods in the site admin view model
|
- Fix database mySql update in J4+
|
||||||
- Update subform field layout across JCB for cleaner look
|
- Remove phpspreadsheet completely from Joomla 4+
|
||||||
- Remove expansion feature
|
- Add option to use powers in preflight event in the installer class
|
||||||
- Fix helper area
|
|
||||||
|
|
||||||
# v3.2.3-alpha
|
# v3.2.3-alpha
|
||||||
|
|
||||||
@ -12,6 +11,10 @@
|
|||||||
- Fix site display controller checkEditId function in J4+
|
- Fix site display controller checkEditId function in J4+
|
||||||
- Add class methods to the HtmlView classes in J4+
|
- Add class methods to the HtmlView classes in J4+
|
||||||
- Fix broken toolbar call in HtmlView in J4+
|
- Fix broken toolbar call in HtmlView in J4+
|
||||||
|
- Fix missing scripts and styles fields and methods in the site admin view model
|
||||||
|
- Update subform field layout across JCB for cleaner look
|
||||||
|
- Remove expansion feature
|
||||||
|
- Fix helper area
|
||||||
|
|
||||||
# v3.2.2
|
# v3.2.2
|
||||||
|
|
||||||
|
10
README.md
10
README.md
@ -9,7 +9,7 @@ The Component Builder for [Joomla](https://extensions.joomla.org/extension/compo
|
|||||||
|
|
||||||
Whether you're a seasoned [Joomla](https://extensions.joomla.org/extension/component-builder/) developer, or have just started, Component Builder will save you lots of time and money. A real must have!
|
Whether you're a seasoned [Joomla](https://extensions.joomla.org/extension/component-builder/) developer, or have just started, Component Builder will save you lots of time and money. A real must have!
|
||||||
|
|
||||||
You can install it quite easily and with no limitations. On [gitea](https://git.vdm.dev/joomla/Component-Builder/tags) is the latest release (3.2.3-alpha2) with **ALL** its features and **ALL** concepts totally open-source and free!
|
You can install it quite easily and with no limitations. On [gitea](https://git.vdm.dev/joomla/Component-Builder/tags) is the latest release (3.2.3-alpha3) with **ALL** its features and **ALL** concepts totally open-source and free!
|
||||||
|
|
||||||
> Watch Quick Build of a Hello World component in [JCB on Youtube](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=45)
|
> Watch Quick Build of a Hello World component in [JCB on Youtube](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=45)
|
||||||
|
|
||||||
@ -144,13 +144,13 @@ TODO
|
|||||||
+ *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io)
|
+ *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io)
|
||||||
+ *Name*: [Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
+ *Name*: [Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||||
+ *First Build*: 30th April, 2015
|
+ *First Build*: 30th April, 2015
|
||||||
+ *Last Build*: 26th July, 2024
|
+ *Last Build*: 27th July, 2024
|
||||||
+ *Version*: 3.2.3-alpha2
|
+ *Version*: 3.2.3-alpha3
|
||||||
+ *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved.
|
+ *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||||
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
|
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
+ *Line count*: **798183**
|
+ *Line count*: **799922**
|
||||||
+ *Field count*: **2093**
|
+ *Field count*: **2093**
|
||||||
+ *File count*: **5491**
|
+ *File count*: **5507**
|
||||||
+ *Folder count*: **482**
|
+ *Folder count*: **482**
|
||||||
|
|
||||||
> This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](https://www.joomlacomponentbuilder.com).
|
> This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](https://www.joomlacomponentbuilder.com).
|
||||||
|
@ -9,7 +9,7 @@ The Component Builder for [Joomla](https://extensions.joomla.org/extension/compo
|
|||||||
|
|
||||||
Whether you're a seasoned [Joomla](https://extensions.joomla.org/extension/component-builder/) developer, or have just started, Component Builder will save you lots of time and money. A real must have!
|
Whether you're a seasoned [Joomla](https://extensions.joomla.org/extension/component-builder/) developer, or have just started, Component Builder will save you lots of time and money. A real must have!
|
||||||
|
|
||||||
You can install it quite easily and with no limitations. On [gitea](https://git.vdm.dev/joomla/Component-Builder/tags) is the latest release (3.2.3-alpha2) with **ALL** its features and **ALL** concepts totally open-source and free!
|
You can install it quite easily and with no limitations. On [gitea](https://git.vdm.dev/joomla/Component-Builder/tags) is the latest release (3.2.3-alpha3) with **ALL** its features and **ALL** concepts totally open-source and free!
|
||||||
|
|
||||||
> Watch Quick Build of a Hello World component in [JCB on Youtube](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=45)
|
> Watch Quick Build of a Hello World component in [JCB on Youtube](https://www.youtube.com/watch?v=IQfsLYIeblk&list=PLQRGFI8XZ_wtGvPQZWBfDzzlERLQgpMRE&index=45)
|
||||||
|
|
||||||
@ -144,13 +144,13 @@ TODO
|
|||||||
+ *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io)
|
+ *Author*: [Llewellyn van der Merwe](mailto:joomla@vdm.io)
|
||||||
+ *Name*: [Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
+ *Name*: [Component Builder](https://git.vdm.dev/joomla/Component-Builder)
|
||||||
+ *First Build*: 30th April, 2015
|
+ *First Build*: 30th April, 2015
|
||||||
+ *Last Build*: 26th July, 2024
|
+ *Last Build*: 27th July, 2024
|
||||||
+ *Version*: 3.2.3-alpha2
|
+ *Version*: 3.2.3-alpha3
|
||||||
+ *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved.
|
+ *Copyright*: Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||||
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
|
+ *License*: GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
+ *Line count*: **798183**
|
+ *Line count*: **799922**
|
||||||
+ *Field count*: **2093**
|
+ *Field count*: **2093**
|
||||||
+ *File count*: **5491**
|
+ *File count*: **5507**
|
||||||
+ *Folder count*: **482**
|
+ *Folder count*: **482**
|
||||||
|
|
||||||
> This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](https://www.joomlacomponentbuilder.com).
|
> This **component** was build with a [Joomla](https://extensions.joomla.org/extension/component-builder/) [Automated Component Builder](https://www.joomlacomponentbuilder.com).
|
||||||
|
@ -28,6 +28,8 @@ HTML::_('bootstrap.renderModal');
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Script File of ###Component### Component
|
* Script File of ###Component### Component
|
||||||
|
*
|
||||||
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
class Com_###Component###InstallerScript
|
class Com_###Component###InstallerScript
|
||||||
{
|
{
|
||||||
@ -35,6 +37,7 @@ class Com_###Component###InstallerScript
|
|||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param ComponentAdapter $parent The object responsible for running this script
|
* @param ComponentAdapter $parent The object responsible for running this script
|
||||||
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
public function __construct(ComponentAdapter $parent) {}
|
public function __construct(ComponentAdapter $parent) {}
|
||||||
|
|
||||||
@ -44,6 +47,7 @@ class Com_###Component###InstallerScript
|
|||||||
* @param ComponentAdapter $parent The object responsible for running this script
|
* @param ComponentAdapter $parent The object responsible for running this script
|
||||||
*
|
*
|
||||||
* @return boolean True on success
|
* @return boolean True on success
|
||||||
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
public function install(ComponentAdapter $parent) {}
|
public function install(ComponentAdapter $parent) {}
|
||||||
|
|
||||||
@ -51,6 +55,8 @@ class Com_###Component###InstallerScript
|
|||||||
* Called on uninstallation
|
* Called on uninstallation
|
||||||
*
|
*
|
||||||
* @param ComponentAdapter $parent The object responsible for running this script
|
* @param ComponentAdapter $parent The object responsible for running this script
|
||||||
|
*
|
||||||
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
public function uninstall(ComponentAdapter $parent)
|
public function uninstall(ComponentAdapter $parent)
|
||||||
{###UNINSTALLSCRIPT###
|
{###UNINSTALLSCRIPT###
|
||||||
@ -68,6 +74,7 @@ class Com_###Component###InstallerScript
|
|||||||
* @param ComponentAdapter $parent The object responsible for running this script
|
* @param ComponentAdapter $parent The object responsible for running this script
|
||||||
*
|
*
|
||||||
* @return boolean True on success
|
* @return boolean True on success
|
||||||
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
public function update(ComponentAdapter $parent){}
|
public function update(ComponentAdapter $parent){}
|
||||||
|
|
||||||
@ -78,6 +85,7 @@ class Com_###Component###InstallerScript
|
|||||||
* @param ComponentAdapter $parent The object responsible for running this script
|
* @param ComponentAdapter $parent The object responsible for running this script
|
||||||
*
|
*
|
||||||
* @return boolean True on success
|
* @return boolean True on success
|
||||||
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
public function preflight($type, ComponentAdapter $parent)
|
public function preflight($type, ComponentAdapter $parent)
|
||||||
{
|
{
|
||||||
@ -121,6 +129,7 @@ class Com_###Component###InstallerScript
|
|||||||
* @param ComponentAdapter $parent The object responsible for running this script
|
* @param ComponentAdapter $parent The object responsible for running this script
|
||||||
*
|
*
|
||||||
* @return boolean True on success
|
* @return boolean True on success
|
||||||
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
public function postflight($type, ComponentAdapter $parent)
|
public function postflight($type, ComponentAdapter $parent)
|
||||||
{
|
{
|
||||||
@ -251,16 +260,27 @@ class Com_###Component###InstallerScript
|
|||||||
*/
|
*/
|
||||||
protected function classExists(string $className): bool
|
protected function classExists(string $className): bool
|
||||||
{
|
{
|
||||||
if (!class_exists($className, true))
|
if (class_exists($className, true))
|
||||||
{
|
{
|
||||||
###THREE_POWER_AUTOLOADER###
|
|
||||||
|
|
||||||
// Check again if the class now exists after requiring the autoloader
|
|
||||||
if (!class_exists($className, true))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Autoloaders to check
|
||||||
|
$autoloaders = [###INSTALLER_POWER_AUTOLOADER_ARRAY###];
|
||||||
|
|
||||||
|
foreach ($autoloaders as $autoloader)
|
||||||
|
{
|
||||||
|
if (file_exists($autoloader))
|
||||||
|
{
|
||||||
|
require_once $autoloader;
|
||||||
|
|
||||||
|
if (class_exists($className, true))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}###INSTALLERMETHODS###
|
}###INSTALLERMETHODS###
|
||||||
}
|
}
|
||||||
|
18
admin/compiler/joomla_3/script_powerloader.php
Normal file
18
admin/compiler/joomla_3/script_powerloader.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 30th April, 2015
|
||||||
|
* @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
|
||||||
|
*/
|
||||||
|
|
||||||
|
// No direct access to this file
|
||||||
|
defined('_JEXEC') or die('Restricted access');
|
||||||
|
?>
|
||||||
|
###BOM###
|
||||||
|
|
||||||
|
// No direct access to this file
|
||||||
|
defined('_JEXEC') or die;###INSTALLER_POWER_HELPER###
|
@ -184,6 +184,12 @@
|
|||||||
"rename": false,
|
"rename": false,
|
||||||
"type": "file"
|
"type": "file"
|
||||||
},
|
},
|
||||||
|
"script_powerloader.php": {
|
||||||
|
"naam": "script_powerloader.php",
|
||||||
|
"path": "c0mp0n3nt/",
|
||||||
|
"rename": false,
|
||||||
|
"type": "file"
|
||||||
|
},
|
||||||
"install.mysql.utf8.sql": {
|
"install.mysql.utf8.sql": {
|
||||||
"naam": "install.mysql.utf8.sql",
|
"naam": "install.mysql.utf8.sql",
|
||||||
"path": "c0mp0n3nt/admin/sql",
|
"path": "c0mp0n3nt/admin/sql",
|
||||||
|
18
admin/compiler/joomla_4/INSTALLER_AUTOLOADER_CLASS.php
Normal file
18
admin/compiler/joomla_4/INSTALLER_AUTOLOADER_CLASS.php
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?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
|
||||||
|
*/
|
||||||
|
|
||||||
|
// No direct access to this JCB template file (EVER)
|
||||||
|
defined('_JCB_TEMPLATE') or die;
|
||||||
|
?>
|
||||||
|
###BOM###
|
||||||
|
|
||||||
|
// No direct access to this file
|
||||||
|
defined('_JEXEC') or die;###INSTALLER_POWER_HELPER###
|
@ -162,7 +162,6 @@ class Com_###Component###InstallerScript implements InstallerScriptInterface
|
|||||||
* @param InstallerAdapter $adapter The adapter calling this method
|
* @param InstallerAdapter $adapter The adapter calling this method
|
||||||
*
|
*
|
||||||
* @return boolean True on success
|
* @return boolean True on success
|
||||||
*
|
|
||||||
* @since 4.2.0
|
* @since 4.2.0
|
||||||
*/
|
*/
|
||||||
public function install(InstallerAdapter $adapter): bool {return true;}
|
public function install(InstallerAdapter $adapter): bool {return true;}
|
||||||
@ -184,7 +183,6 @@ class Com_###Component###InstallerScript implements InstallerScriptInterface
|
|||||||
* @param InstallerAdapter $adapter The adapter calling this method
|
* @param InstallerAdapter $adapter The adapter calling this method
|
||||||
*
|
*
|
||||||
* @return boolean True on success
|
* @return boolean True on success
|
||||||
*
|
|
||||||
* @since 4.2.0
|
* @since 4.2.0
|
||||||
*/
|
*/
|
||||||
public function uninstall(InstallerAdapter $adapter): bool
|
public function uninstall(InstallerAdapter $adapter): bool
|
||||||
@ -207,7 +205,6 @@ class Com_###Component###InstallerScript implements InstallerScriptInterface
|
|||||||
* @param InstallerAdapter $adapter The adapter calling this method
|
* @param InstallerAdapter $adapter The adapter calling this method
|
||||||
*
|
*
|
||||||
* @return boolean True on success
|
* @return boolean True on success
|
||||||
*
|
|
||||||
* @since 4.2.0
|
* @since 4.2.0
|
||||||
*/
|
*/
|
||||||
public function preflight(string $type, InstallerAdapter $adapter): bool
|
public function preflight(string $type, InstallerAdapter $adapter): bool
|
||||||
@ -252,7 +249,6 @@ class Com_###Component###InstallerScript implements InstallerScriptInterface
|
|||||||
* @param InstallerAdapter $adapter The adapter calling this method
|
* @param InstallerAdapter $adapter The adapter calling this method
|
||||||
*
|
*
|
||||||
* @return boolean True on success
|
* @return boolean True on success
|
||||||
*
|
|
||||||
* @since 4.2.0
|
* @since 4.2.0
|
||||||
*/
|
*/
|
||||||
public function postflight(string $type, InstallerAdapter $adapter): bool
|
public function postflight(string $type, InstallerAdapter $adapter): bool
|
||||||
@ -355,7 +351,6 @@ class Com_###Component###InstallerScript implements InstallerScriptInterface
|
|||||||
* Remove the files and folders in the given array from
|
* Remove the files and folders in the given array from
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*
|
|
||||||
* @since 3.6
|
* @since 3.6
|
||||||
*/
|
*/
|
||||||
protected function removeFiles()
|
protected function removeFiles()
|
||||||
@ -387,7 +382,6 @@ class Com_###Component###InstallerScript implements InstallerScriptInterface
|
|||||||
* Moves the CLI scripts into the CLI folder in the CMS
|
* Moves the CLI scripts into the CLI folder in the CMS
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*
|
|
||||||
* @since 3.6
|
* @since 3.6
|
||||||
*/
|
*/
|
||||||
protected function moveCliFiles()
|
protected function moveCliFiles()
|
||||||
@ -1180,16 +1174,27 @@ class Com_###Component###InstallerScript implements InstallerScriptInterface
|
|||||||
*/
|
*/
|
||||||
protected function classExists(string $className): bool
|
protected function classExists(string $className): bool
|
||||||
{
|
{
|
||||||
if (!class_exists($className, true))
|
if (class_exists($className, true))
|
||||||
{
|
{
|
||||||
###THREE_POWER_AUTOLOADER###
|
|
||||||
|
|
||||||
// Check again if the class now exists after requiring the autoloader
|
|
||||||
if (!class_exists($className, true))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Autoloaders to check
|
||||||
|
$autoloaders = [###INSTALLER_POWER_AUTOLOADER_ARRAY###];
|
||||||
|
|
||||||
|
foreach ($autoloaders as $autoloader)
|
||||||
|
{
|
||||||
|
if (file_exists($autoloader))
|
||||||
|
{
|
||||||
|
require_once $autoloader;
|
||||||
|
|
||||||
|
if (class_exists($className, true))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}###INSTALLERMETHODS###
|
}###INSTALLERMETHODS###
|
||||||
}
|
}
|
||||||
|
@ -182,6 +182,13 @@
|
|||||||
"newName": "[[[Component]]]InstallerScript.php",
|
"newName": "[[[Component]]]InstallerScript.php",
|
||||||
"type": "file"
|
"type": "file"
|
||||||
},
|
},
|
||||||
|
"INSTALLER_AUTOLOADER_CLASS.php": {
|
||||||
|
"naam": "INSTALLER_AUTOLOADER_CLASS.php",
|
||||||
|
"path": "c0mp0n3nt/",
|
||||||
|
"rename": "new",
|
||||||
|
"newName": "[[[Component]]]InstallerPowerloader.php",
|
||||||
|
"type": "file"
|
||||||
|
},
|
||||||
"SITE_DISPATCHER.php": {
|
"SITE_DISPATCHER.php": {
|
||||||
"naam": "SITE_DISPATCHER.php",
|
"naam": "SITE_DISPATCHER.php",
|
||||||
"path": "c0mp0n3nt/site/src/Dispatcher",
|
"path": "c0mp0n3nt/site/src/Dispatcher",
|
||||||
|
File diff suppressed because one or more lines are too long
@ -1,15 +1,15 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<extension type="component" version="3.10" method="upgrade">
|
<extension type="component" version="3.10" method="upgrade">
|
||||||
<name>COM_COMPONENTBUILDER</name>
|
<name>COM_COMPONENTBUILDER</name>
|
||||||
<creationDate>26th July, 2024</creationDate>
|
<creationDate>27th July, 2024</creationDate>
|
||||||
<author>Llewellyn van der Merwe</author>
|
<author>Llewellyn van der Merwe</author>
|
||||||
<authorEmail>joomla@vdm.io</authorEmail>
|
<authorEmail>joomla@vdm.io</authorEmail>
|
||||||
<authorUrl>https://dev.vdm.io</authorUrl>
|
<authorUrl>https://dev.vdm.io</authorUrl>
|
||||||
<copyright>Copyright (C) 2015 Vast Development Method. All rights reserved.</copyright>
|
<copyright>Copyright (C) 2015 Vast Development Method. All rights reserved.</copyright>
|
||||||
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
|
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
|
||||||
<version>3.2.3-alpha2</version>
|
<version>3.2.3-alpha3</version>
|
||||||
<description><![CDATA[
|
<description><![CDATA[
|
||||||
<h1>Component Builder (v.3.2.3-alpha2)</h1>
|
<h1>Component Builder (v.3.2.3-alpha3)</h1>
|
||||||
<div style="clear: both;"></div>
|
<div style="clear: both;"></div>
|
||||||
<p>The Component Builder for [Joomla](https://extensions.joomla.org/extension/component-builder/) is highly advanced tool that is truly able to build extremely complex components in a fraction of the time.
|
<p>The Component Builder for [Joomla](https://extensions.joomla.org/extension/component-builder/) is highly advanced tool that is truly able to build extremely complex components in a fraction of the time.
|
||||||
|
|
||||||
|
@ -169,7 +169,7 @@
|
|||||||
<version>3.2.3-alpha</version>
|
<version>3.2.3-alpha</version>
|
||||||
<infourl title="Component Builder!">https://dev.vdm.io</infourl>
|
<infourl title="Component Builder!">https://dev.vdm.io</infourl>
|
||||||
<downloads>
|
<downloads>
|
||||||
<downloadurl type="full" format="zip">https://git.vdm.dev/api/v1/repos/joomla/pkg-component-builder/archive/v3.2.3-alpha2.zip</downloadurl>
|
<downloadurl type="full" format="zip">https://git.vdm.dev/api/v1/repos/joomla/pkg-component-builder/archive/v3.2.3-alpha3.zip</downloadurl>
|
||||||
</downloads>
|
</downloads>
|
||||||
<tags>
|
<tags>
|
||||||
<tag>alpha</tag>
|
<tag>alpha</tag>
|
||||||
@ -184,10 +184,10 @@
|
|||||||
<element>pkg_component_builder</element>
|
<element>pkg_component_builder</element>
|
||||||
<type>package</type>
|
<type>package</type>
|
||||||
<client>site</client>
|
<client>site</client>
|
||||||
<version>3.2.3-alpha2</version>
|
<version>3.2.3-alpha3</version>
|
||||||
<infourl title="Component Builder!">https://dev.vdm.io</infourl>
|
<infourl title="Component Builder!">https://dev.vdm.io</infourl>
|
||||||
<downloads>
|
<downloads>
|
||||||
<downloadurl type="full" format="zip">https://git.vdm.dev/api/v1/repos/joomla/pkg-component-builder/archive/v3.2.3-alpha2.zip</downloadurl>
|
<downloadurl type="full" format="zip">https://git.vdm.dev/api/v1/repos/joomla/pkg-component-builder/archive/v3.2.3-alpha3.zip</downloadurl>
|
||||||
</downloads>
|
</downloads>
|
||||||
<tags>
|
<tags>
|
||||||
<tag>alpha</tag>
|
<tag>alpha</tag>
|
||||||
|
@ -0,0 +1,214 @@
|
|||||||
|
<?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\Abstraction;
|
||||||
|
|
||||||
|
|
||||||
|
use Joomla\CMS\Factory;
|
||||||
|
use VDM\Joomla\Interfaces\PHPConfigurationCheckerInterface;
|
||||||
|
use VDM\Joomla\Abstraction\Registry;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PHP Configuration Checker
|
||||||
|
*
|
||||||
|
* @since 5.0.2
|
||||||
|
*/
|
||||||
|
abstract class PHPConfigurationChecker extends Registry implements PHPConfigurationCheckerInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The upload max filesize value
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 5.0.2
|
||||||
|
**/
|
||||||
|
protected string $upload_max_filesize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The post max size value
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 5.0.2
|
||||||
|
**/
|
||||||
|
protected string $post_max_size;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The max execution time value
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
* @since 5.0.2
|
||||||
|
**/
|
||||||
|
protected int $max_execution_time;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The max input vars value
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
* @since 5.0.2
|
||||||
|
**/
|
||||||
|
protected int $max_input_vars;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The max input time value
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
* @since 5.0.2
|
||||||
|
**/
|
||||||
|
protected int $max_input_time;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The memory limit value
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 5.0.2
|
||||||
|
**/
|
||||||
|
protected string $memory_limit;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The registry array.
|
||||||
|
*
|
||||||
|
* @var array
|
||||||
|
* @since 5.0.2
|
||||||
|
**/
|
||||||
|
protected array $active = [
|
||||||
|
'php' => [
|
||||||
|
'upload_max_filesize' => [
|
||||||
|
'success' => 'The upload_max_filesize is appropriately set to handle large files, which is essential for uploading substantial components and media.',
|
||||||
|
'warning' => 'The current upload_max_filesize may not support large file uploads effectively, potentially causing failures during component installation.'
|
||||||
|
],
|
||||||
|
'post_max_size' => [
|
||||||
|
'success' => 'The post_max_size setting is sufficient to manage large data submissions, ensuring smooth data processing within forms and uploads.',
|
||||||
|
'warning' => 'An insufficient post_max_size can lead to truncated data submissions, affecting form functionality and data integrity.'
|
||||||
|
],
|
||||||
|
'max_execution_time' => [
|
||||||
|
'success' => 'Max execution time is set high enough to execute complex operations without premature termination, which is crucial for lengthy operations.',
|
||||||
|
'warning' => 'A low max execution time could lead to script timeouts, especially during intensive operations, which might interrupt execution and cause failures during the compiling of a large extension.'
|
||||||
|
],
|
||||||
|
'max_input_vars' => [
|
||||||
|
'success' => 'The max_input_vars setting supports a high number of input variables, facilitating complex forms and detailed component configurations.',
|
||||||
|
'warning' => 'Too few max_input_vars may result in lost data during processing complex forms, which can lead to incomplete configurations and operational issues.'
|
||||||
|
],
|
||||||
|
'max_input_time' => [
|
||||||
|
'success' => 'Max input time is adequate for processing inputs efficiently during high-load operations, ensuring no premature timeouts.',
|
||||||
|
'warning' => 'An insufficient max input time could result in incomplete data processing during input-heavy operations, potentially leading to errors and data loss.'
|
||||||
|
],
|
||||||
|
'memory_limit' => [
|
||||||
|
'success' => 'The memory limit is set high to accommodate extensive operations and data processing, which enhances overall performance and stability.',
|
||||||
|
'warning' => 'A low memory limit can lead to frequent crashes and performance issues, particularly when processing large amounts of data or complex calculations.'
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'environment' => [
|
||||||
|
'name' => 'extension environment',
|
||||||
|
'objective' => 'These settings are crucial for ensuring the successful installation and stable functionality of the extension.',
|
||||||
|
'wiki_name' => 'PHP Settings Wiki',
|
||||||
|
'wiki_url' => '#'
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Application object.
|
||||||
|
*
|
||||||
|
* @since 5.0.2
|
||||||
|
**/
|
||||||
|
protected $app;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @param $app The app object.
|
||||||
|
*
|
||||||
|
* @since 5.0.2
|
||||||
|
*/
|
||||||
|
public function __construct($app = null)
|
||||||
|
{
|
||||||
|
$this->app = $app ?: Factory::getApplication();
|
||||||
|
|
||||||
|
// set the required PHP Configures
|
||||||
|
$this->set('php.upload_max_filesize.value', $this->upload_max_filesize);
|
||||||
|
$this->set('php.post_max_size.value', $this->post_max_size);
|
||||||
|
$this->set('php.max_execution_time.value', $this->max_execution_time);
|
||||||
|
$this->set('php.max_input_vars.value', $this->max_input_vars);
|
||||||
|
$this->set('php.max_input_time.value', $this->max_input_time);
|
||||||
|
$this->set('php.memory_limit.value', $this->memory_limit);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check that the required configurations are set for PHP
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 5.0.2
|
||||||
|
**/
|
||||||
|
public function run(): void
|
||||||
|
{
|
||||||
|
$showHelp = false;
|
||||||
|
|
||||||
|
// Check each configuration and provide detailed feedback
|
||||||
|
$configurations = $this->active['php'] ?? [];
|
||||||
|
foreach ($configurations as $configName => $configDetails)
|
||||||
|
{
|
||||||
|
$currentValue = ini_get($configName);
|
||||||
|
if ($currentValue === false)
|
||||||
|
{
|
||||||
|
$this->app->enqueueMessage("Error: Unable to retrieve current setting for '{$configName}'.", 'error');
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$requiredValue = $configDetails['value'] ?? 0;
|
||||||
|
$isMemoryValue = strpbrk($requiredValue, 'KMG') !== false;
|
||||||
|
|
||||||
|
$requiredValueBytes = $isMemoryValue ? $this->convertToBytes($requiredValue) : (int) $requiredValue;
|
||||||
|
$currentValueBytes = $isMemoryValue ? $this->convertToBytes($currentValue) : (int) $currentValue;
|
||||||
|
$conditionMet = $currentValueBytes >= $requiredValueBytes;
|
||||||
|
|
||||||
|
$messageType = $conditionMet ? 'message' : 'warning';
|
||||||
|
$messageText = $conditionMet ?
|
||||||
|
"Success: {$configName} is set to {$currentValue}. " . $configDetails['success'] ?? '':
|
||||||
|
"Warning: {$configName} configuration should be at least {$requiredValue} but is currently {$currentValue}. " . $configDetails['warning'] ?? '';
|
||||||
|
|
||||||
|
$showHelp = ($showHelp || $messageType === 'warning') ? true : false;
|
||||||
|
|
||||||
|
$this->app->enqueueMessage($messageText, $messageType);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($showHelp)
|
||||||
|
{
|
||||||
|
$this->app->enqueueMessage("To optimize your {$this->get('environment.name', 'extension')}, specific PHP settings must be enhanced.<br>{$this->get('environment.objective', '')}<br>We've identified that certain configurations currently do not meet the recommended standards.<br>To adjust these settings and prevent potential issues, please consult our detailed guide available at <a href=\"https://{$this->get('environment.wiki_url', '#')}\" target=\"_blank\">{$this->get('environment.wiki_name', 'PHP Settings Wiki')}</a>.", 'notice');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function to convert PHP INI memory values to bytes
|
||||||
|
*
|
||||||
|
* @param string $value The value to convert
|
||||||
|
*
|
||||||
|
* @return int The bytes value
|
||||||
|
* @since 5.0.2
|
||||||
|
*/
|
||||||
|
protected function convertToBytes(string $value): int
|
||||||
|
{
|
||||||
|
$value = trim($value);
|
||||||
|
$lastChar = strtolower($value[strlen($value) - 1]);
|
||||||
|
$numValue = substr($value, 0, -1);
|
||||||
|
|
||||||
|
switch ($lastChar)
|
||||||
|
{
|
||||||
|
case 'g':
|
||||||
|
return $numValue * 1024 * 1024 * 1024;
|
||||||
|
case 'm':
|
||||||
|
return $numValue * 1024 * 1024;
|
||||||
|
case 'k':
|
||||||
|
return $numValue * 1024;
|
||||||
|
default:
|
||||||
|
return (int) $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -351,7 +351,7 @@ final class Settings implements SettingsInterface
|
|||||||
$this->config->get('footable', false))
|
$this->config->get('footable', false))
|
||||||
{
|
{
|
||||||
$this->addImportViewFolder();
|
$this->addImportViewFolder();
|
||||||
$this->addPhpSpreadsheetFolder();
|
// $this->addPhpSpreadsheetFolder(); // soon
|
||||||
$this->addUikitFolder();
|
$this->addUikitFolder();
|
||||||
$this->addFooTableFolder();
|
$this->addFooTableFolder();
|
||||||
}
|
}
|
||||||
|
@ -351,7 +351,7 @@ final class Settings implements SettingsInterface
|
|||||||
$this->config->get('footable', false))
|
$this->config->get('footable', false))
|
||||||
{
|
{
|
||||||
$this->addImportViewFolder();
|
$this->addImportViewFolder();
|
||||||
$this->addPhpSpreadsheetFolder();
|
// $this->addPhpSpreadsheetFolder(); // soon
|
||||||
$this->addUikitFolder();
|
$this->addUikitFolder();
|
||||||
$this->addFooTableFolder();
|
$this->addFooTableFolder();
|
||||||
}
|
}
|
||||||
|
@ -303,6 +303,24 @@ class Config extends BaseConfig
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get component installer autoloader path
|
||||||
|
*
|
||||||
|
* @return string The component installer autoloader path
|
||||||
|
* @since 5.0.2
|
||||||
|
*/
|
||||||
|
protected function getComponentinstallerautoloaderpath(): string
|
||||||
|
{
|
||||||
|
if ($this->joomla_version == 3)
|
||||||
|
{
|
||||||
|
return 'script_powerloader.php';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return ucfirst($this->component_codename) . 'InstallerPowerloader.php';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get add namespace prefix
|
* get add namespace prefix
|
||||||
*
|
*
|
||||||
|
@ -1160,8 +1160,7 @@ class Interpretation extends Fields
|
|||||||
$newJ['component_version']
|
$newJ['component_version']
|
||||||
= CFactory::_('Component')->get('component_version');
|
= CFactory::_('Component')->get('component_version');
|
||||||
// update the component with the new dynamic SQL
|
// update the component with the new dynamic SQL
|
||||||
$modelJ = \ComponentbuilderHelper::getModel('joomla_component');
|
CFactory::_('Data.Item')->table('joomla_component')->set((object) $newJ, 'id'); // <-- to insure the history is also updated
|
||||||
$modelJ->save($newJ); // <-- to insure the history is also updated
|
|
||||||
// reset the watch here
|
// reset the watch here
|
||||||
CFactory::_('History')->get('joomla_component', CFactory::_('Config')->component_id);
|
CFactory::_('History')->get('joomla_component', CFactory::_('Config')->component_id);
|
||||||
|
|
||||||
@ -1175,10 +1174,9 @@ class Interpretation extends Fields
|
|||||||
{
|
{
|
||||||
$newU['joomla_component'] = (int) CFactory::_('Config')->component_id;
|
$newU['joomla_component'] = (int) CFactory::_('Config')->component_id;
|
||||||
}
|
}
|
||||||
$newU['version_update'] = json_encode($buket);
|
$newU['version_update'] = $buket;
|
||||||
// update the component with the new dynamic SQL
|
// update the component with the new dynamic SQL
|
||||||
$modelU = \ComponentbuilderHelper::getModel('component_updates');
|
CFactory::_('Data.Item')->table('component_updates')->set((object) $newU, 'id'); // <-- to insure the history is also updated
|
||||||
$modelU->save($newU); // <-- to insure the history is also updated
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,11 +228,6 @@ final class Header implements HeaderInterface
|
|||||||
// get dynamic headers
|
// get dynamic headers
|
||||||
switch ($context)
|
switch ($context)
|
||||||
{
|
{
|
||||||
case 'admin.helper':
|
|
||||||
case 'site.helper':
|
|
||||||
$this->setHelperClassHeader($headers, $codeName);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'admin.view.html':
|
case 'admin.view.html':
|
||||||
case 'admin.views.html':
|
case 'admin.views.html':
|
||||||
case 'custom.admin.view.html':
|
case 'custom.admin.view.html':
|
||||||
@ -561,25 +556,5 @@ final class Header implements HeaderInterface
|
|||||||
|
|
||||||
return $headers;
|
return $headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* set Helper Dynamic Headers
|
|
||||||
*
|
|
||||||
* @param array $headers The headers array
|
|
||||||
* @param string $target_client
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
* @since 3.2.0
|
|
||||||
*/
|
|
||||||
protected function setHelperClassHeader(&$headers, $target_client)
|
|
||||||
{
|
|
||||||
// add only to admin client
|
|
||||||
if ('admin' === $target_client && $this->config->get('add_eximport', false))
|
|
||||||
{
|
|
||||||
$headers[] = 'use PhpOffice\PhpSpreadsheet\IOFactory;';
|
|
||||||
$headers[] = 'use PhpOffice\PhpSpreadsheet\Spreadsheet;';
|
|
||||||
$headers[] = 'use PhpOffice\PhpSpreadsheet\Writer\Xlsx;';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -228,11 +228,6 @@ final class Header implements HeaderInterface
|
|||||||
// get dynamic headers
|
// get dynamic headers
|
||||||
switch ($context)
|
switch ($context)
|
||||||
{
|
{
|
||||||
case 'admin.helper':
|
|
||||||
case 'site.helper':
|
|
||||||
$this->setHelperClassHeader($headers, $codeName);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 'admin.view.html':
|
case 'admin.view.html':
|
||||||
case 'admin.views.html':
|
case 'admin.views.html':
|
||||||
case 'custom.admin.view.html':
|
case 'custom.admin.view.html':
|
||||||
@ -561,25 +556,5 @@ final class Header implements HeaderInterface
|
|||||||
|
|
||||||
return $headers;
|
return $headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* set Helper Dynamic Headers
|
|
||||||
*
|
|
||||||
* @param array $headers The headers array
|
|
||||||
* @param string $target_client
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
* @since 3.2.0
|
|
||||||
*/
|
|
||||||
protected function setHelperClassHeader(&$headers, $target_client)
|
|
||||||
{
|
|
||||||
// add only to admin client
|
|
||||||
if ('admin' === $target_client && $this->config->get('add_eximport', false))
|
|
||||||
{
|
|
||||||
$headers[] = 'use PhpOffice\PhpSpreadsheet\IOFactory;';
|
|
||||||
$headers[] = 'use PhpOffice\PhpSpreadsheet\Spreadsheet;';
|
|
||||||
$headers[] = 'use PhpOffice\PhpSpreadsheet\Writer\Xlsx;';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,6 +51,14 @@ class Autoloader
|
|||||||
*/
|
*/
|
||||||
protected Content $content;
|
protected Content $content;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Installer Class Autoloader
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 5.0.2
|
||||||
|
**/
|
||||||
|
protected string $installerhelper = '';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper Class Autoloader
|
* Helper Class Autoloader
|
||||||
*
|
*
|
||||||
@ -77,6 +85,7 @@ class Autoloader
|
|||||||
// reset all autoloaders power placeholders
|
// reset all autoloaders power placeholders
|
||||||
$this->content->set('ADMIN_POWER_HELPER', '');
|
$this->content->set('ADMIN_POWER_HELPER', '');
|
||||||
$this->content->set('SITE_POWER_HELPER', '');
|
$this->content->set('SITE_POWER_HELPER', '');
|
||||||
|
$this->content->set('INSTALLER_POWER_HELPER', '');
|
||||||
$this->content->set('PLUGIN_POWER_AUTOLOADER', '');
|
$this->content->set('PLUGIN_POWER_AUTOLOADER', '');
|
||||||
$this->content->set('SITE_PLUGIN_POWER_AUTOLOADER', '');
|
$this->content->set('SITE_PLUGIN_POWER_AUTOLOADER', '');
|
||||||
$this->content->set('POWER_AUTOLOADER', '');
|
$this->content->set('POWER_AUTOLOADER', '');
|
||||||
@ -89,6 +98,7 @@ class Autoloader
|
|||||||
$this->content->set('SITE_TWO_POWER_AUTOLOADER', '');
|
$this->content->set('SITE_TWO_POWER_AUTOLOADER', '');
|
||||||
$this->content->set('SITE_THREE_POWER_AUTOLOADER', '');
|
$this->content->set('SITE_THREE_POWER_AUTOLOADER', '');
|
||||||
$this->content->set('SITE_FOUR_POWER_AUTOLOADER', '');
|
$this->content->set('SITE_FOUR_POWER_AUTOLOADER', '');
|
||||||
|
$this->content->set('INSTALLER_POWER_AUTOLOADER_ARRAY', '');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -118,6 +128,9 @@ class Autoloader
|
|||||||
// to add to custom files
|
// to add to custom files
|
||||||
$this->content->add('POWER_AUTOLOADER', $this->getAutoloaderFile(0));
|
$this->content->add('POWER_AUTOLOADER', $this->getAutoloaderFile(0));
|
||||||
$this->content->add('SITE_POWER_AUTOLOADER', $this->getAutoloaderFile(0, 'JPATH_SITE'));
|
$this->content->add('SITE_POWER_AUTOLOADER', $this->getAutoloaderFile(0, 'JPATH_SITE'));
|
||||||
|
|
||||||
|
// to add to install file
|
||||||
|
$this->content->add('INSTALLER_POWER_AUTOLOADER_ARRAY', $this->getAutoloaderInstallArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -147,20 +160,23 @@ class Autoloader
|
|||||||
uksort($this->power->namespace, fn($a, $b) => strlen((string) $b) - strlen((string) $a));
|
uksort($this->power->namespace, fn($a, $b) => strlen((string) $b) - strlen((string) $a));
|
||||||
|
|
||||||
// load to admin helper class
|
// load to admin helper class
|
||||||
$this->content->add('ADMIN_POWER_HELPER', $this->getHelperAutoloader());
|
$this->content->add('ADMIN_POWER_HELPER', $this->getAutoloaderCode());
|
||||||
|
|
||||||
// load to site helper class if needed
|
// load to site helper class if needed
|
||||||
$this->content->add('SITE_POWER_HELPER', $this->getHelperAutoloader());
|
$this->content->add('SITE_POWER_HELPER', $this->getAutoloaderCode());
|
||||||
|
|
||||||
|
// load to installer helper class if needed
|
||||||
|
$this->content->add('INSTALLER_POWER_HELPER', $this->getAutoloaderInstallerCode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get helper autoloader code
|
* Get autoloader code
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
* @since 3.2.0
|
* @since 3.2.0
|
||||||
*/
|
*/
|
||||||
private function getHelperAutoloader(): string
|
private function getAutoloaderCode(): string
|
||||||
{
|
{
|
||||||
// check if it was already build
|
// check if it was already build
|
||||||
if (!empty($this->helper))
|
if (!empty($this->helper))
|
||||||
@ -172,13 +188,13 @@ class Autoloader
|
|||||||
$code = [];
|
$code = [];
|
||||||
|
|
||||||
// add the composer stuff here
|
// add the composer stuff here
|
||||||
if (($script = $this->getComposer(0)) !== null)
|
if (($script = $this->getComposer()) !== null)
|
||||||
{
|
{
|
||||||
$code[] = $script;
|
$code[] = $script;
|
||||||
}
|
}
|
||||||
|
|
||||||
// get the helper autoloader
|
// get the helper autoloader
|
||||||
if (($script = $this->getAutoloader(0)) !== null)
|
if (($script = $this->getAutoloader()) !== null)
|
||||||
{
|
{
|
||||||
$code[] = $script;
|
$code[] = $script;
|
||||||
}
|
}
|
||||||
@ -203,7 +219,7 @@ class Autoloader
|
|||||||
*/
|
*/
|
||||||
private function getAutoloaderFile(int $tabSpace, string $area = 'JPATH_ADMINISTRATOR'): ?string
|
private function getAutoloaderFile(int $tabSpace, string $area = 'JPATH_ADMINISTRATOR'): ?string
|
||||||
{
|
{
|
||||||
// we start building the autoloaded file loader
|
// we start building the autoloader file loader
|
||||||
$autoload_file = [];
|
$autoload_file = [];
|
||||||
$autoload_file[] = Indent::_($tabSpace) . '//'
|
$autoload_file[] = Indent::_($tabSpace) . '//'
|
||||||
. Line::_(__Line__, __Class__) . " The power autoloader for this project ($area) area.";
|
. Line::_(__Line__, __Class__) . " The power autoloader for this project ($area) area.";
|
||||||
@ -221,23 +237,21 @@ class Autoloader
|
|||||||
/**
|
/**
|
||||||
* Get autoloader code
|
* Get autoloader code
|
||||||
*
|
*
|
||||||
* @param int $tabSpace The dynamic tab spacer
|
|
||||||
*
|
|
||||||
* @return string|null
|
* @return string|null
|
||||||
* @since 3.2.0
|
* @since 3.2.0
|
||||||
*/
|
*/
|
||||||
private function getAutoloader(int $tabSpace): ?string
|
private function getAutoloader(): ?string
|
||||||
{
|
{
|
||||||
if (($size = ArrayHelper::check($this->power->namespace)) > 0)
|
if (($size = ArrayHelper::check($this->power->namespace)) > 0)
|
||||||
{
|
{
|
||||||
// we start building the spl_autoload_register function call
|
// we start building the spl_autoload_register function call
|
||||||
$autoload_method = [];
|
$autoload_method = [];
|
||||||
$autoload_method[] = Indent::_($tabSpace) . '//'
|
$autoload_method[] = '//'
|
||||||
. Line::_(__Line__, __Class__) . ' register additional namespace';
|
. Line::_(__Line__, __Class__) . ' register additional namespace';
|
||||||
$autoload_method[] = Indent::_($tabSpace) . 'spl_autoload_register(function ($class) {';
|
$autoload_method[] = 'spl_autoload_register(function ($class) {';
|
||||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '//'
|
$autoload_method[] = Indent::_(1) . '//'
|
||||||
. Line::_(__Line__, __Class__) . ' project-specific base directories and namespace prefix';
|
. Line::_(__Line__, __Class__) . ' project-specific base directories and namespace prefix';
|
||||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '$search = [';
|
$autoload_method[] = Indent::_(1) . '$search = [';
|
||||||
|
|
||||||
// counter to manage the comma in the actual array
|
// counter to manage the comma in the actual array
|
||||||
$counter = 1;
|
$counter = 1;
|
||||||
@ -246,63 +260,63 @@ class Autoloader
|
|||||||
// don't add the ending comma on last value
|
// don't add the ending comma on last value
|
||||||
if ($size == $counter)
|
if ($size == $counter)
|
||||||
{
|
{
|
||||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(2) . "'" . $this->config->get('jcb_powers_path', 'libraries/jcb_powers') . "/$base_dir' => '" . implode('\\\\', $prefix) . "'";
|
$autoload_method[] = Indent::_(2) . "'" . $this->config->get('jcb_powers_path', 'libraries/jcb_powers') . "/$base_dir' => '" . implode('\\\\', $prefix) . "'";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(2) . "'" . $this->config->get('jcb_powers_path', 'libraries/jcb_powers') . "/$base_dir' => '" . implode('\\\\', $prefix) . "',";
|
$autoload_method[] = Indent::_(2) . "'" . $this->config->get('jcb_powers_path', 'libraries/jcb_powers') . "/$base_dir' => '" . implode('\\\\', $prefix) . "',";
|
||||||
}
|
}
|
||||||
$counter++;
|
$counter++;
|
||||||
}
|
}
|
||||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '];';
|
$autoload_method[] = Indent::_(1) . '];';
|
||||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '// Start the search and load if found';
|
$autoload_method[] = Indent::_(1) . '// Start the search and load if found';
|
||||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '$found = false;';
|
$autoload_method[] = Indent::_(1) . '$found = false;';
|
||||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '$found_base_dir = "";';
|
$autoload_method[] = Indent::_(1) . '$found_base_dir = "";';
|
||||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '$found_len = 0;';
|
$autoload_method[] = Indent::_(1) . '$found_len = 0;';
|
||||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . 'foreach ($search as $base_dir => $prefix)';
|
$autoload_method[] = Indent::_(1) . 'foreach ($search as $base_dir => $prefix)';
|
||||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '{';
|
$autoload_method[] = Indent::_(1) . '{';
|
||||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(2) . '//'
|
$autoload_method[] = Indent::_(2) . '//'
|
||||||
. Line::_(__Line__, __Class__) . ' does the class use the namespace prefix?';
|
. Line::_(__Line__, __Class__) . ' does the class use the namespace prefix?';
|
||||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(2) . '$len = strlen($prefix);';
|
$autoload_method[] = Indent::_(2) . '$len = strlen($prefix);';
|
||||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(2) . 'if (strncmp($prefix, $class, $len) === 0)';
|
$autoload_method[] = Indent::_(2) . 'if (strncmp($prefix, $class, $len) === 0)';
|
||||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(2) . '{';
|
$autoload_method[] = Indent::_(2) . '{';
|
||||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(3) . '//'
|
$autoload_method[] = Indent::_(3) . '//'
|
||||||
. Line::_(__Line__, __Class__) . ' we have a match so load the values';
|
. Line::_(__Line__, __Class__) . ' we have a match so load the values';
|
||||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(3) . '$found = true;';
|
$autoload_method[] = Indent::_(3) . '$found = true;';
|
||||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(3) . '$found_base_dir = $base_dir;';
|
$autoload_method[] = Indent::_(3) . '$found_base_dir = $base_dir;';
|
||||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(3) . '$found_len = $len;';
|
$autoload_method[] = Indent::_(3) . '$found_len = $len;';
|
||||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(3) . '//'
|
$autoload_method[] = Indent::_(3) . '//'
|
||||||
. Line::_(__Line__, __Class__) . ' done here';
|
. Line::_(__Line__, __Class__) . ' done here';
|
||||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(3) . 'break;';
|
$autoload_method[] = Indent::_(3) . 'break;';
|
||||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(2) . '}';
|
$autoload_method[] = Indent::_(2) . '}';
|
||||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '}';
|
$autoload_method[] = Indent::_(1) . '}';
|
||||||
|
|
||||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '//'
|
$autoload_method[] = Indent::_(1) . '//'
|
||||||
. Line::_(__Line__, __Class__) . ' check if we found a match';
|
. Line::_(__Line__, __Class__) . ' check if we found a match';
|
||||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . 'if (!$found)';
|
$autoload_method[] = Indent::_(1) . 'if (!$found)';
|
||||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '{';
|
$autoload_method[] = Indent::_(1) . '{';
|
||||||
|
|
||||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(2) . '//'
|
$autoload_method[] = Indent::_(2) . '//'
|
||||||
. Line::_(__Line__, __Class__) . ' not found so move to the next registered autoloader';
|
. Line::_(__Line__, __Class__) . ' not found so move to the next registered autoloader';
|
||||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(2) . 'return;';
|
$autoload_method[] = Indent::_(2) . 'return;';
|
||||||
|
|
||||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '}';
|
$autoload_method[] = Indent::_(1) . '}';
|
||||||
|
|
||||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '//'
|
$autoload_method[] = Indent::_(1) . '//'
|
||||||
. Line::_(__Line__, __Class__) . ' get the relative class name';
|
. Line::_(__Line__, __Class__) . ' get the relative class name';
|
||||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '$relative_class = substr($class, $found_len);';
|
$autoload_method[] = Indent::_(1) . '$relative_class = substr($class, $found_len);';
|
||||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '//'
|
$autoload_method[] = Indent::_(1) . '//'
|
||||||
. Line::_(__Line__, __Class__) . ' replace the namespace prefix with the base directory, replace namespace';
|
. Line::_(__Line__, __Class__) . ' replace the namespace prefix with the base directory, replace namespace';
|
||||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '// separators with directory separators in the relative class name, append';
|
$autoload_method[] = Indent::_(1) . '// separators with directory separators in the relative class name, append';
|
||||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '// with .php';
|
$autoload_method[] = Indent::_(1) . '// with .php';
|
||||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . "\$file = JPATH_ROOT . '/' . \$found_base_dir . '/src' . str_replace('\\\\', '/', \$relative_class) . '.php';";
|
$autoload_method[] = Indent::_(1) . "\$file = JPATH_ROOT . '/' . \$found_base_dir . '/src' . str_replace('\\\\', '/', \$relative_class) . '.php';";
|
||||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '//'
|
$autoload_method[] = Indent::_(1) . '//'
|
||||||
. Line::_(__Line__, __Class__) . ' if the file exists, require it';
|
. Line::_(__Line__, __Class__) . ' if the file exists, require it';
|
||||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . 'if (file_exists($file))';
|
$autoload_method[] = Indent::_(1) . 'if (file_exists($file))';
|
||||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '{';
|
$autoload_method[] = Indent::_(1) . '{';
|
||||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(2) . 'require $file;';
|
$autoload_method[] = Indent::_(2) . 'require $file;';
|
||||||
$autoload_method[] = Indent::_($tabSpace) . Indent::_(1) . '}';
|
$autoload_method[] = Indent::_(1) . '}';
|
||||||
$autoload_method[] = Indent::_($tabSpace) . '});';
|
$autoload_method[] = '});';
|
||||||
|
|
||||||
return implode(PHP_EOL, $autoload_method);
|
return implode(PHP_EOL, $autoload_method);
|
||||||
}
|
}
|
||||||
@ -313,12 +327,10 @@ class Autoloader
|
|||||||
/**
|
/**
|
||||||
* Get the composer autoloader routine
|
* Get the composer autoloader routine
|
||||||
*
|
*
|
||||||
* @param int $tabSpace The dynamic tab spacer
|
|
||||||
*
|
|
||||||
* @return string|null
|
* @return string|null
|
||||||
* @since 3.2.0
|
* @since 3.2.0
|
||||||
*/
|
*/
|
||||||
private function getComposer(int $tabSpace): ?string
|
private function getComposer(): ?string
|
||||||
{
|
{
|
||||||
if (ArrayHelper::check($this->power->composer))
|
if (ArrayHelper::check($this->power->composer))
|
||||||
{
|
{
|
||||||
@ -332,11 +344,11 @@ class Autoloader
|
|||||||
// don't add the ending comma on last value
|
// don't add the ending comma on last value
|
||||||
if (empty($add_once[$access_point]))
|
if (empty($add_once[$access_point]))
|
||||||
{
|
{
|
||||||
$composer_routine[] = Indent::_($tabSpace) . "\$composer_autoloader = JPATH_LIBRARIES . '/$access_point';";
|
$composer_routine[] = "\$composer_autoloader = JPATH_LIBRARIES . '/$access_point';";
|
||||||
$composer_routine[] = Indent::_($tabSpace) . 'if (file_exists($composer_autoloader))';
|
$composer_routine[] = 'if (file_exists($composer_autoloader))';
|
||||||
$composer_routine[] = Indent::_($tabSpace) . "{";
|
$composer_routine[] = "{";
|
||||||
$composer_routine[] = Indent::_($tabSpace) . Indent::_(1) . 'require_once $composer_autoloader;';
|
$composer_routine[] = Indent::_(1) . 'require_once $composer_autoloader;';
|
||||||
$composer_routine[] = Indent::_($tabSpace) . "}";
|
$composer_routine[] = "}";
|
||||||
|
|
||||||
$add_once[$access_point] = true;
|
$add_once[$access_point] = true;
|
||||||
}
|
}
|
||||||
@ -345,12 +357,209 @@ class Autoloader
|
|||||||
// this is just about the [autoloader or autoloaders] in the comment ;)
|
// this is just about the [autoloader or autoloaders] in the comment ;)
|
||||||
if (count($add_once) == 1)
|
if (count($add_once) == 1)
|
||||||
{
|
{
|
||||||
array_unshift($composer_routine, Indent::_($tabSpace) . '//'
|
array_unshift($composer_routine, '//'
|
||||||
. Line::_(__Line__, __Class__) . ' add the autoloader for the composer classes');
|
. Line::_(__Line__, __Class__) . ' add the autoloader for the composer classes');
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
array_unshift($composer_routine, Indent::_($tabSpace) . '//'
|
array_unshift($composer_routine, '//'
|
||||||
|
. Line::_(__Line__, __Class__) . ' add the autoloaders for the composer classes');
|
||||||
|
}
|
||||||
|
|
||||||
|
return implode(PHP_EOL, $composer_routine);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get autoloaders for install file
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @since 5.0.2
|
||||||
|
*/
|
||||||
|
private function getAutoloaderInstallArray(): string
|
||||||
|
{
|
||||||
|
// we start building the autoloader file loader
|
||||||
|
$autoload_file = [];
|
||||||
|
$autoload_file[] = PHP_EOL . Indent::_(3) . "__DIR__ . '/" .
|
||||||
|
$this->config->get('component_installer_autoloader_path', 'ERROR') . "',";
|
||||||
|
$autoload_file[] = Indent::_(3) . "JPATH_ADMINISTRATOR . '/components/com_"
|
||||||
|
. $this->config->get('component_code_name', 'ERROR') . '/'
|
||||||
|
. $this->config->get('component_autoloader_path', 'ERROR') . "'" . PHP_EOL . Indent::_(2);
|
||||||
|
|
||||||
|
return implode(PHP_EOL, $autoload_file);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get installer autoloader code
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
* @since 5.0.2
|
||||||
|
*/
|
||||||
|
private function getAutoloaderInstallerCode(): string
|
||||||
|
{
|
||||||
|
// check if it was already build
|
||||||
|
if (!empty($this->installerhelper))
|
||||||
|
{
|
||||||
|
return $this->installerhelper;
|
||||||
|
}
|
||||||
|
|
||||||
|
// load the code
|
||||||
|
$code = [];
|
||||||
|
|
||||||
|
// add the composer stuff here
|
||||||
|
// if (($script = $this->getInstallerComposer()) !== null)
|
||||||
|
// {
|
||||||
|
// $code[] = $script;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// get the helper autoloader
|
||||||
|
if (($script = $this->getInstallerAutoloader()) !== null)
|
||||||
|
{
|
||||||
|
$code[] = $script;
|
||||||
|
}
|
||||||
|
|
||||||
|
// if we have any
|
||||||
|
if (!empty($code))
|
||||||
|
{
|
||||||
|
$this->installerhelper = PHP_EOL . PHP_EOL . implode(PHP_EOL . PHP_EOL, $code);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $this->installerhelper;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get autoloader code
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return string|null
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
private function getInstallerAutoloader(): ?string
|
||||||
|
{
|
||||||
|
if (($size = ArrayHelper::check($this->power->namespace)) > 0)
|
||||||
|
{
|
||||||
|
// we start building the spl_autoload_register function call
|
||||||
|
$autoload_method = [];
|
||||||
|
$autoload_method[] = '//'
|
||||||
|
. Line::_(__Line__, __Class__) . ' register additional namespace';
|
||||||
|
$autoload_method[] = 'spl_autoload_register(function ($class) {';
|
||||||
|
$autoload_method[] = Indent::_(1) . '//'
|
||||||
|
. Line::_(__Line__, __Class__) . ' project-specific base directories and namespace prefix';
|
||||||
|
$autoload_method[] = Indent::_(1) . '$search = [';
|
||||||
|
|
||||||
|
// counter to manage the comma in the actual array
|
||||||
|
$counter = 1;
|
||||||
|
foreach ($this->power->namespace as $base_dir => $prefix)
|
||||||
|
{
|
||||||
|
// don't add the ending comma on last value
|
||||||
|
if ($size == $counter)
|
||||||
|
{
|
||||||
|
$autoload_method[] = Indent::_(2) . "'" . $this->config->get('jcb_powers_path', 'libraries/jcb_powers') . "/$base_dir' => '" . implode('\\\\', $prefix) . "'";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$autoload_method[] = Indent::_(2) . "'" . $this->config->get('jcb_powers_path', 'libraries/jcb_powers') . "/$base_dir' => '" . implode('\\\\', $prefix) . "',";
|
||||||
|
}
|
||||||
|
$counter++;
|
||||||
|
}
|
||||||
|
$autoload_method[] = Indent::_(1) . '];';
|
||||||
|
$autoload_method[] = Indent::_(1) . '// Start the search and load if found';
|
||||||
|
$autoload_method[] = Indent::_(1) . '$found = false;';
|
||||||
|
$autoload_method[] = Indent::_(1) . '$found_base_dir = "";';
|
||||||
|
$autoload_method[] = Indent::_(1) . '$found_len = 0;';
|
||||||
|
$autoload_method[] = Indent::_(1) . 'foreach ($search as $base_dir => $prefix)';
|
||||||
|
$autoload_method[] = Indent::_(1) . '{';
|
||||||
|
$autoload_method[] = Indent::_(2) . '//'
|
||||||
|
. Line::_(__Line__, __Class__) . ' does the class use the namespace prefix?';
|
||||||
|
$autoload_method[] = Indent::_(2) . '$len = strlen($prefix);';
|
||||||
|
$autoload_method[] = Indent::_(2) . 'if (strncmp($prefix, $class, $len) === 0)';
|
||||||
|
$autoload_method[] = Indent::_(2) . '{';
|
||||||
|
$autoload_method[] = Indent::_(3) . '//'
|
||||||
|
. Line::_(__Line__, __Class__) . ' we have a match so load the values';
|
||||||
|
$autoload_method[] = Indent::_(3) . '$found = true;';
|
||||||
|
$autoload_method[] = Indent::_(3) . '$found_base_dir = $base_dir;';
|
||||||
|
$autoload_method[] = Indent::_(3) . '$found_len = $len;';
|
||||||
|
$autoload_method[] = Indent::_(3) . '//'
|
||||||
|
. Line::_(__Line__, __Class__) . ' done here';
|
||||||
|
$autoload_method[] = Indent::_(3) . 'break;';
|
||||||
|
$autoload_method[] = Indent::_(2) . '}';
|
||||||
|
$autoload_method[] = Indent::_(1) . '}';
|
||||||
|
|
||||||
|
$autoload_method[] = Indent::_(1) . '//'
|
||||||
|
. Line::_(__Line__, __Class__) . ' check if we found a match';
|
||||||
|
$autoload_method[] = Indent::_(1) . 'if (!$found)';
|
||||||
|
$autoload_method[] = Indent::_(1) . '{';
|
||||||
|
|
||||||
|
$autoload_method[] = Indent::_(2) . '//'
|
||||||
|
. Line::_(__Line__, __Class__) . ' not found so move to the next registered autoloader';
|
||||||
|
$autoload_method[] = Indent::_(2) . 'return;';
|
||||||
|
|
||||||
|
$autoload_method[] = Indent::_(1) . '}';
|
||||||
|
|
||||||
|
$autoload_method[] = Indent::_(1) . '//'
|
||||||
|
. Line::_(__Line__, __Class__) . ' get the relative class name';
|
||||||
|
$autoload_method[] = Indent::_(1) . '$relative_class = substr($class, $found_len);';
|
||||||
|
$autoload_method[] = Indent::_(1) . '//'
|
||||||
|
. Line::_(__Line__, __Class__) . ' replace the namespace prefix with the base directory, replace namespace';
|
||||||
|
$autoload_method[] = Indent::_(1) . '// separators with directory separators in the relative class name, append';
|
||||||
|
$autoload_method[] = Indent::_(1) . '// with .php';
|
||||||
|
$autoload_method[] = Indent::_(1) . "\$file = __DIR__ . '/' . \$found_base_dir . '/src' . str_replace('\\\\', '/', \$relative_class) . '.php';";
|
||||||
|
$autoload_method[] = Indent::_(1) . '//'
|
||||||
|
. Line::_(__Line__, __Class__) . ' if the file exists, require it';
|
||||||
|
$autoload_method[] = Indent::_(1) . 'if (file_exists($file))';
|
||||||
|
$autoload_method[] = Indent::_(1) . '{';
|
||||||
|
$autoload_method[] = Indent::_(2) . 'require $file;';
|
||||||
|
$autoload_method[] = Indent::_(1) . '}';
|
||||||
|
$autoload_method[] = '});';
|
||||||
|
|
||||||
|
return implode(PHP_EOL, $autoload_method);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the composer autoloader routine (NOT READY)
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* @return string|null
|
||||||
|
* @since 3.2.0
|
||||||
|
*/
|
||||||
|
private function getInstallerComposer(): ?string
|
||||||
|
{
|
||||||
|
if (ArrayHelper::check($this->power->composer))
|
||||||
|
{
|
||||||
|
// 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[] = "\$composer_autoloader = __DIR__ . '/libraries/$access_point';";
|
||||||
|
$composer_routine[] = 'if (file_exists($composer_autoloader))';
|
||||||
|
$composer_routine[] = "{";
|
||||||
|
$composer_routine[] = Indent::_(1) . 'require_once $composer_autoloader;';
|
||||||
|
$composer_routine[] = "}";
|
||||||
|
|
||||||
|
$add_once[$access_point] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// this is just about the [autoloader or autoloaders] in the comment ;)
|
||||||
|
if (count($add_once) == 1)
|
||||||
|
{
|
||||||
|
array_unshift($composer_routine, '//'
|
||||||
|
. Line::_(__Line__, __Class__) . ' add the autoloader for the composer classes');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
array_unshift($composer_routine, '//'
|
||||||
. Line::_(__Line__, __Class__) . ' add the autoloaders for the composer classes');
|
. Line::_(__Line__, __Class__) . ' add the autoloaders for the composer classes');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,88 @@
|
|||||||
|
<?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;
|
||||||
|
|
||||||
|
|
||||||
|
use VDM\Joomla\Interfaces\PHPConfigurationCheckerInterface;
|
||||||
|
use VDM\Joomla\Abstraction\PHPConfigurationChecker as ExtendingPHPConfigurationChecker;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Componentbuilder PHP Configuration Checker
|
||||||
|
*
|
||||||
|
* @since 3.2.2
|
||||||
|
*/
|
||||||
|
final class PHPConfigurationChecker extends ExtendingPHPConfigurationChecker implements PHPConfigurationCheckerInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* The upload max filesize value
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 5.0.2
|
||||||
|
**/
|
||||||
|
protected string $upload_max_filesize = '128M';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The post max size value
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 5.0.2
|
||||||
|
**/
|
||||||
|
protected string $post_max_size = '128M';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The max execution time value
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
* @since 5.0.2
|
||||||
|
**/
|
||||||
|
protected int $max_execution_time = 60;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The max input vars value
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
* @since 5.0.2
|
||||||
|
**/
|
||||||
|
protected int $max_input_vars = 7000;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The max input time value
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
* @since 5.0.2
|
||||||
|
**/
|
||||||
|
protected int $max_input_time = 60;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The memory limit value
|
||||||
|
*
|
||||||
|
* @var string
|
||||||
|
* @since 5.0.2
|
||||||
|
**/
|
||||||
|
protected string $memory_limit = '256M';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor.
|
||||||
|
*
|
||||||
|
* @since 5.0.2
|
||||||
|
*/
|
||||||
|
public function __construct($app = null)
|
||||||
|
{
|
||||||
|
parent::__construct($app);
|
||||||
|
|
||||||
|
// set the required PHP Configures
|
||||||
|
$this->set('environment.name', 'Componentbuilder environment');
|
||||||
|
$this->set('environment.wiki_url', 'git.vdm.dev/joomla/Component-Builder/wiki/PHP-Settings');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,30 @@
|
|||||||
|
<?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\Interfaces;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* PHP Configuration Checker
|
||||||
|
*
|
||||||
|
* @since 5.0.2
|
||||||
|
*/
|
||||||
|
interface PHPConfigurationCheckerInterface
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Check that the required configurations are set for PHP
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
* @since 5.0.2
|
||||||
|
**/
|
||||||
|
public function run(): void;
|
||||||
|
}
|
||||||
|
|
151
script.php
151
script.php
@ -23,12 +23,15 @@ use VDM\Joomla\FOF\Encrypt\AES;
|
|||||||
use VDM\Joomla\Utilities\StringHelper;
|
use VDM\Joomla\Utilities\StringHelper;
|
||||||
use VDM\Joomla\Utilities\JsonHelper;
|
use VDM\Joomla\Utilities\JsonHelper;
|
||||||
use VDM\Joomla\Utilities\ArrayHelper;
|
use VDM\Joomla\Utilities\ArrayHelper;
|
||||||
|
use VDM\Joomla\Componentbuilder\PHPConfigurationChecker;
|
||||||
use VDM\Joomla\Componentbuilder\Table\SchemaChecker;
|
use VDM\Joomla\Componentbuilder\Table\SchemaChecker;
|
||||||
use VDM\Joomla\Utilities\GetHelper;
|
use VDM\Joomla\Utilities\GetHelper;
|
||||||
HTML::_('bootstrap.renderModal');
|
HTML::_('bootstrap.renderModal');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Script File of Componentbuilder Component
|
* Script File of Componentbuilder Component
|
||||||
|
*
|
||||||
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
class Com_ComponentbuilderInstallerScript
|
class Com_ComponentbuilderInstallerScript
|
||||||
{
|
{
|
||||||
@ -36,6 +39,7 @@ class Com_ComponentbuilderInstallerScript
|
|||||||
* Constructor
|
* Constructor
|
||||||
*
|
*
|
||||||
* @param ComponentAdapter $parent The object responsible for running this script
|
* @param ComponentAdapter $parent The object responsible for running this script
|
||||||
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
public function __construct(ComponentAdapter $parent) {}
|
public function __construct(ComponentAdapter $parent) {}
|
||||||
|
|
||||||
@ -45,6 +49,7 @@ class Com_ComponentbuilderInstallerScript
|
|||||||
* @param ComponentAdapter $parent The object responsible for running this script
|
* @param ComponentAdapter $parent The object responsible for running this script
|
||||||
*
|
*
|
||||||
* @return boolean True on success
|
* @return boolean True on success
|
||||||
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
public function install(ComponentAdapter $parent) {}
|
public function install(ComponentAdapter $parent) {}
|
||||||
|
|
||||||
@ -52,6 +57,8 @@ class Com_ComponentbuilderInstallerScript
|
|||||||
* Called on uninstallation
|
* Called on uninstallation
|
||||||
*
|
*
|
||||||
* @param ComponentAdapter $parent The object responsible for running this script
|
* @param ComponentAdapter $parent The object responsible for running this script
|
||||||
|
*
|
||||||
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
public function uninstall(ComponentAdapter $parent)
|
public function uninstall(ComponentAdapter $parent)
|
||||||
{
|
{
|
||||||
@ -5973,6 +5980,7 @@ class Com_ComponentbuilderInstallerScript
|
|||||||
* @param ComponentAdapter $parent The object responsible for running this script
|
* @param ComponentAdapter $parent The object responsible for running this script
|
||||||
*
|
*
|
||||||
* @return boolean True on success
|
* @return boolean True on success
|
||||||
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
public function update(ComponentAdapter $parent){}
|
public function update(ComponentAdapter $parent){}
|
||||||
|
|
||||||
@ -5983,6 +5991,7 @@ class Com_ComponentbuilderInstallerScript
|
|||||||
* @param ComponentAdapter $parent The object responsible for running this script
|
* @param ComponentAdapter $parent The object responsible for running this script
|
||||||
*
|
*
|
||||||
* @return boolean True on success
|
* @return boolean True on success
|
||||||
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
public function preflight($type, ComponentAdapter $parent)
|
public function preflight($type, ComponentAdapter $parent)
|
||||||
{
|
{
|
||||||
@ -6457,15 +6466,21 @@ class Com_ComponentbuilderInstallerScript
|
|||||||
$this->removeFolder($cleaner);
|
$this->removeFolder($cleaner);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check that the required configuration are set for PHP
|
// Check that the PHP configurations are sufficient
|
||||||
$this->phpConfigurationCheck($app);
|
if ($this->classExists(PHPConfigurationChecker::class))
|
||||||
|
{
|
||||||
|
(new PHPConfigurationChecker())->run();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// do any install needed
|
// do any install needed
|
||||||
if ($type === 'install')
|
if ($type === 'install')
|
||||||
{
|
{
|
||||||
|
|
||||||
// Check that the required configuration are set for PHP
|
// Check that the PHP configurations are sufficient
|
||||||
$this->phpConfigurationCheck($app);
|
if ($this->classExists(PHPConfigurationChecker::class))
|
||||||
|
{
|
||||||
|
(new PHPConfigurationChecker())->run();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// check if the PHPExcel stuff is still around
|
// check if the PHPExcel stuff is still around
|
||||||
if (File::exists(JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/PHPExcel.php'))
|
if (File::exists(JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/PHPExcel.php'))
|
||||||
@ -6485,6 +6500,7 @@ class Com_ComponentbuilderInstallerScript
|
|||||||
* @param ComponentAdapter $parent The object responsible for running this script
|
* @param ComponentAdapter $parent The object responsible for running this script
|
||||||
*
|
*
|
||||||
* @return boolean True on success
|
* @return boolean True on success
|
||||||
|
* @since 1.5.0
|
||||||
*/
|
*/
|
||||||
public function postflight($type, ComponentAdapter $parent)
|
public function postflight($type, ComponentAdapter $parent)
|
||||||
{
|
{
|
||||||
@ -9985,7 +10001,7 @@ class Com_ComponentbuilderInstallerScript
|
|||||||
echo '<div style="background-color: #fff;" class="alert alert-info"><a target="_blank" href="https://dev.vdm.io" title="Component Builder">
|
echo '<div style="background-color: #fff;" class="alert alert-info"><a target="_blank" href="https://dev.vdm.io" title="Component Builder">
|
||||||
<img src="components/com_componentbuilder/assets/images/vdm-component.jpg"/>
|
<img src="components/com_componentbuilder/assets/images/vdm-component.jpg"/>
|
||||||
</a>
|
</a>
|
||||||
<h3>Upgrade to Version 3.2.3-alpha2 Was Successful! Let us know if anything is not working as expected.</h3></div>';
|
<h3>Upgrade to Version 3.2.3-alpha3 Was Successful! Let us know if anything is not working as expected.</h3></div>';
|
||||||
|
|
||||||
// Set db if not set already.
|
// Set db if not set already.
|
||||||
if (!isset($db))
|
if (!isset($db))
|
||||||
@ -11861,130 +11877,31 @@ class Com_ComponentbuilderInstallerScript
|
|||||||
*/
|
*/
|
||||||
protected function classExists(string $className): bool
|
protected function classExists(string $className): bool
|
||||||
{
|
{
|
||||||
if (!class_exists($className, true))
|
if (class_exists($className, true))
|
||||||
{
|
{
|
||||||
// The power autoloader for this project (JPATH_ADMINISTRATOR) area.
|
|
||||||
$power_autoloader = JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/powerloader.php';
|
|
||||||
if (file_exists($power_autoloader))
|
|
||||||
{
|
|
||||||
require_once $power_autoloader;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check again if the class now exists after requiring the autoloader
|
|
||||||
if (!class_exists($className, true))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// Autoloaders to check
|
||||||
* Define the required limits with specific messages for success and warning scenarios
|
$autoloaders = [
|
||||||
*
|
__DIR__ . '/script_powerloader.php',
|
||||||
* @var array
|
JPATH_ADMINISTRATOR . '/components/com_componentbuilder/helpers/powerloader.php'
|
||||||
* @since 3.2.1
|
|
||||||
*/
|
|
||||||
protected array $requiredPHPConfigs = [
|
|
||||||
'upload_max_filesize' => [
|
|
||||||
'value' => '128M',
|
|
||||||
'success' => 'The upload_max_filesize is appropriately set to handle large files, which is essential for uploading substantial components and media.',
|
|
||||||
'warning' => 'The current upload_max_filesize may not support large file uploads effectively, potentially causing failures during component installation.'
|
|
||||||
],
|
|
||||||
'post_max_size' => [
|
|
||||||
'value' => '128M',
|
|
||||||
'success' => 'The post_max_size setting is sufficient to manage large data submissions, ensuring smooth data processing within forms and uploads.',
|
|
||||||
'warning' => 'An insufficient post_max_size can lead to truncated data submissions, affecting form functionality and data integrity.'
|
|
||||||
],
|
|
||||||
'max_execution_time' => [
|
|
||||||
'value' => 60,
|
|
||||||
'success' => 'Max execution time is set high enough to execute complex operations without premature termination, which is crucial for lengthy operations.',
|
|
||||||
'warning' => 'A low max execution time could lead to script timeouts, especially during intensive operations, which might interrupt execution and cause failures during the compiling of a large extension.'
|
|
||||||
],
|
|
||||||
'max_input_vars' => [
|
|
||||||
'value' => 7000,
|
|
||||||
'success' => 'The max_input_vars setting supports a high number of input variables, facilitating complex forms and detailed component configurations.',
|
|
||||||
'warning' => 'Too few max_input_vars may result in lost data during processing complex forms, which can lead to incomplete configurations and operational issues.'
|
|
||||||
],
|
|
||||||
'max_input_time' => [
|
|
||||||
'value' => 60,
|
|
||||||
'success' => 'Max input time is adequate for processing inputs efficiently during high-load operations, ensuring no premature timeouts.',
|
|
||||||
'warning' => 'An insufficient max input time could result in incomplete data processing during input-heavy operations, potentially leading to errors and data loss.'
|
|
||||||
],
|
|
||||||
'memory_limit' => [
|
|
||||||
'value' => '256M',
|
|
||||||
'success' => 'The memory limit is set high to accommodate extensive operations and data processing, which enhances overall performance and stability.',
|
|
||||||
'warning' => 'A low memory limit can lead to frequent crashes and performance issues, particularly when processing large amounts of data or complex calculations.'
|
|
||||||
]
|
|
||||||
];
|
];
|
||||||
|
|
||||||
/**
|
foreach ($autoloaders as $autoloader)
|
||||||
* Helper function to convert PHP INI memory values to bytes
|
|
||||||
*
|
|
||||||
* @param string $value The value to convert
|
|
||||||
*
|
|
||||||
* @return int The bytes value
|
|
||||||
* @since 3.2.1
|
|
||||||
*/
|
|
||||||
protected function convertToBytes(string $value): int
|
|
||||||
{
|
{
|
||||||
$value = trim($value);
|
if (file_exists($autoloader))
|
||||||
$lastChar = strtolower($value[strlen($value) - 1]);
|
{
|
||||||
$numValue = substr($value, 0, -1);
|
require_once $autoloader;
|
||||||
|
|
||||||
switch ($lastChar)
|
if (class_exists($className, true))
|
||||||
{
|
{
|
||||||
case 'g':
|
return true;
|
||||||
return $numValue * 1024 * 1024 * 1024;
|
}
|
||||||
case 'm':
|
|
||||||
return $numValue * 1024 * 1024;
|
|
||||||
case 'k':
|
|
||||||
return $numValue * 1024;
|
|
||||||
default:
|
|
||||||
return (int) $value;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
return false;
|
||||||
* Check that the required configurations are set for PHP
|
|
||||||
*
|
|
||||||
* @param $app The application
|
|
||||||
*
|
|
||||||
* @return void
|
|
||||||
* @since 3.2.1
|
|
||||||
*/
|
|
||||||
protected function phpConfigurationCheck($app): void
|
|
||||||
{
|
|
||||||
$showHelp = false;
|
|
||||||
|
|
||||||
// Check each configuration and provide detailed feedback
|
|
||||||
foreach ($this->requiredPHPConfigs as $configName => $configDetails)
|
|
||||||
{
|
|
||||||
$currentValue = ini_get($configName);
|
|
||||||
if ($currentValue === false)
|
|
||||||
{
|
|
||||||
$app->enqueueMessage("Error: Unable to retrieve current setting for '{$configName}'.", 'error');
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$isMemoryValue = strpbrk($configDetails['value'], 'KMG') !== false;
|
|
||||||
$requiredValueBytes = $isMemoryValue ? $this->convertToBytes($configDetails['value']) : (int) $configDetails['value'];
|
|
||||||
$currentValueBytes = $isMemoryValue ? $this->convertToBytes($currentValue) : (int) $currentValue;
|
|
||||||
$conditionMet = $currentValueBytes >= $requiredValueBytes;
|
|
||||||
|
|
||||||
$messageType = $conditionMet ? 'message' : 'warning';
|
|
||||||
$messageText = $conditionMet ?
|
|
||||||
"Success: {$configName} is set to {$currentValue}. " . $configDetails['success'] :
|
|
||||||
"Warning: {$configName} configuration should be at least {$configDetails['value']} but is currently {$currentValue}. " . $configDetails['warning'];
|
|
||||||
$showHelp = ($showHelp || $messageType === 'warning') ? true : false;
|
|
||||||
$app->enqueueMessage($messageText, $messageType);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($showHelp)
|
|
||||||
{
|
|
||||||
$app->enqueueMessage('To optimize your Joomla Component Builder (JCB) development environment, specific PHP settings must be enhanced.<br>These settings are crucial for ensuring the successful installation and compilation of extensions.<br>We\'ve identified that certain configurations currently do not meet the recommended standards.<br>To adjust these settings and prevent potential issues, please consult our detailed guide available at <a href="https://git.vdm.dev/joomla/Component-Builder/wiki/PHP-Settings" target="_blank">JCB PHP Settings Wiki</a>.
|
|
||||||
', 'notice');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
60
script_powerloader.php
Normal file
60
script_powerloader.php
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package Joomla.Component.Builder
|
||||||
|
*
|
||||||
|
* @created 30th April, 2015
|
||||||
|
* @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
|
||||||
|
*/
|
||||||
|
|
||||||
|
// No direct access to this file
|
||||||
|
defined('_JEXEC') or die;
|
||||||
|
|
||||||
|
// register additional namespace
|
||||||
|
spl_autoload_register(function ($class) {
|
||||||
|
// project-specific base directories and namespace prefix
|
||||||
|
$search = [
|
||||||
|
'libraries/vendor_jcb/VDM.Joomla.Gitea' => 'VDM\\Joomla\\Gitea',
|
||||||
|
'libraries/vendor_jcb/VDM.Joomla.FOF' => 'VDM\\Joomla\\FOF',
|
||||||
|
'libraries/vendor_jcb/VDM.Joomla' => 'VDM\\Joomla',
|
||||||
|
'libraries/vendor_jcb/VDM.Minify' => 'VDM\\Minify',
|
||||||
|
'libraries/vendor_jcb/VDM.Psr' => 'VDM\\Psr'
|
||||||
|
];
|
||||||
|
// Start the search and load if found
|
||||||
|
$found = false;
|
||||||
|
$found_base_dir = "";
|
||||||
|
$found_len = 0;
|
||||||
|
foreach ($search as $base_dir => $prefix)
|
||||||
|
{
|
||||||
|
// does the class use the namespace prefix?
|
||||||
|
$len = strlen($prefix);
|
||||||
|
if (strncmp($prefix, $class, $len) === 0)
|
||||||
|
{
|
||||||
|
// we have a match so load the values
|
||||||
|
$found = true;
|
||||||
|
$found_base_dir = $base_dir;
|
||||||
|
$found_len = $len;
|
||||||
|
// done here
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// check if we found a match
|
||||||
|
if (!$found)
|
||||||
|
{
|
||||||
|
// not found so move to the next registered autoloader
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// get the relative class name
|
||||||
|
$relative_class = substr($class, $found_len);
|
||||||
|
// replace the namespace prefix with the base directory, replace namespace
|
||||||
|
// separators with directory separators in the relative class name, append
|
||||||
|
// with .php
|
||||||
|
$file = __DIR__ . '/' . $found_base_dir . '/src' . str_replace('\\', '/', $relative_class) . '.php';
|
||||||
|
// if the file exists, require it
|
||||||
|
if (file_exists($file))
|
||||||
|
{
|
||||||
|
require $file;
|
||||||
|
}
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user