-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpackages.php
73 lines (67 loc) · 2.16 KB
/
packages.php
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
<?php
/**
* Defines and autoloads the application's dependencies
*
* @package hexydec/torque
*/
namespace hexydec\torque;
class packages {
/**
* @var string SLUG A constant defining the slug that is used in the admin system to deliver the app
*/
public const SLUG = 'torque';
/**
* @var string VERSION The version number of the application, this is used in the cache key for CSS/Javascript that is minified
*/
public const VERSION = '0.7.3';
/**
* @var string INSTALLDIR The folder where the dependencies are stored
*/
public const INSTALLDIR = __DIR__.'/packages/';
/**
* @var array $packages A list of external dependencies to be installed when the plugin is activated and where their autoloaders are
*
* Note that external dependencies are only installed when install-external.php is available and the packages are not already bundled
*/
protected static array $packages = [
'htmldoc' => [
'class' => 'hexydec\\html\\htmldoc',
'file' => 'https://github.com/hexydec/htmldoc/archive/refs/heads/master.zip',
'extract' => 'htmldoc-master/src/',
'autoload' => 'htmldoc/autoload.php'
],
'cssdoc' => [
'class' => 'hexydec\\css\\cssdoc',
'file' => 'https://github.com/hexydec/cssdoc/archive/refs/heads/master.zip',
'extract' => 'cssdoc-master/src/',
'autoload' => 'cssdoc/autoload.php'
],
'jslite' => [
'class' => 'hexydec\\jslite\\jslite',
'file' => 'https://github.com/hexydec/jslite/archive/refs/heads/master.zip',
'extract' => 'jslite-master/src/',
'autoload' => 'jslite/autoload.php'
],
'tokenise' => [
'class' => 'hexydec\\tokens\\tokenise',
'file' => 'https://github.com/hexydec/tokenise/archive/refs/heads/master.zip',
'extract' => 'tokenise-master/src/',
'autoload' => 'tokenise/autoload.php'
]
];
/**
* Defines an autoloader to load the application's dependencies
*
* @return void
*/
public static function autoload() : void {
\spl_autoload_register(function (string $class) : void {
$dir = self::INSTALLDIR;
foreach (self::$packages AS $item) {
if ($item['class'] === $class && \file_exists($dir.$item['autoload'])) {
require $dir.$item['autoload'];
}
}
});
}
}