You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/building-extensions/install-update/installation/install-process.md
+40-21Lines changed: 40 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -48,7 +48,7 @@ When you go to install extensions and select a zip file of an extension to insta
48
48
## Example Script File
49
49
50
50
The easiest way to write a script file is to use the \Joomla\CMS\Installer\InstallerScriptInterface definition in libraries/src/Installer/InstallerScriptInterface.php.
51
-
You simply have to return an instance of a class which implements the 5 installer functions.
51
+
You simply have to return an instance of a class which implements the 5 installer functions. You can use the \Joomla\CMS\Installer\InstallerScriptTrait trait from libraries/src/Installer/InstallerScriptTrait.php to benefit from pre-defined functionality like a PHP and Joomla minimum version check or creating a dashboard preset menu module.
52
52
53
53
You can either
54
54
1. Return an anonymous Script File class which implements InstallerScriptInterface, or
@@ -64,6 +64,7 @@ For an example of the first approach see the [Module Tutorial Step 6](../../modu
64
64
use Joomla\CMS\Application\AdministratorApplication;
65
65
use Joomla\CMS\Installer\InstallerAdapter;
66
66
use Joomla\CMS\Installer\InstallerScriptInterface;
67
+
use Joomla\CMS\Installer\InstallerScriptTrait;
67
68
use Joomla\CMS\Language\Text;
68
69
use Joomla\Database\DatabaseInterface;
69
70
use Joomla\DI\Container;
@@ -84,9 +85,39 @@ return new class () implements ServiceProviderInterface {
84
85
$container->get(AdministratorApplication::class),
85
86
$container->get(DatabaseInterface::class)
86
87
) implements InstallerScriptInterface {
88
+
use InstallerScriptTrait;
89
+
87
90
private AdministratorApplication $app;
88
91
private DatabaseInterface $db;
89
92
93
+
/**
94
+
* Minimum PHP version required to install the extension
95
+
*
96
+
* @var string
97
+
*/
98
+
protected $minimumPhp = '8.4';
99
+
100
+
/**
101
+
* Minimum Joomla! version required to install the extension
102
+
*
103
+
* @var string
104
+
*/
105
+
protected $minimumJoomla = '6.0.0;
106
+
107
+
/**
108
+
* A list of files to be deleted
109
+
*
110
+
* @var array
111
+
*/
112
+
protected $deleteFiles = [];
113
+
114
+
/**
115
+
* A list of folders to be deleted
116
+
*
117
+
* @var array
118
+
*/
119
+
protected $deleteFolders = [];
120
+
90
121
public function __construct(AdministratorApplication $app, DatabaseInterface $db)
91
122
{
92
123
$this->app = $app;
@@ -114,33 +145,21 @@ return new class () implements ServiceProviderInterface {
114
145
return true;
115
146
}
116
147
117
-
public function preflight(string $type, InstallerAdapter $parent): bool
148
+
public function customPreflight(string $type, InstallerAdapter $parent): bool
118
149
{
119
-
return true;
120
-
}
150
+
// Your custom preflight code
121
151
122
-
public function postflight(string $type, InstallerAdapter $parent): bool
0 commit comments