1
|
|
|
<?php |
|
|
|
|
2
|
|
|
|
3
|
|
|
namespace FlexiPeeHP; |
4
|
|
|
|
5
|
|
|
require_once '../testing/bootstrap.php'; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Obtain Actions for given evidence |
9
|
|
|
* |
10
|
|
|
* @param string $evidence |
11
|
|
|
* @param FlexiBeeRO $syncer Class to read from FlexiBee |
12
|
|
|
* @return array Actions structure |
13
|
|
|
*/ |
14
|
|
|
function getEvidenceActions($evidence, FlexiBeeRO $syncer) |
15
|
|
|
{ |
16
|
|
|
$actions = []; |
17
|
|
|
$flexinfo = $syncer->performRequest($evidence.'/actions.json'); |
18
|
|
|
if (count($flexinfo) && array_key_exists('actions', $flexinfo)) { |
19
|
|
|
if (isset($flexinfo['actions']['action'])) { |
20
|
|
|
foreach ($flexinfo['actions']['action'] as $evidenceActions) { |
21
|
|
|
$key = $evidenceActions['actionId']; |
22
|
|
|
$actions[$key] = $evidenceActions; |
23
|
|
|
} |
24
|
|
|
} else { |
25
|
|
|
$syncer->addStatusMessage(sprintf('Missing actions for %s', |
26
|
|
|
$evidence), 'warning'); |
27
|
|
|
} |
28
|
|
|
} |
29
|
|
|
return $actions; |
30
|
|
|
} |
31
|
|
|
echo '<?php |
32
|
|
|
/** |
33
|
|
|
* FlexiPeeHP - Evidence Actions. |
34
|
|
|
* |
35
|
|
|
* @author Vítězslav Dvořák <[email protected]> |
36
|
|
|
* @copyright (C) 2015,2016 Spoje.Net |
37
|
|
|
*/ |
38
|
|
|
|
39
|
|
|
namespace FlexiPeeHP; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* EvidenceActions |
43
|
|
|
* |
44
|
|
|
* @link https://demo.flexibee.eu/devdoc/actions Provádění akcí |
45
|
|
|
*/ |
46
|
|
|
|
47
|
|
|
class Actions |
48
|
|
|
{ |
49
|
|
|
'; |
50
|
|
|
|
51
|
|
|
|
52
|
|
|
$syncer = new FlexiBeeRO(); |
53
|
|
|
|
54
|
|
|
$pos = 0; |
55
|
|
View Code Duplication |
foreach (EvidenceList::$name as $evidencePath => $evidenceName) { |
|
|
|
|
56
|
|
|
$pos++; |
57
|
|
|
$structure = getEvidenceActions($evidencePath, $syncer); |
58
|
|
|
if (count($structure)) { |
59
|
|
|
echo ' /** |
60
|
|
|
* Evidence '.$evidencePath.' ('.$evidenceName.') Actions. |
61
|
|
|
* |
62
|
|
|
* @var array |
63
|
|
|
*/ |
64
|
|
|
'; |
65
|
|
|
echo ' static public $'.lcfirst(FlexiBeeRO::evidenceToClassName($evidencePath)).' = '.var_export($structure, |
66
|
|
|
true).'; |
67
|
|
|
'; |
68
|
|
|
|
69
|
|
|
$syncer->addStatusMessage($pos.' of '.count(EvidenceList::$name).' '.$evidencePath.': actions obtained', |
70
|
|
|
'success'); |
71
|
|
|
} else { |
72
|
|
|
$syncer->addStatusMessage($pos.' of '.count(EvidenceList::$name).' '.$evidencePath.': obtaining actions problem', |
73
|
|
|
'error'); |
74
|
|
|
} |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
echo '} |
78
|
|
|
'; |
79
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.