1
|
|
|
<?php |
|
|
|
|
2
|
|
|
|
3
|
|
|
namespace FlexiPeeHP; |
4
|
|
|
|
5
|
|
|
require_once '../testing/bootstrap.php'; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Obtain structure for given evidence |
9
|
|
|
* |
10
|
|
|
* @param string $evidence |
11
|
|
|
* @param FlexiBeeRO $syncer Class to read from FlexiBee |
12
|
|
|
* @return array Evidence structure |
13
|
|
|
*/ |
14
|
|
View Code Duplication |
function getColumnsInfo($evidence, FlexiBeeRO $syncer) |
|
|
|
|
15
|
|
|
{ |
16
|
|
|
$useKeywords = []; |
17
|
|
|
$flexinfo = $syncer->performRequest($evidence.'/properties.json'); |
18
|
|
|
if (count($flexinfo) && array_key_exists('properties', $flexinfo)) { |
19
|
|
|
foreach ($flexinfo['properties']['property'] as $evidenceProperty) { |
20
|
|
|
$key = $evidenceProperty['propertyName']; |
21
|
|
|
$useKeywords[$key] = $evidenceProperty; |
22
|
|
|
$useKeywords[$key]['name'] = $evidenceProperty['name']; |
23
|
|
|
$useKeywords[$key]['type'] = $evidenceProperty['type']; |
24
|
|
|
} |
25
|
|
|
} |
26
|
|
|
return $useKeywords; |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
|
30
|
|
|
echo '<?php |
31
|
|
|
/** |
32
|
|
|
* FlexiPeeHP - Seznam Evidencí. |
33
|
|
|
* |
34
|
|
|
* @author Vítězslav Dvořák <[email protected]> |
35
|
|
|
* @copyright (C) 2016 Spoje.Net |
36
|
|
|
*/ |
37
|
|
|
|
38
|
|
|
namespace FlexiPeeHP; |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @link https://demo.flexibee.eu/c/demo/evidence-list Přehled evidencí |
42
|
|
|
*/ |
43
|
|
|
class EvidenceList extends FlexiBeeRO |
44
|
|
|
{ |
45
|
|
|
/** |
46
|
|
|
* Evidence užitá objektem. |
47
|
|
|
* |
48
|
|
|
* @var string |
49
|
|
|
*/ |
50
|
|
|
public $evidence = \'evidence-list\'; |
51
|
|
|
|
52
|
|
|
'; |
53
|
|
|
|
54
|
|
|
|
55
|
|
|
$syncer = new EvidenceList(); |
56
|
|
|
|
57
|
|
|
$evidencies = $syncer->getColumnsFromFlexibee(['evidencePath', 'evidenceName']); |
58
|
|
|
|
59
|
|
|
$evlist = []; |
60
|
|
|
foreach ($evidencies['evidences']['evidence'] as $evidenceID => $evidence) { |
61
|
|
|
$evlist[$evidence['evidencePath']] = $evidence['evidenceName']; |
62
|
|
|
$fullList[$evidence['evidencePath']] = $evidence; |
63
|
|
|
} |
64
|
|
|
echo ' /** |
65
|
|
|
* Evidences Path/Name listing. |
66
|
|
|
* |
67
|
|
|
* @var array |
68
|
|
|
*/ |
69
|
|
|
'; |
70
|
|
|
echo ' static public $name = '.var_export($evlist, true).'; |
71
|
|
|
|
72
|
|
|
'; |
73
|
|
|
echo ' /** |
74
|
|
|
* All Evidence\'s all properties listing. |
75
|
|
|
* |
76
|
|
|
* @var array |
77
|
|
|
*/ |
78
|
|
|
'; |
79
|
|
|
echo ' static public $evidences = '.var_export($fullList, true).'; |
80
|
|
|
|
81
|
|
|
'; |
82
|
|
|
|
83
|
|
|
echo '} |
84
|
|
|
'; |
85
|
|
|
|
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.