This repository was archived by the owner on Aug 11, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathinstall.php
More file actions
95 lines (90 loc) · 3.11 KB
/
install.php
File metadata and controls
95 lines (90 loc) · 3.11 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
<?php
/**
* This install script ensures that all dependencies are met.
*
* @author Clay Freeman <git@clayfreeman.com>
* @copyright 2018 Bluewall, LLC. All rights reserved.
* @license GNU General Public License v3 (GPL-3.0).
*/
use \Joomla\CMS\Factory;
use \Joomla\CMS\Installer\InstallerAdapter;
use \Joomla\CMS\Installer\InstallerScript;
use \Joomla\CMS\Language\Text;
/**
* The HTTP/2 Push automated Joomla! system plugin installer script.
*/
final class plgSystemHttp2PushInstallerScript extends InstallerScript {
/**
* Define a minimum acceptable PHP version for this plugin.
*
* @var string
*/
protected $minimumPhp = '7.1.0';
/**
* Check that a class exists by name using the provided symbol.
*
* This method intentionally forbids autoloading since the symbol should be
* provided by PHP core.
*
* @param string $symbol A string containing the class name.
*
* @return bool `TRUE` if the class exists,
* `FALSE` otherwise.
*/
protected function classExists(string $symbol): bool {
$exists = \class_exists($symbol, FALSE);
if (!$exists) {
Factory::getApplication()->enqueueMessage(
Text::sprintf('PLG_SYSTEM_HTTP2PUSH_DEPENDENCY',
\htmlentities($symbol)), 'error');
}
return $exists;
}
/**
* Check that a function exists by name using the provided symbol.
*
* @param string $symbol A string containing the function name.
*
* @return bool `TRUE` if the function exists,
* `FALSE` otherwise.
*/
protected function functionExists(string $symbol): bool {
$exists = \function_exists($symbol);
if (!$exists) {
Factory::getApplication()->enqueueMessage(
Text::sprintf('PLG_SYSTEM_HTTP2PUSH_DEPENDENCY',
\htmlentities($symbol)), 'error');
}
return $exists;
}
/**
* Checks that the required PHP API's are installed.
*
* This plugin depends on the `\DOMDocument` and `\DOMXPath` classes and the
* `\libxml_use_internal_errors()` function available in PHP's XML extension
* on many distributions or by statically compiling PHP with the
* `--enable-dom` and `--enable-simplexml` flags.
*
* @param string $type The type of change (install,
* update, ...).
* @param InstallerAdapter $parent The class calling this method.
*
* @return bool `TRUE` if all prerequisites are
* satisfied, `FALSE` otherwise
*/
public function preflight($type, $parent) {
// Check a list of classes that are required for this plugin to work
$classes = \array_map([$this, 'classExists'], [
'\\DOMDocument',
'\\DOMElement',
'\\DOMNode',
'\\DOMXPath'
]);
// Check a list of functions that are required for this plugin to work
$functions = \array_map([$this, 'functionExists'], [
'\\libxml_use_internal_errors'
]);
// Ensure that all of the required symbols exist
return !\in_array(FALSE, \array_merge($classes, $functions), TRUE);
}
}