Commit | Line | Data |
---|---|---|
31236900 TO |
1 | <?php |
2 | /* | |
3 | +--------------------------------------------------------------------+ | |
4 | | Copyright CiviCRM LLC. All rights reserved. | | |
5 | | | | |
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 | | |
9 | +--------------------------------------------------------------------+ | |
10 | */ | |
11 | ||
12 | /** | |
13 | * Track minimal information which identifies the target extension. | |
14 | */ | |
15 | trait CRM_Extension_Upgrader_IdentityTrait { | |
16 | ||
17 | /** | |
18 | * @var string | |
19 | * eg 'com.example.myextension' | |
20 | */ | |
21 | protected $extensionName; | |
22 | ||
23 | /** | |
24 | * @var string | |
25 | * full path to the extension's source tree | |
26 | */ | |
27 | protected $extensionDir; | |
28 | ||
29 | /** | |
30 | * {@inheritDoc} | |
31 | */ | |
32 | public function init(array $params) { | |
33 | $this->extensionName = $params['key']; | |
34 | $system = CRM_Extension_System::singleton(); | |
35 | $mapper = $system->getMapper(); | |
36 | $this->extensionDir = $mapper->keyToBasePath($this->extensionName); | |
37 | } | |
38 | ||
39 | /** | |
40 | * @return string | |
41 | * Ex: 'org.example.foobar' | |
42 | */ | |
43 | public function getExtensionKey() { | |
44 | return $this->extensionName; | |
45 | } | |
46 | ||
47 | /** | |
48 | * @return string | |
49 | * Ex: '/var/www/sites/default/ext/org.example.foobar' | |
50 | */ | |
51 | public function getExtensionDir() { | |
52 | return $this->extensionDir; | |
53 | } | |
54 | ||
55 | } |