Compare commits
38 Commits
Author | SHA1 | Date | |
---|---|---|---|
9f2bd76e7b | |||
12f42d5862 | |||
c2be954cb9 | |||
a4db1430a3 | |||
f3df2e8cae | |||
3400287ea9 | |||
2d9a5cbd8c | |||
6ae490271f | |||
9be4b8b3d5 | |||
e176e70832 | |||
214bbd23d1 | |||
aa37b1961e | |||
052d51263e | |||
a778d12183 | |||
a396b50bfd | |||
48280b0053 | |||
e240f1aff5 | |||
a2065c141a | |||
466897f9a8 | |||
2fd0d4c784 | |||
36b11971d4 | |||
c54d2a1338 | |||
4ae1650844 | |||
ec4143067c | |||
a17d579ea7 | |||
7647206027 | |||
cc10c12a85 | |||
6f4fa877a4 | |||
b68ab9e1a8 | |||
7766a51e43 | |||
03882d5952 | |||
85c66ba77a | |||
58d993b319 | |||
52493a408f | |||
0f3808a8b4 | |||
b58ee63a61 | |||
828acf546a | |||
fcfea05579 |
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<extension type="plugin" version="4.0" group="extension" method="upgrade">
|
||||
<extension type="plugin" version="5.0" group="extension" method="upgrade">
|
||||
<name>PLG_EXTENSION_COMPONENTBUILDERPRIVACYCOMPILER</name>
|
||||
<creationDate>7th November, 2024</creationDate>
|
||||
<author>Llewellyn van der Merwe</author>
|
||||
|
118
script.php
118
script.php
@ -13,9 +13,11 @@
|
||||
defined('_JEXEC') or die('Restricted access');
|
||||
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Version;
|
||||
use Joomla\CMS\Installer\InstallerAdapter;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Filesystem\File;
|
||||
use Joomla\CMS\Filesystem\Folder;
|
||||
use Joomla\Filesystem\File;
|
||||
use Joomla\Filesystem\Folder;
|
||||
|
||||
/**
|
||||
* Extension - Componentbuilder Privacy Compiler script file.
|
||||
@ -24,4 +26,116 @@ use Joomla\CMS\Filesystem\Folder;
|
||||
*/
|
||||
class plgExtensionComponentbuilderPrivacyCompilerInstallerScript
|
||||
{
|
||||
/**
|
||||
* The CMS Application.
|
||||
*
|
||||
* @since 4.4.2
|
||||
*/
|
||||
protected $app;
|
||||
|
||||
/**
|
||||
* A list of files to be deleted
|
||||
*
|
||||
* @var array
|
||||
* @since 3.6
|
||||
*/
|
||||
protected array $deleteFiles = [];
|
||||
|
||||
/**
|
||||
* A list of folders to be deleted
|
||||
*
|
||||
* @var array
|
||||
* @since 3.6
|
||||
*/
|
||||
protected array $deleteFolders = [];
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param InstallerAdapter $adapter The object responsible for running this script
|
||||
*/
|
||||
public function __construct($adapter)
|
||||
{
|
||||
// get application
|
||||
$this->app = Factory::getApplication();
|
||||
|
||||
if (is_file(JPATH_ROOT . '/plugins/extension/componentbuilderprivacycompiler/componentbuilderprivacycompiler.php'))
|
||||
{
|
||||
$this->deleteFiles[] = '/plugins/extension/componentbuilderprivacycompiler/componentbuilderprivacycompiler.php';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called before any type of action
|
||||
*
|
||||
* @param string $route Which action is happening (install|uninstall|discover_install|update)
|
||||
* @param InstallerAdapter $adapter The object responsible for running this script
|
||||
*
|
||||
* @return boolean True on success
|
||||
*/
|
||||
public function preflight($route, $adapter)
|
||||
{
|
||||
// set application to local method var, just use $this->app in future [we will drop $app in J6]
|
||||
$app = $this->app;
|
||||
|
||||
// the default for both install and update
|
||||
$jversion = new Version();
|
||||
if (!$jversion->isCompatible('5.0.0'))
|
||||
{
|
||||
$app->enqueueMessage('Please upgrade to at least Joomla! 5.0.0 before continuing!', 'error');
|
||||
return false;
|
||||
}
|
||||
|
||||
// remove old files and folders
|
||||
$this->removeFiles();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called before any type of action
|
||||
*
|
||||
* @param string $route Which action is happening (install|uninstall|discover_install|update)
|
||||
* @param InstallerAdapter $adapter The object responsible for running this script
|
||||
*
|
||||
* @return boolean True on success
|
||||
*/
|
||||
public function postflight($route, $adapter)
|
||||
{
|
||||
// set application to local method var, just use $this->app in future [we will drop $app in J6]
|
||||
$app = $this->app;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the files and folders in the given array from
|
||||
*
|
||||
* @return void
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected function removeFiles()
|
||||
{
|
||||
if (!empty($this->deleteFiles))
|
||||
{
|
||||
foreach ($this->deleteFiles as $file)
|
||||
{
|
||||
if (is_file(JPATH_ROOT . $file) && !File::delete(JPATH_ROOT . $file))
|
||||
{
|
||||
echo Text::sprintf('JLIB_INSTALLER_ERROR_FILE_FOLDER', $file) . '<br>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($this->deleteFolders))
|
||||
{
|
||||
foreach ($this->deleteFolders as $folder)
|
||||
{
|
||||
if (is_dir(JPATH_ROOT . $folder) && !Folder::delete(JPATH_ROOT . $folder))
|
||||
{
|
||||
echo Text::sprintf('JLIB_INSTALLER_ERROR_FILE_FOLDER', $folder) . '<br>';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,6 @@ use Joomla\CMS\Extension\PluginInterface;
|
||||
use Joomla\Event\DispatcherInterface;
|
||||
use Joomla\DI\ServiceProviderInterface;
|
||||
use Joomla\DI\Container;
|
||||
use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper;
|
||||
use VDM\Plugin\Extension\ComponentbuilderPrivacyCompiler\Extension\ComponentbuilderPrivacyCompiler;
|
||||
|
||||
return new class () implements ServiceProviderInterface {
|
||||
|
@ -10,7 +10,6 @@
|
||||
*/
|
||||
namespace VDM\Plugin\Extension\ComponentbuilderPrivacyCompiler\Extension;
|
||||
|
||||
use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper;
|
||||
use Joomla\CMS\Factory;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Application\CMSApplication;
|
||||
|
Loading…
Reference in New Issue
Block a user