Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
bc77d7c0 | 4 | | Copyright CiviCRM LLC. All rights reserved. | |
6a488035 | 5 | | | |
bc77d7c0 TO |
6 | | This work is published under the GNU AGPLv3 license with some | |
7 | | permitted exceptions and without any warranty. For full license | | |
8 | | and copyright information, see https://civicrm.org/licensing | | |
6a488035 | 9 | +--------------------------------------------------------------------+ |
d25dd0ee | 10 | */ |
6a488035 TO |
11 | |
12 | /** | |
13 | * @package CRM | |
ca5cec67 | 14 | * @copyright CiviCRM LLC https://civicrm.org/licensing |
6a488035 TO |
15 | */ |
16 | ||
17 | /** | |
18 | * An extension container is a locally-accessible source tree which can be | |
19 | * scanned for extensions. | |
20 | */ | |
21 | class CRM_Extension_Container_Static implements CRM_Extension_Container_Interface { | |
7b966967 | 22 | |
e0ef6999 | 23 | /** |
78612209 TO |
24 | * @param array $exts |
25 | * Array(string $key => array $spec) List of extensions. | |
e0ef6999 | 26 | */ |
6a488035 TO |
27 | public function __construct($exts) { |
28 | $this->exts = $exts; | |
29 | } | |
30 | ||
58119ee4 | 31 | /** |
e7c15cb6 | 32 | * @inheritDoc |
58119ee4 TO |
33 | */ |
34 | public function checkRequirements() { | |
be2fb01f | 35 | return []; |
58119ee4 TO |
36 | } |
37 | ||
6a488035 | 38 | /** |
e7c15cb6 | 39 | * @inheritDoc |
6a488035 TO |
40 | */ |
41 | public function getName() { | |
42 | return $this->name; | |
43 | } | |
44 | ||
45 | /** | |
e7c15cb6 | 46 | * @inheritDoc |
6a488035 TO |
47 | */ |
48 | public function getKeys() { | |
49 | return array_keys($this->exts); | |
50 | } | |
51 | ||
52 | /** | |
e7c15cb6 | 53 | * @inheritDoc |
6a488035 TO |
54 | */ |
55 | public function getPath($key) { | |
56 | $e = $this->getExt($key); | |
57 | return $e['path']; | |
58 | } | |
59 | ||
60 | /** | |
e7c15cb6 | 61 | * @inheritDoc |
6a488035 TO |
62 | */ |
63 | public function getResUrl($key) { | |
64 | $e = $this->getExt($key); | |
65 | return $e['resUrl']; | |
66 | } | |
67 | ||
68 | /** | |
e7c15cb6 | 69 | * @inheritDoc |
6a488035 TO |
70 | */ |
71 | public function refresh() { | |
72 | } | |
73 | ||
e0ef6999 | 74 | /** |
78612209 TO |
75 | * @param string $key |
76 | * Extension name. | |
e0ef6999 EM |
77 | * |
78 | * @throws CRM_Extension_Exception_MissingException | |
79 | */ | |
6a488035 TO |
80 | protected function getExt($key) { |
81 | if (isset($this->exts[$key])) { | |
82 | return $this->exts[$key]; | |
78612209 TO |
83 | } |
84 | else { | |
6a488035 TO |
85 | throw new CRM_Extension_Exception_MissingException("Missing extension: $key"); |
86 | } | |
87 | } | |
96025800 | 88 | |
6a488035 | 89 | } |