1 | <?php |
||
2 | |||
3 | namespace FlexiPeeHP; |
||
4 | |||
5 | if (!defined('EASE_APPNAME')) { |
||
6 | define('EASE_APPNAME', 'FlexiPeeHP Actions'); |
||
7 | } |
||
8 | if (!defined('EASE_LOGGER')) { |
||
9 | define('EASE_LOGGER', 'console|syslog'); |
||
10 | } |
||
11 | |||
12 | require_once '../testing/bootstrap.php'; |
||
13 | |||
14 | $outFile = 'Actions.php'; |
||
15 | $outJson = 'Actions.json'; |
||
16 | $ok = 0; |
||
17 | |||
18 | /** |
||
19 | * Obtain Actions for given evidence |
||
20 | * |
||
21 | * @param string $evidence |
||
22 | * @param FlexiBeeRO $syncer Class to read from FlexiBee |
||
23 | * @return array Actions structure |
||
24 | */ |
||
25 | function getEvidenceActions($evidence, FlexiBeeRO $syncer) { |
||
26 | $columns = $syncer->getColumnsInfo($evidence); |
||
27 | if (array_key_exists('zamekK', $columns)) { |
||
28 | $syncer->addStatusMessage('Adding LOCK actions to evidence ' . $evidence, |
||
29 | 'debug'); |
||
30 | $actions = [ |
||
31 | 'lock' => [ |
||
32 | 'actionId' => 'lock', |
||
33 | 'actionName' => 'Zamknout', |
||
34 | 'needInstance' => 'true', |
||
35 | 'actionMakesSense' => 'ONLY_WITH_INSTANCE_AND_NOT_IN_CREATE', |
||
36 | 'isRealAction' => 'true', |
||
37 | 'isService' => 'YES', |
||
38 | ], |
||
39 | 'lock-for-ucetni' => [ |
||
40 | 'actionId' => 'lock-for-ucetni', |
||
41 | 'actionName' => 'Zamknout pro učetní', |
||
42 | 'needInstance' => 'true', |
||
43 | 'actionMakesSense' => 'ONLY_WITH_INSTANCE_AND_NOT_IN_CREATE', |
||
44 | 'isRealAction' => 'true', |
||
45 | 'isService' => 'YES', |
||
46 | ], |
||
47 | 'unlock' => [ |
||
48 | 'actionId' => 'unlock', |
||
49 | 'actionName' => 'Odemknout', |
||
50 | 'needInstance' => 'true', |
||
51 | 'actionMakesSense' => 'ONLY_WITH_INSTANCE_AND_NOT_IN_CREATE', |
||
52 | 'isRealAction' => 'true', |
||
53 | 'isService' => 'YES', |
||
54 | ] |
||
55 | ]; |
||
56 | } else { |
||
57 | $actions = []; |
||
58 | } |
||
59 | $flexinfo = $syncer->performRequest($evidence . '/actions.json'); |
||
60 | if (count($flexinfo) && array_key_exists('actions', $flexinfo)) { |
||
61 | if (isset($flexinfo['actions']['action'])) { |
||
62 | if (\Ease\Functions::isAssoc($flexinfo['actions']['action'])) { |
||
63 | $key = $flexinfo['actions']['action']['actionId']; |
||
64 | $actions[$key] = $flexinfo['actions']['action']; |
||
65 | } else { |
||
66 | foreach ($flexinfo['actions']['action'] as $evidenceActions) { |
||
67 | if (array_key_exists('actionId', $evidenceActions)) { |
||
68 | $key = $evidenceActions['actionId']; |
||
69 | $actions[$key] = $evidenceActions; |
||
70 | } else { |
||
71 | $syncer->addStatusMessage(sprintf('actionId not set for %s', |
||
72 | $evidence . ' / ' . $evidenceActions['actionName']), |
||
73 | 'warning'); |
||
74 | } |
||
75 | } |
||
76 | } |
||
77 | } else { |
||
78 | $syncer->addStatusMessage(sprintf('Missing actions for %s', |
||
79 | $evidence), 'warning'); |
||
80 | } |
||
81 | } |
||
82 | return $actions; |
||
83 | } |
||
84 | |||
85 | $evidenceActions = '<?php |
||
86 | /** |
||
87 | * FlexiPeeHP - Evidence Actions. |
||
88 | * |
||
89 | * @author Vítězslav Dvořák <[email protected]> |
||
90 | * @copyright (C) 2015-' . date('Y') . ' Spoje.Net |
||
91 | */ |
||
92 | |||
93 | namespace FlexiPeeHP; |
||
94 | |||
95 | /** |
||
96 | * EvidenceActions |
||
97 | * |
||
98 | * @link https://demo.flexibee.eu/devdoc/actions Provádění akcí |
||
99 | */ |
||
100 | |||
101 | class Actions |
||
102 | { |
||
103 | '; |
||
104 | |||
105 | $statuser = new Status(); |
||
106 | $evidenceActions .= ' /** |
||
107 | * Source FlexiBee server version. |
||
108 | * |
||
109 | * @var string |
||
110 | */ |
||
111 | '; |
||
112 | $evidenceActions .= ' static public $version = \'' . $statuser->getDataValue('version') . '\'; |
||
113 | |||
114 | '; |
||
115 | |||
116 | $syncer = new FlexiBeeRO(); |
||
0 ignored issues
–
show
Deprecated Code
introduced
by
![]() |
|||
117 | $syncer->setObjectName('FlexiBee Evidence Actions'); |
||
118 | $syncer->addStatusMessage('Updating Evidences Actions'); |
||
119 | |||
120 | $structures = []; |
||
121 | |||
122 | $pos = 0; |
||
123 | foreach (EvidenceList::$name as $evidencePath => $evidenceName) { |
||
124 | $pos++; |
||
125 | $structure = getEvidenceActions($evidencePath, $syncer); |
||
126 | $structures[$evidencePath] = $structure; |
||
127 | if (count($structure)) { |
||
128 | $evidenceActions .= ' /** |
||
129 | * Evidence ' . $evidencePath . ' (' . $evidenceName . ') Actions. |
||
130 | * |
||
131 | * @var array |
||
132 | */ |
||
133 | '; |
||
134 | $evidenceActions .= ' static public $' . lcfirst(FlexiBeeRO::evidenceToClassName($evidencePath)) . ' = ' . var_export($structure, |
||
135 | true) . '; |
||
136 | '; |
||
137 | |||
138 | $syncer->addStatusMessage($pos . ' of ' . count(EvidenceList::$name) . ' ' . $evidencePath . ': ' . implode(',', |
||
139 | array_keys($structure)), 'success'); |
||
140 | $ok++; |
||
141 | } else { |
||
142 | $syncer->addStatusMessage($pos . ' of ' . count(EvidenceList::$name) . ' ' . $evidencePath . ': obtaining actions problem', |
||
143 | 'error'); |
||
144 | } |
||
145 | } |
||
146 | |||
147 | $evidenceActions .= '} |
||
148 | '; |
||
149 | |||
150 | $syncer->addStatusMessage('Updating of ' . $ok . ' Evidences Actions done', |
||
151 | 'success'); |
||
152 | file_put_contents($outFile, $evidenceActions); |
||
153 | |||
154 | file_put_contents($outJson, json_encode($structures)); |
||
155 |