Issues (152)

tools/update_evidencelist_class.php (1 issue)

1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 5 and the first side effect is on line 8.

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.

Loading history...
2
3
namespace FlexiPeeHP;
4
5
define('EASE_APPNAME', 'FlexiPeehUP');
6
define('EASE_LOGGER', 'console|syslog');
7
8
require_once '../testing/bootstrap.php';
9
10
11
12
$outFile     = 'EvidenceList.php';
13
$outJson     = 'EvidenceList.json';
14
$outFullJson = 'EvidenceFullList.json';
15
16
/**
17
 * Obtain structure for given evidence
18
 *
19
 * @param string     $evidence
20
 * @param FlexiBeeRO $syncer Class to read from FlexiBee
21
 * @return array     Evidence structure
22
 */
23
function getColumnsInfo($evidence, FlexiBeeRO $syncer)
24
{
25
    $useKeywords = [];
26
    $flexinfo    = $syncer->performRequest($evidence.'/properties.json');
27
    if (count($flexinfo) && array_key_exists('properties', $flexinfo)) {
28
        foreach ($flexinfo['properties']['property'] as $evidenceProperty) {
29
            $key                       = $evidenceProperty['propertyName'];
30
            $useKeywords[$key]         = $evidenceProperty;
31
            $useKeywords[$key]['name'] = $evidenceProperty['name'];
32
            $useKeywords[$key]['type'] = $evidenceProperty['type'];
33
        }
34
    }
35
    return $useKeywords;
36
}
37
$statuser = new Status();
38
39
40
$evidenceList = '<?php
41
/**
42
 * FlexiPeeHP - List of Evidencies.
43
 *
44
 * Generated: '.date(DATE_RFC2822).' 
45
 * From:      '.$statuser->url.'
46
 *    
47
 * @author     Vítězslav Dvořák <[email protected]>
48
 * @copyright  (C) 2016-2017 Spoje.Net
49
 */
50
51
namespace FlexiPeeHP;
52
53
/**
54
 * Evidencies listing and its properties
55
 * Seznam Evidencí a jejich vlastnosti
56
 *
57
 * @link https://demo.flexibee.eu/c/demo/evidence-list Přehled evidencí
58
 */
59
class EvidenceList extends FlexiBeeRO
60
{
61
    /**
62
     * Evidence užitá objektem.
63
     *
64
     * @var string
65
     */
66
    public $evidence = \'evidence-list\';
67
68
    /**
69
     * Základní namespace pro komunikaci s FlexiBee.
70
     * Basic namespace for communication with FlexiBee
71
     *
72
     * @var string Jmený prostor datového bloku odpovědi
73
     */
74
    public $nameSpace = \'evidences\';
75
76
    /**
77
     * Column use to identfy record
78
     *
79
     * @var string
80
     */
81
    public $keyColumn = \'evidencePath\';
82
83
';
84
85
$evidenceList .= '    /**
86
     * Source FlexiBee server version.
87
     *
88
     * @var string
89
     */
90
';
91
$evidenceList .= ' static public $version = \''.$statuser->getDataValue('version').'\';
92
93
';
94
95
$syncer = new EvidenceList();
96
$syncer->addStatusMessage('Updating Evidences List');
97
98
$evidencies = $syncer->getColumnsFromFlexibee(['evidencePath', 'evidenceName']);
99
100
//Add Evidencies Forbidden on demo.FlexiBee.eu
101
$evidencies[] = [
102
    "evidenceType" => "NASTAVENI",
103
    "evidenceName" => "Nastavení",
104
    "evidencePath" => "nastaveni",
105
    "importStatus" => "NOT_DOCUMENTED",
106
    "className" => "cz.winstrom.vo.nast.Nastaveni",
107
    "formCode" => "nNastav"
108
];
109
110
$evidencies[] = [
111
    "evidenceType" => "UZIVATELE",
112
    "evidenceName" => "Osoby a uživatelé",
113
    "evidencePath" => "uzivatel",
114
    "importStatus" => "NOT_DOCUMENTED",
115
    "className" => "cz.winstrom.vo.w.Uzivatel",
116
    "formCode" => "cisOsoby"
117
];
118
119
120
$evlist = [];
121
foreach ($evidencies as $evidenceID => $evidence) {
122
    if (array_key_exists('evidencePath', $evidence)) {
123
        $evlist[$evidence['evidencePath']]   = $evidence['evidenceName'];
124
        $fullList[$evidence['evidencePath']] = $evidence;
125
    }
126
}
127
128
asort($evlist);
129
asort($fullList);
130
131
$evidenceList .= '    /**
132
     * Evidences Path/Name listing.
133
     *
134
     * @var array
135
     */
136
';
137
$evidenceList .= ' static public $name = '.var_export($evlist, true).';
138
139
';
140
$evidenceList .= '    /**
141
     * All Evidence\'s all properties listing.
142
     *
143
     * @var array
144
     */
145
';
146
$evidenceList .= ' static public $evidences = '.var_export($fullList, true).';
147
148
';
149
150
$evidenceList .= '
151
    /**
152
     * Obtain evidence identifier
153
     *
154
     * @return string company database name
155
     */
156
    public function getRecordID()
157
    {
158
        return $this->getDataValue(\'evidencePath\');
159
    }
160
    ';
161
162
163
$evidenceList .= '}
164
';
165
166
$syncer->addStatusMessage('Updating of '.count($fullList).' Evidences Infos done',
167
    'success');
168
file_put_contents($outFile, $evidenceList);
169
170
file_put_contents($outJson, json_encode($evlist));
171
172
file_put_contents($outFullJson, json_encode($fullList));
173
174