Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscript.php
More file actions
Latest commit
101 lines (78 loc) · 2.4 KB
/
Copy pathscript.php
File metadata and controls
101 lines (78 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
defined('_JEXEC') or die;
useJoomla\CMS\Application\AdministratorApplication;
useJoomla\CMS\Factory;
useJoomla\CMS\Installer\InstallerAdapter;
useJoomla\CMS\Installer\InstallerScriptInterface;
useJoomla\CMS\Language\Text;
useJoomla\CMS\Version;
useJoomla\Database\DatabaseDriver;
useJoomla\DI\Container;
useJoomla\DI\ServiceProviderInterface;
returnnewclass () implements ServiceProviderInterface {
publicfunctionregister(Container$container): void
{
$container->set(InstallerScriptInterface::class, newclass ($container->get(AdministratorApplication::class)) implements InstallerScriptInterface {
protectedAdministratorApplication$app;
protectedDatabaseDriver$db;
protectedstring$minimumJoomla = '5.0.0';
protectedstring$minimumPhp = '8.2';
publicfunction__construct(AdministratorApplication$app)
{
$this->app = $app;
$this->db = Factory::getContainer()->get('DatabaseDriver');
}
publicfunctioninstall(InstallerAdapter$adapter): bool
{
$this->enablePlugin($adapter);
returntrue;
}
publicfunctionupdate(InstallerAdapter$adapter): bool
{
returntrue;
}
publicfunctionuninstall(InstallerAdapter$adapter): bool
{
returntrue;
}
publicfunctionpreflight(string$type, InstallerAdapter$adapter): bool
{
if (!$this->checkCompatible())
{
returnfalse;
}
returntrue;
}
publicfunctionpostflight(string$type, InstallerAdapter$adapter): bool
{
returntrue;
}
protectedfunctioncheckCompatible(): bool
{
$app = Factory::getApplication();
if (!(newVersion())->isCompatible($this->minimumJoomla))
{
$app->enqueueMessage(Text::sprintf('Required version of Joomla! %s', $this->minimumJoomla),
'error');
returnfalse;
}
if (!(version_compare(PHP_VERSION, $this->minimumPhp) >= 0))
{
$app->enqueueMessage(Text::sprintf('Required PHP version %s', $this->minimumPhp),
'error');
returnfalse;
}
returntrue;
}
protectedfunctionenablePlugin(InstallerAdapter$adapter)
{
$plugin = new \stdClass();
$plugin->type = 'plugin';
$plugin->element = $adapter->getElement();
$plugin->folder = (string) $adapter->getParent()->manifest->attributes()['group'];
$plugin->enabled = 1;
$this->db->updateObject('#__extensions', $plugin, ['type', 'element', 'folder']);
}
});
}
};