|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* Copyright (C) 2018 |
|
5
|
|
|
* Nathan Boiron <[email protected]> |
|
6
|
|
|
* Romain Canon <[email protected]> |
|
7
|
|
|
* |
|
8
|
|
|
* This file is part of the TYPO3 NotiZ project. |
|
9
|
|
|
* It is free software; you can redistribute it and/or modify it |
|
10
|
|
|
* under the terms of the GNU General Public License, either |
|
11
|
|
|
* version 3 of the License, or any later version. |
|
12
|
|
|
* |
|
13
|
|
|
* For the full copyright and license information, see: |
|
14
|
|
|
* http://www.gnu.org/licenses/gpl-3.0.html |
|
15
|
|
|
*/ |
|
16
|
|
|
|
|
17
|
|
|
namespace CuyZ\Notiz\Domain\Event\TYPO3; |
|
18
|
|
|
|
|
19
|
|
|
use CuyZ\Notiz\Core\Event\AbstractEvent; |
|
20
|
|
|
use CuyZ\Notiz\Core\Event\Support\ProvidesExampleProperties; |
|
21
|
|
|
use TYPO3\CMS\Core\Utility\PathUtility; |
|
22
|
|
|
use TYPO3\CMS\Extensionmanager\Utility\ListUtility; |
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Event triggered when an extension is installed via the extension manager. |
|
26
|
|
|
*/ |
|
27
|
|
|
class ExtensionInstalledEvent extends AbstractEvent implements ProvidesExampleProperties |
|
28
|
|
|
{ |
|
29
|
|
|
/** |
|
30
|
|
|
* @label Event/TYPO3/ExtensionInstalled:marker.key |
|
31
|
|
|
* @marker |
|
32
|
|
|
* |
|
33
|
|
|
* @var string |
|
34
|
|
|
*/ |
|
35
|
|
|
protected $key; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @label Event/TYPO3/ExtensionInstalled:marker.title |
|
39
|
|
|
* @marker |
|
40
|
|
|
* |
|
41
|
|
|
* @var string |
|
42
|
|
|
*/ |
|
43
|
|
|
protected $title; |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @label Event/TYPO3/ExtensionInstalled:marker.description |
|
47
|
|
|
* @marker |
|
48
|
|
|
* |
|
49
|
|
|
* @var string |
|
50
|
|
|
*/ |
|
51
|
|
|
protected $description; |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* @label Event/TYPO3/ExtensionInstalled:marker.version |
|
55
|
|
|
* @marker |
|
56
|
|
|
* |
|
57
|
|
|
* @var string |
|
58
|
|
|
*/ |
|
59
|
|
|
protected $version; |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @var ListUtility |
|
63
|
|
|
*/ |
|
64
|
|
|
protected $listUtility; |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @param string $extensionKey |
|
68
|
|
|
*/ |
|
69
|
|
|
public function run($extensionKey) |
|
70
|
|
|
{ |
|
71
|
|
|
$extension = $this->getExtensionData($extensionKey); |
|
72
|
|
|
|
|
73
|
|
|
$this->key = $extensionKey; |
|
74
|
|
|
$this->title = $extension['title']; |
|
75
|
|
|
$this->version = $extension['version']; |
|
76
|
|
|
$this->description = $extension['description']; |
|
77
|
|
|
} |
|
78
|
|
|
|
|
79
|
|
|
/** |
|
80
|
|
|
* @param string $extensionKey |
|
81
|
|
|
* @return array |
|
82
|
|
|
*/ |
|
83
|
|
|
protected function getExtensionData($extensionKey) |
|
84
|
|
|
{ |
|
85
|
|
|
$extensionPackage = $this->listUtility->getExtension($extensionKey); |
|
86
|
|
|
|
|
87
|
|
|
$data = [ |
|
88
|
|
|
'siteRelPath' => PathUtility::getRelativePath(PATH_site, $extensionPackage->getPackagePath()), |
|
89
|
|
|
'key' => $extensionKey, |
|
90
|
|
|
]; |
|
91
|
|
|
|
|
92
|
|
|
$extensionsInformation = $this->listUtility->enrichExtensionsWithEmConfInformation([$extensionKey => $data]); |
|
93
|
|
|
|
|
94
|
|
|
return $extensionsInformation[$extensionKey]; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
/** |
|
98
|
|
|
* @param ListUtility $listUtility |
|
99
|
|
|
*/ |
|
100
|
|
|
public function injectListUtility(ListUtility $listUtility) |
|
101
|
|
|
{ |
|
102
|
|
|
$this->listUtility = $listUtility; |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
/** |
|
106
|
|
|
* @return array |
|
107
|
|
|
*/ |
|
108
|
|
|
public function getExampleProperties() |
|
109
|
|
|
{ |
|
110
|
|
|
return [ |
|
111
|
|
|
'key' => 'my_extension', |
|
112
|
|
|
'title' => 'My Extension', |
|
113
|
|
|
'description' => 'Some random description that gives details about my extension.', |
|
114
|
|
|
'version' => '1.0.42', |
|
115
|
|
|
]; |
|
116
|
|
|
} |
|
117
|
|
|
} |
|
118
|
|
|
|