ADD script file for installation process (template)

This commit is contained in:
Thomas Kuschel 2024-09-01 01:03:07 +02:00
parent d395377760
commit 0532b525b5
3 changed files with 82 additions and 4 deletions

View File

@ -2,14 +2,16 @@
<extension type="component" method="upgrade"> <extension type="component" method="upgrade">
<name>Depot</name> <name>Depot</name>
<author>KW4NZ</author> <author>KW4NZ</author>
<creationDate>2024-05-26</creationDate> <creationDate>2024-08-31</creationDate>
<copyright>(C) KW4NZ Thomas Kuschel</copyright> <copyright>(C) KW4NZ Thomas Kuschel</copyright>
<license>GPL v2 +; see LICENSE.md</license> <license>GPL v2 +; see LICENSE.md</license>
<authorEmail>thomas@kuschel.at</authorEmail> <authorEmail>thomas@kuschel.at</authorEmail>
<authorUrl>https://kuschel.at</authorUrl> <authorUrl>https://kuschel.at</authorUrl>
<version>0.9.20</version> <version>0.9.23</version>
<description>COM_DEPOT_XML_DESCRIPTION</description> <description>COM_DEPOT_XML_DESCRIPTION</description>
<namespace path="src/">KW4NZ\Component\Depot</namespace> <namespace path="src/">KW4NZ\Component\Depot</namespace>
<!-- Runs on install/uninstall/update since 2.5 -->
<scriptfile>script.php</scriptfile>
<install> <!-- Runs on install --> <install> <!-- Runs on install -->
<sql> <sql>
<file driver="mysql" charset="utf8">sql/install.mysql.utf8.sql</file> <file driver="mysql" charset="utf8">sql/install.mysql.utf8.sql</file>

76
script.php Normal file
View File

@ -0,0 +1,76 @@
<?php
/**
* @package Depot.Installation.Script
* @subpackage com_depot
* @author Thomas Kuschel <thomas@kuschel.at>
* @copyright (C) 2024 KW4NZ, <https://www.kuschel.at>
* @license GNU General Public License version 2 or later; see LICENSE.md
* @since 0.9.21
*/
\defined('_JEXEC') or die;
/**
* Script file of Depot component.
*
* The name of this class is dependent on the component being installed.
* The class name should have the component's name, directly followed by
* the text InstallerScript (ex:. com_depotInstallerScript).
*
* This class will be called by Joomla's installer, if specified in your component's
* manifest file, and is used for custom automation actions in its installation process.
*
* In order to use this automation script, you should reference it in your component's
* mainfest file as follows:
* <scriptfile>script.php</scriptfile>
*/
use Joomla\CMS\Factory;
use Joomla\CMS\Installer\InstallerAdapter;
use Joomla\CMS\Installer\InstallerScriptInterface;
use Joomla\CMS\Language\Text;
return new class() implements InstallerScriptInterface {
private string $minimumJoomla = '4.4.8'; // '5.1.4'
private string $minimumPhp = '8.1.29';
public function install(InstallerAdapter $adapter): bool
{
echo "component install<br>";
return true;
}
public function update(InstallerAdapter $adapter): bool
{
echo "component update<br>";
return true;
}
public function uninstall(InstallerAdapter $adapter): bool
{
echo "component uninstall<br>";
return true;
}
public function preflight(string $type, InstallerAdapter $adapter): bool
{
echo "component preflight<br>";
if (version_compare(PHP_VERSION, $this->minimumPhp, '<')) {
Factory::getApplication()->enqueueMessage(sprintf(Text::_('JLIB_INSTALLER_MINIMUM_PHP'), $this->minimumPhp), 'error');
return false;
}
if (version_compare(JVERSION, $this->minimumJoomla, '<')) {
Factory::getApplication()->enqueueMessage(sprintf(Text::_('JLIB_INSTALLER_MINIMUM_JOOMLA'), $this->minimumJoomla), 'error');
return false;
}
return true;
}
public function postflight(string $type, InstallerAdapter $adapter): bool
{
echo "component postflight<br>";
return true;
}
};

BIN
zip/depot.zip (Stored with Git LFS)

Binary file not shown.