1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* TechDivision\Import\Converter\Plugins\GenericExportableConverterPlugin |
5
|
|
|
* |
6
|
|
|
* NOTICE OF LICENSE |
7
|
|
|
* |
8
|
|
|
* This source file is subject to the Open Software License (OSL 3.0) |
9
|
|
|
* that is available through the world-wide-web at this URL: |
10
|
|
|
* http://opensource.org/licenses/osl-3.0.php |
11
|
|
|
* |
12
|
|
|
* PHP version 5 |
13
|
|
|
* |
14
|
|
|
* @author Tim Wagner <[email protected]> |
15
|
|
|
* @copyright 2019 TechDivision GmbH <[email protected]> |
16
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
17
|
|
|
* @link https://github.com/techdivision/import-converter |
18
|
|
|
* @link http://www.techdivision.com |
19
|
|
|
*/ |
20
|
|
|
|
21
|
|
|
namespace TechDivision\Import\Converter\Plugins; |
22
|
|
|
|
23
|
|
|
use TechDivision\Import\Utils\CacheKeys; |
24
|
|
|
use TechDivision\Import\Converter\Utils\ConfigurationKeys; |
25
|
|
|
use TechDivision\Import\Plugins\SubjectPlugin; |
26
|
|
|
use TechDivision\Import\Plugins\ExportableTrait; |
27
|
|
|
use TechDivision\Import\Plugins\ExportablePluginInterface; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Plugin that exports artefacts with type names defined in configuration. |
31
|
|
|
* |
32
|
|
|
* @author Tim Wagner <[email protected]> |
33
|
|
|
* @copyright 2019 TechDivision GmbH <[email protected]> |
34
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
35
|
|
|
* @link https://github.com/techdivision/import-converter |
36
|
|
|
* @link http://www.techdivision.com |
37
|
|
|
*/ |
38
|
|
|
class GenericExportableConverterPlugin extends SubjectPlugin implements ExportablePluginInterface |
39
|
|
|
{ |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* The trait that provides export functionality. |
43
|
|
|
* |
44
|
|
|
* @var \TechDivision\Import\Plugins\ExportableTrait |
45
|
|
|
*/ |
46
|
|
|
use ExportableTrait; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Returns the array with the exportable artefact types from the configuration. |
50
|
|
|
* |
51
|
|
|
* @return array The artefact types |
52
|
|
|
*/ |
53
|
|
|
protected function getExportableArtefactTypes() |
54
|
|
|
{ |
55
|
|
|
|
56
|
|
|
// query whether or not the configuration value is available |
57
|
|
|
if ($this->getPluginConfiguration()->hasParam(ConfigurationKeys::EXPORTABLE_ARTEFACT_TYPES)) { |
58
|
|
|
return $this->getPluginConfiguration()->getParam(ConfigurationKeys::EXPORTABLE_ARTEFACT_TYPES); |
|
|
|
|
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
// return an empty array if the param has NOT been set |
62
|
|
|
return array(); |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
/** |
66
|
|
|
* Return's the artefacts for post-processing. |
67
|
|
|
* |
68
|
|
|
* @return array The artefacts |
69
|
|
|
*/ |
70
|
|
|
public function getArtefacts() |
71
|
|
|
{ |
72
|
|
|
|
73
|
|
|
// load the available artefacts |
74
|
|
|
$artefacts = $this->getRegistryProcessor()->getAttribute(CacheKeys::ARTEFACTS); |
75
|
|
|
|
76
|
|
|
// initialize the array for the artefacts that has to be exported |
77
|
|
|
$toExport = array(); |
78
|
|
|
|
79
|
|
|
// load the artefacts that has to be exported |
80
|
|
|
foreach ($this->getExportableArtefactTypes() as $exportableArtefactType) { |
81
|
|
|
if (isset($artefacts[$exportableArtefactType]) && is_array($artefacts[$exportableArtefactType])) { |
82
|
|
|
$toExport[$exportableArtefactType] = $artefacts[$exportableArtefactType]; |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|
86
|
|
|
// return the array with the exportable artefac types |
87
|
|
|
return $toExport; |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
/** |
91
|
|
|
* Reset the array with the artefacts to free the memory. |
92
|
|
|
* |
93
|
|
|
* @return void |
94
|
|
|
*/ |
95
|
|
|
public function resetArtefacts() |
96
|
|
|
{ |
97
|
|
|
// do nothing here, because we can't remove only one key from the array with artefacts in a multiprocess compatible manner |
98
|
|
|
} |
99
|
|
|
} |
100
|
|
|
|