@@ -55,9 +55,9 @@ discard block |
||
55 | 55 | { |
56 | 56 | foreach ($this->getAllTableNames() as $table_name) |
57 | 57 | { |
58 | - echo $table_name . "<br>"; |
|
58 | + echo $table_name."<br>"; |
|
59 | 59 | $tableInfo = $this->_dbMetaData->getTableInfo($table_name); |
60 | - echo "Table info:" . "<br>"; |
|
60 | + echo "Table info:"."<br>"; |
|
61 | 61 | echo "<pre>"; |
62 | 62 | print_r($tableInfo); |
63 | 63 | echo "</pre>"; |
@@ -82,6 +82,6 @@ discard block |
||
82 | 82 | |
83 | 83 | protected function eq($data) |
84 | 84 | { |
85 | - return '"' . $data . '"'; |
|
85 | + return '"'.$data.'"'; |
|
86 | 86 | } |
87 | 87 | } |
@@ -33,8 +33,9 @@ discard block |
||
33 | 33 | |
34 | 34 | public function __construct() |
35 | 35 | { |
36 | - if (!class_exists("TActiveRecordManager", false)) |
|
37 | - throw new Exception("You need to enable the ActiveRecord module in your application configuration file."); |
|
36 | + if (!class_exists("TActiveRecordManager", false)) { |
|
37 | + throw new Exception("You need to enable the ActiveRecord module in your application configuration file."); |
|
38 | + } |
|
38 | 39 | $ar_manager = TActiveRecordManager::getInstance(); |
39 | 40 | $_conn = $ar_manager->getDbConnection(); |
40 | 41 | $_conn->Active = true; |
@@ -44,10 +45,12 @@ discard block |
||
44 | 45 | public function setOpFile($op_file_namespace) |
45 | 46 | { |
46 | 47 | $op_file = Prado::getPathOfNamespace($op_file_namespace); |
47 | - if (empty($op_file)) |
|
48 | - throw new Exception("You need to fix your output folder namespace."); |
|
49 | - if (!is_dir($op_file)) |
|
50 | - mkdir($op_file, 0777, true); |
|
48 | + if (empty($op_file)) { |
|
49 | + throw new Exception("You need to fix your output folder namespace."); |
|
50 | + } |
|
51 | + if (!is_dir($op_file)) { |
|
52 | + mkdir($op_file, 0777, true); |
|
53 | + } |
|
51 | 54 | $this->_opFile = $op_file; |
52 | 55 | } |
53 | 56 | |
@@ -68,8 +71,9 @@ discard block |
||
68 | 71 | { |
69 | 72 | $tableNames = $this->_dbMetaData->findTableNames(); |
70 | 73 | $index = array_search('pradocache', $tableNames); |
71 | - if ($index) |
|
72 | - array_splice($tableNames, $index, 1); |
|
74 | + if ($index) { |
|
75 | + array_splice($tableNames, $index, 1); |
|
76 | + } |
|
73 | 77 | return $tableNames; |
74 | 78 | } |
75 | 79 |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | private function _commonGenerate($tableName, $tableInfo) |
138 | 138 | { |
139 | 139 | if (count($tableInfo->getColumns()) === 0) |
140 | - throw new Exception("Unable to find table or view $tableName in " . $this->_dbMetaData->getDbConnection()->getConnectionString() . "."); |
|
140 | + throw new Exception("Unable to find table or view $tableName in ".$this->_dbMetaData->getDbConnection()->getConnectionString()."."); |
|
141 | 141 | else |
142 | 142 | { |
143 | 143 | $properties = []; |
@@ -148,7 +148,7 @@ discard block |
||
148 | 148 | |
149 | 149 | $clasName = $this->_getProperClassName($tableName); |
150 | 150 | $class = $this->generateClass($properties, $tableName, $clasName, $toString); |
151 | - $output = $this->_opFile . DIRECTORY_SEPARATOR . $clasName . ".php"; |
|
151 | + $output = $this->_opFile.DIRECTORY_SEPARATOR.$clasName.".php"; |
|
152 | 152 | file_put_contents($output, $class); |
153 | 153 | } |
154 | 154 | |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | { |
157 | 157 | $table_name_words = str_replace("_", " ", strtolower($tableName)); |
158 | 158 | $final_conversion = str_replace(" ", "", ucwords($table_name_words)); |
159 | - return $this->_clasPrefix . $final_conversion . $this->_classSufix; |
|
159 | + return $this->_clasPrefix.$final_conversion.$this->_classSufix; |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | //----------------------------------------------------------------------------- |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | protected function generateProperty($field, $metadata) |
165 | 165 | { |
166 | 166 | $prop = ''; |
167 | - $name = '$' . $field; |
|
167 | + $name = '$'.$field; |
|
168 | 168 | |
169 | 169 | /* TODO use in version 2.0 */ |
170 | 170 | // $type = $column->getPHPType(); |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | |
181 | 181 | $code = "\tpublic static \$RELATIONS = array ("; |
182 | 182 | foreach ($this->_relations[$tablename] as $rel_data) |
183 | - $code .= "\n\t\t'" . $rel_data["prop_name"] . "' => array(" . $rel_data["rel_type"] . ", '" . $rel_data["ref_class_name"] . "', '" . $rel_data["prop_ref"] . "'),"; |
|
183 | + $code .= "\n\t\t'".$rel_data["prop_name"]."' => array(".$rel_data["rel_type"].", '".$rel_data["ref_class_name"]."', '".$rel_data["prop_ref"]."'),"; |
|
184 | 184 | |
185 | 185 | $code = substr($code, 0, -1); |
186 | 186 | $code .= "\n\t);"; |
@@ -71,8 +71,10 @@ discard block |
||
71 | 71 | if (!empty($this->_relations)) |
72 | 72 | { |
73 | 73 | // Cancel generation of M-M relationships middle table |
74 | - if (count($tableInfo->getPrimaryKeys()) === 2 && count($tableInfo->getColumns()) === 2)//M-M relationships |
|
74 | + if (count($tableInfo->getPrimaryKeys()) === 2 && count($tableInfo->getColumns()) === 2) { |
|
75 | + //M-M relationships |
|
75 | 76 | continue; |
77 | + } |
|
76 | 78 | } |
77 | 79 | $this->_commonGenerate($tableName, $tableInfo); |
78 | 80 | } |
@@ -87,9 +89,11 @@ discard block |
||
87 | 89 | $pks = $tableInfo->getPrimaryKeys(); |
88 | 90 | $fks = $tableInfo->getForeignKeys(); |
89 | 91 | |
90 | - if (count($pks) === 2 && count($tableInfo->getColumns()) === 2)//M-M relationships |
|
92 | + if (count($pks) === 2 && count($tableInfo->getColumns()) === 2) { |
|
93 | + //M-M relationships |
|
91 | 94 | { |
92 | 95 | $table_name_mm = $fks[0]["table"]; |
96 | + } |
|
93 | 97 | $table_name_mm2 = $fks[1]["table"]; |
94 | 98 | |
95 | 99 | $this->_relations[$table_name_mm][] = [ |
@@ -107,9 +111,11 @@ discard block |
||
107 | 111 | ]; |
108 | 112 | continue; |
109 | 113 | } |
110 | - foreach ($fks as $fk_data)//1-M relationships |
|
114 | + foreach ($fks as $fk_data) { |
|
115 | + //1-M relationships |
|
111 | 116 | { |
112 | 117 | $owner_table = $fk_data["table"]; |
118 | + } |
|
113 | 119 | $slave_table = $table_name; |
114 | 120 | $fk_prop = key($fk_data["keys"]); |
115 | 121 | |
@@ -136,13 +142,14 @@ discard block |
||
136 | 142 | |
137 | 143 | private function _commonGenerate($tableName, $tableInfo) |
138 | 144 | { |
139 | - if (count($tableInfo->getColumns()) === 0) |
|
140 | - throw new Exception("Unable to find table or view $tableName in " . $this->_dbMetaData->getDbConnection()->getConnectionString() . "."); |
|
141 | - else |
|
145 | + if (count($tableInfo->getColumns()) === 0) { |
|
146 | + throw new Exception("Unable to find table or view $tableName in " . $this->_dbMetaData->getDbConnection()->getConnectionString() . "."); |
|
147 | + } else |
|
142 | 148 | { |
143 | 149 | $properties = []; |
144 | - foreach ($tableInfo->getColumns() as $field => $metadata) |
|
145 | - $properties[] = $this->generateProperty($field, $metadata); |
|
150 | + foreach ($tableInfo->getColumns() as $field => $metadata) { |
|
151 | + $properties[] = $this->generateProperty($field, $metadata); |
|
152 | + } |
|
146 | 153 | $toString = $this->_buildSmartToString($tableInfo); |
147 | 154 | } |
148 | 155 | |
@@ -175,12 +182,14 @@ discard block |
||
175 | 182 | |
176 | 183 | private function _renderRelations($tablename) |
177 | 184 | { |
178 | - if (!isset($this->_relations[$tablename])) |
|
179 | - return ""; |
|
185 | + if (!isset($this->_relations[$tablename])) { |
|
186 | + return ""; |
|
187 | + } |
|
180 | 188 | |
181 | 189 | $code = "\tpublic static \$RELATIONS = array ("; |
182 | - foreach ($this->_relations[$tablename] as $rel_data) |
|
183 | - $code .= "\n\t\t'" . $rel_data["prop_name"] . "' => array(" . $rel_data["rel_type"] . ", '" . $rel_data["ref_class_name"] . "', '" . $rel_data["prop_ref"] . "'),"; |
|
190 | + foreach ($this->_relations[$tablename] as $rel_data) { |
|
191 | + $code .= "\n\t\t'" . $rel_data["prop_name"] . "' => array(" . $rel_data["rel_type"] . ", '" . $rel_data["ref_class_name"] . "', '" . $rel_data["prop_ref"] . "'),"; |
|
192 | + } |
|
184 | 193 | |
185 | 194 | $code = substr($code, 0, -1); |
186 | 195 | $code .= "\n\t);"; |
@@ -195,9 +204,9 @@ discard block |
||
195 | 204 | { |
196 | 205 | foreach ($tableInfo->getColumns() as $column) |
197 | 206 | { |
198 | - if (isset($column->IsPrimaryKey) && $column->IsPrimaryKey) |
|
199 | - $property = str_replace($this->uqChars, "", $column->ColumnName); |
|
200 | - elseif ($column->PdoType == PDO::PARAM_STR && $column->DBType != "date") |
|
207 | + if (isset($column->IsPrimaryKey) && $column->IsPrimaryKey) { |
|
208 | + $property = str_replace($this->uqChars, "", $column->ColumnName); |
|
209 | + } elseif ($column->PdoType == PDO::PARAM_STR && $column->DBType != "date") |
|
201 | 210 | { |
202 | 211 | $property = str_replace($this->uqChars, "", $column->ColumnName); |
203 | 212 | break; |
@@ -48,11 +48,13 @@ |
||
48 | 48 | |
49 | 49 | public function init($config) |
50 | 50 | { |
51 | - if ($this->getApplication()->getMode() === TApplicationMode::Performance || $this->getApplication()->getMode() === TApplicationMode::Normal) |
|
52 | - throw new TInvalidOperationException("You should not use Prado WSAT in any of the production modes."); |
|
51 | + if ($this->getApplication()->getMode() === TApplicationMode::Performance || $this->getApplication()->getMode() === TApplicationMode::Normal) { |
|
52 | + throw new TInvalidOperationException("You should not use Prado WSAT in any of the production modes."); |
|
53 | + } |
|
53 | 54 | |
54 | - if (empty($this->_pass)) |
|
55 | - throw new TConfigurationException("You need to specify the Password attribute."); |
|
55 | + if (empty($this->_pass)) { |
|
56 | + throw new TConfigurationException("You need to specify the Password attribute."); |
|
57 | + } |
|
56 | 58 | |
57 | 59 | $this->setDefaultPage("TWsatHome"); |
58 | 60 | $this->_startThemeManager(); |
@@ -37,13 +37,15 @@ |
||
37 | 37 | $ar_generator->setClasPrefix($classPrefix); |
38 | 38 | $ar_generator->setClassSufix($classSuffix); |
39 | 39 | |
40 | - if ($this->build_rel->Checked) |
|
41 | - $ar_generator->buildRelations(); |
|
40 | + if ($this->build_rel->Checked) { |
|
41 | + $ar_generator->buildRelations(); |
|
42 | + } |
|
42 | 43 | |
43 | - if ($tableName != "*") |
|
44 | - $ar_generator->generate($tableName); |
|
45 | - else |
|
46 | - $ar_generator->generateAll(); |
|
44 | + if ($tableName != "*") { |
|
45 | + $ar_generator->generate($tableName); |
|
46 | + } else { |
|
47 | + $ar_generator->generateAll(); |
|
48 | + } |
|
47 | 49 | |
48 | 50 | $this->feedback_panel->CssClass = "green_panel"; |
49 | 51 | $this->generation_msg->Text = "The code has been generated successfully."; |
@@ -58,7 +58,7 @@ |
||
58 | 58 | { |
59 | 59 | $id = "cb_$tableName"; |
60 | 60 | $obj = $this->tableNames->findControl($id); |
61 | - if($obj !== null && $obj->Checked) |
|
61 | + if ($obj !== null && $obj->Checked) |
|
62 | 62 | { |
63 | 63 | $scf_generator->generateCRUD($tableName); |
64 | 64 | } |
@@ -53,23 +53,23 @@ |
||
53 | 53 | { |
54 | 54 | default: |
55 | 55 | case self::LIST_TYPE: |
56 | - $unitName = "list" . ucfirst($tableName); |
|
56 | + $unitName = "list".ucfirst($tableName); |
|
57 | 57 | break; |
58 | 58 | |
59 | 59 | case self::ADD_TYPE: |
60 | - $unitName = "add" . ucfirst($tableName); |
|
60 | + $unitName = "add".ucfirst($tableName); |
|
61 | 61 | break; |
62 | 62 | |
63 | 63 | case self::SHOW_TYPE: |
64 | - $unitName = "show" . ucfirst($tableName); |
|
64 | + $unitName = "show".ucfirst($tableName); |
|
65 | 65 | break; |
66 | 66 | } |
67 | 67 | |
68 | 68 | $class = $this->generateClass($unitName); |
69 | - $outputClass = $this->_opFile . DIRECTORY_SEPARATOR . $unitName . ".php"; |
|
69 | + $outputClass = $this->_opFile.DIRECTORY_SEPARATOR.$unitName.".php"; |
|
70 | 70 | file_put_contents($outputClass, $class); |
71 | 71 | |
72 | - $outputPage = $this->_opFile . DIRECTORY_SEPARATOR . $unitName . ".page"; |
|
72 | + $outputPage = $this->_opFile.DIRECTORY_SEPARATOR.$unitName.".page"; |
|
73 | 73 | $page = $this->generatePage($tableName, $viewType); |
74 | 74 | file_put_contents($outputPage, $page); |
75 | 75 | } |
@@ -98,10 +98,10 @@ |
||
98 | 98 | */ |
99 | 99 | public function publishAsset($assetPath, $className = null) |
100 | 100 | { |
101 | - if($className === null) |
|
101 | + if ($className === null) |
|
102 | 102 | $className = get_class($this); |
103 | 103 | $class = new \ReflectionClass($className); |
104 | - $fullPath = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . $assetPath; |
|
104 | + $fullPath = dirname($class->getFileName()).DIRECTORY_SEPARATOR.$assetPath; |
|
105 | 105 | return $this->publishFilePath($fullPath); |
106 | 106 | } |
107 | 107 |
@@ -98,8 +98,9 @@ |
||
98 | 98 | */ |
99 | 99 | public function publishAsset($assetPath, $className = null) |
100 | 100 | { |
101 | - if($className === null) |
|
102 | - $className = get_class($this); |
|
101 | + if($className === null) { |
|
102 | + $className = get_class($this); |
|
103 | + } |
|
103 | 104 | $class = new \ReflectionClass($className); |
104 | 105 | $fullPath = dirname($class->getFileName()) . DIRECTORY_SEPARATOR . $assetPath; |
105 | 106 | return $this->publishFilePath($fullPath); |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function loadFromFile($fname) |
68 | 68 | { |
69 | - if(Prado::getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) |
|
69 | + if (Prado::getApplication()->getConfigurationType() == TApplication::CONFIG_TYPE_PHP) |
|
70 | 70 | { |
71 | 71 | $fcontent = include $fname; |
72 | 72 | $this->loadFromPhp($fcontent, dirname($fname)); |
@@ -95,28 +95,28 @@ discard block |
||
95 | 95 | public function loadFromPhp($config, $configPath) |
96 | 96 | { |
97 | 97 | // application properties |
98 | - if(isset($config['application'])) |
|
98 | + if (isset($config['application'])) |
|
99 | 99 | { |
100 | - foreach($config['application'] as $name => $value) |
|
100 | + foreach ($config['application'] as $name => $value) |
|
101 | 101 | { |
102 | 102 | $this->_properties[$name] = $value; |
103 | 103 | } |
104 | 104 | $this->_empty = false; |
105 | 105 | } |
106 | 106 | |
107 | - if(isset($config['paths']) && is_array($config['paths'])) |
|
107 | + if (isset($config['paths']) && is_array($config['paths'])) |
|
108 | 108 | $this->loadPathsPhp($config['paths'], $configPath); |
109 | 109 | |
110 | - if(isset($config['modules']) && is_array($config['modules'])) |
|
110 | + if (isset($config['modules']) && is_array($config['modules'])) |
|
111 | 111 | $this->loadModulesPhp($config['modules'], $configPath); |
112 | 112 | |
113 | - if(isset($config['services']) && is_array($config['services'])) |
|
113 | + if (isset($config['services']) && is_array($config['services'])) |
|
114 | 114 | $this->loadServicesPhp($config['services'], $configPath); |
115 | 115 | |
116 | - if(isset($config['parameters']) && is_array($config['parameters'])) |
|
116 | + if (isset($config['parameters']) && is_array($config['parameters'])) |
|
117 | 117 | $this->loadParametersPhp($config['parameters'], $configPath); |
118 | 118 | |
119 | - if(isset($config['includes']) && is_array($config['includes'])) |
|
119 | + if (isset($config['includes']) && is_array($config['includes'])) |
|
120 | 120 | $this->loadExternalXml($config['includes'], $configPath); |
121 | 121 | } |
122 | 122 | |
@@ -128,15 +128,15 @@ discard block |
||
128 | 128 | public function loadFromXml($dom, $configPath) |
129 | 129 | { |
130 | 130 | // application properties |
131 | - foreach($dom->getAttributes() as $name => $value) |
|
131 | + foreach ($dom->getAttributes() as $name => $value) |
|
132 | 132 | { |
133 | 133 | $this->_properties[$name] = $value; |
134 | 134 | $this->_empty = false; |
135 | 135 | } |
136 | 136 | |
137 | - foreach($dom->getElements() as $element) |
|
137 | + foreach ($dom->getElements() as $element) |
|
138 | 138 | { |
139 | - switch($element->getTagName()) |
|
139 | + switch ($element->getTagName()) |
|
140 | 140 | { |
141 | 141 | case 'paths': |
142 | 142 | $this->loadPathsXml($element, $configPath); |
@@ -167,26 +167,26 @@ discard block |
||
167 | 167 | */ |
168 | 168 | protected function loadPathsPhp($pathsNode, $configPath) |
169 | 169 | { |
170 | - if(isset($pathsNode['aliases']) && is_array($pathsNode['aliases'])) |
|
170 | + if (isset($pathsNode['aliases']) && is_array($pathsNode['aliases'])) |
|
171 | 171 | { |
172 | - foreach($pathsNode['aliases'] as $id => $path) |
|
172 | + foreach ($pathsNode['aliases'] as $id => $path) |
|
173 | 173 | { |
174 | 174 | $path = str_replace('\\', '/', $path); |
175 | - if(preg_match('/^\\/|.:\\/|.:\\\\/', $path)) // if absolute path |
|
175 | + if (preg_match('/^\\/|.:\\/|.:\\\\/', $path)) // if absolute path |
|
176 | 176 | $p = realpath($path); |
177 | 177 | else |
178 | - $p = realpath($configPath . DIRECTORY_SEPARATOR . $path); |
|
179 | - if($p === false || !is_dir($p)) |
|
178 | + $p = realpath($configPath.DIRECTORY_SEPARATOR.$path); |
|
179 | + if ($p === false || !is_dir($p)) |
|
180 | 180 | throw new TConfigurationException('appconfig_aliaspath_invalid', $id, $path); |
181 | - if(isset($this->_aliases[$id])) |
|
181 | + if (isset($this->_aliases[$id])) |
|
182 | 182 | throw new TConfigurationException('appconfig_alias_redefined', $id); |
183 | 183 | $this->_aliases[$id] = $p; |
184 | 184 | } |
185 | 185 | } |
186 | 186 | |
187 | - if(isset($pathsNode['using']) && is_array($pathsNode['using'])) |
|
187 | + if (isset($pathsNode['using']) && is_array($pathsNode['using'])) |
|
188 | 188 | { |
189 | - foreach($pathsNode['using'] as $namespace) |
|
189 | + foreach ($pathsNode['using'] as $namespace) |
|
190 | 190 | { |
191 | 191 | $this->_usings[] = $namespace; |
192 | 192 | } |
@@ -200,22 +200,22 @@ discard block |
||
200 | 200 | */ |
201 | 201 | protected function loadPathsXml($pathsNode, $configPath) |
202 | 202 | { |
203 | - foreach($pathsNode->getElements() as $element) |
|
203 | + foreach ($pathsNode->getElements() as $element) |
|
204 | 204 | { |
205 | - switch($element->getTagName()) |
|
205 | + switch ($element->getTagName()) |
|
206 | 206 | { |
207 | 207 | case 'alias': |
208 | 208 | { |
209 | - if(($id = $element->getAttribute('id')) !== null && ($path = $element->getAttribute('path')) !== null) |
|
209 | + if (($id = $element->getAttribute('id')) !== null && ($path = $element->getAttribute('path')) !== null) |
|
210 | 210 | { |
211 | 211 | $path = str_replace('\\', '/', $path); |
212 | - if(preg_match('/^\\/|.:\\/|.:\\\\/', $path)) // if absolute path |
|
212 | + if (preg_match('/^\\/|.:\\/|.:\\\\/', $path)) // if absolute path |
|
213 | 213 | $p = realpath($path); |
214 | 214 | else |
215 | - $p = realpath($configPath . DIRECTORY_SEPARATOR . $path); |
|
216 | - if($p === false || !is_dir($p)) |
|
215 | + $p = realpath($configPath.DIRECTORY_SEPARATOR.$path); |
|
216 | + if ($p === false || !is_dir($p)) |
|
217 | 217 | throw new TConfigurationException('appconfig_aliaspath_invalid', $id, $path); |
218 | - if(isset($this->_aliases[$id])) |
|
218 | + if (isset($this->_aliases[$id])) |
|
219 | 219 | throw new TConfigurationException('appconfig_alias_redefined', $id); |
220 | 220 | $this->_aliases[$id] = $p; |
221 | 221 | } |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | } |
227 | 227 | case 'using': |
228 | 228 | { |
229 | - if(($namespace = $element->getAttribute('namespace')) !== null) |
|
229 | + if (($namespace = $element->getAttribute('namespace')) !== null) |
|
230 | 230 | $this->_usings[] = $namespace; |
231 | 231 | else |
232 | 232 | throw new TConfigurationException('appconfig_using_invalid'); |
@@ -246,20 +246,20 @@ discard block |
||
246 | 246 | */ |
247 | 247 | protected function loadModulesPhp($modulesNode, $configPath) |
248 | 248 | { |
249 | - foreach($modulesNode as $id => $module) |
|
249 | + foreach ($modulesNode as $id => $module) |
|
250 | 250 | { |
251 | - if(!isset($module['class'])) |
|
251 | + if (!isset($module['class'])) |
|
252 | 252 | throw new TConfigurationException('appconfig_moduletype_required', $id); |
253 | 253 | $type = $module['class']; |
254 | 254 | unset($module['class']); |
255 | 255 | $properties = []; |
256 | - if(isset($module['properties'])) |
|
256 | + if (isset($module['properties'])) |
|
257 | 257 | { |
258 | 258 | $properties = $module['properties']; |
259 | 259 | unset($module['properties']); |
260 | 260 | } |
261 | 261 | $properties['id'] = $id; |
262 | - $this->_modules[$id] = [$type,$properties,$module]; |
|
262 | + $this->_modules[$id] = [$type, $properties, $module]; |
|
263 | 263 | $this->_empty = false; |
264 | 264 | } |
265 | 265 | } |
@@ -271,20 +271,20 @@ discard block |
||
271 | 271 | */ |
272 | 272 | protected function loadModulesXml($modulesNode, $configPath) |
273 | 273 | { |
274 | - foreach($modulesNode->getElements() as $element) |
|
274 | + foreach ($modulesNode->getElements() as $element) |
|
275 | 275 | { |
276 | - if($element->getTagName() === 'module') |
|
276 | + if ($element->getTagName() === 'module') |
|
277 | 277 | { |
278 | 278 | $properties = $element->getAttributes(); |
279 | 279 | $id = $properties->itemAt('id'); |
280 | 280 | $type = $properties->remove('class'); |
281 | - if($type === null) |
|
281 | + if ($type === null) |
|
282 | 282 | throw new TConfigurationException('appconfig_moduletype_required', $id); |
283 | 283 | $element->setParent(null); |
284 | - if($id === null) |
|
285 | - $this->_modules[] = [$type,$properties->toArray(),$element]; |
|
284 | + if ($id === null) |
|
285 | + $this->_modules[] = [$type, $properties->toArray(), $element]; |
|
286 | 286 | else |
287 | - $this->_modules[$id] = [$type,$properties->toArray(),$element]; |
|
287 | + $this->_modules[$id] = [$type, $properties->toArray(), $element]; |
|
288 | 288 | $this->_empty = false; |
289 | 289 | } |
290 | 290 | else |
@@ -299,15 +299,15 @@ discard block |
||
299 | 299 | */ |
300 | 300 | protected function loadServicesPhp($servicesNode, $configPath) |
301 | 301 | { |
302 | - foreach($servicesNode as $id => $service) |
|
302 | + foreach ($servicesNode as $id => $service) |
|
303 | 303 | { |
304 | - if(!isset($service['class'])) |
|
304 | + if (!isset($service['class'])) |
|
305 | 305 | throw new TConfigurationException('appconfig_servicetype_required'); |
306 | 306 | $type = $service['class']; |
307 | 307 | $properties = isset($service['properties']) ? $service['properties'] : []; |
308 | 308 | unset($service['properties']); |
309 | 309 | $properties['id'] = $id; |
310 | - $this->_services[$id] = [$type,$properties,$service]; |
|
310 | + $this->_services[$id] = [$type, $properties, $service]; |
|
311 | 311 | $this->_empty = false; |
312 | 312 | } |
313 | 313 | } |
@@ -319,17 +319,17 @@ discard block |
||
319 | 319 | */ |
320 | 320 | protected function loadServicesXml($servicesNode, $configPath) |
321 | 321 | { |
322 | - foreach($servicesNode->getElements() as $element) |
|
322 | + foreach ($servicesNode->getElements() as $element) |
|
323 | 323 | { |
324 | - if($element->getTagName() === 'service') |
|
324 | + if ($element->getTagName() === 'service') |
|
325 | 325 | { |
326 | 326 | $properties = $element->getAttributes(); |
327 | - if(($id = $properties->itemAt('id')) === null) |
|
327 | + if (($id = $properties->itemAt('id')) === null) |
|
328 | 328 | throw new TConfigurationException('appconfig_serviceid_required'); |
329 | - if(($type = $properties->remove('class')) === null) |
|
329 | + if (($type = $properties->remove('class')) === null) |
|
330 | 330 | throw new TConfigurationException('appconfig_servicetype_required', $id); |
331 | 331 | $element->setParent(null); |
332 | - $this->_services[$id] = [$type,$properties->toArray(),$element]; |
|
332 | + $this->_services[$id] = [$type, $properties->toArray(), $element]; |
|
333 | 333 | $this->_empty = false; |
334 | 334 | } |
335 | 335 | else |
@@ -344,17 +344,17 @@ discard block |
||
344 | 344 | */ |
345 | 345 | protected function loadParametersPhp($parametersNode, $configPath) |
346 | 346 | { |
347 | - foreach($parametersNode as $id => $parameter) |
|
347 | + foreach ($parametersNode as $id => $parameter) |
|
348 | 348 | { |
349 | - if(is_array($parameter)) |
|
349 | + if (is_array($parameter)) |
|
350 | 350 | { |
351 | - if(isset($parameter['class'])) |
|
351 | + if (isset($parameter['class'])) |
|
352 | 352 | { |
353 | 353 | $type = $parameter['class']; |
354 | 354 | unset($parameter['class']); |
355 | 355 | $properties = isset($service['properties']) ? $service['properties'] : []; |
356 | 356 | $properties['id'] = $id; |
357 | - $this->_parameters[$id] = [$type,$properties]; |
|
357 | + $this->_parameters[$id] = [$type, $properties]; |
|
358 | 358 | } |
359 | 359 | } |
360 | 360 | else |
@@ -371,22 +371,22 @@ discard block |
||
371 | 371 | */ |
372 | 372 | protected function loadParametersXml($parametersNode, $configPath) |
373 | 373 | { |
374 | - foreach($parametersNode->getElements() as $element) |
|
374 | + foreach ($parametersNode->getElements() as $element) |
|
375 | 375 | { |
376 | - if($element->getTagName() === 'parameter') |
|
376 | + if ($element->getTagName() === 'parameter') |
|
377 | 377 | { |
378 | 378 | $properties = $element->getAttributes(); |
379 | - if(($id = $properties->remove('id')) === null) |
|
379 | + if (($id = $properties->remove('id')) === null) |
|
380 | 380 | throw new TConfigurationException('appconfig_parameterid_required'); |
381 | - if(($type = $properties->remove('class')) === null) |
|
381 | + if (($type = $properties->remove('class')) === null) |
|
382 | 382 | { |
383 | - if(($value = $properties->remove('value')) === null) |
|
383 | + if (($value = $properties->remove('value')) === null) |
|
384 | 384 | $this->_parameters[$id] = $element; |
385 | 385 | else |
386 | 386 | $this->_parameters[$id] = $value; |
387 | 387 | } |
388 | 388 | else |
389 | - $this->_parameters[$id] = [$type,$properties->toArray()]; |
|
389 | + $this->_parameters[$id] = [$type, $properties->toArray()]; |
|
390 | 390 | $this->_empty = false; |
391 | 391 | } |
392 | 392 | else |
@@ -401,14 +401,14 @@ discard block |
||
401 | 401 | */ |
402 | 402 | protected function loadExternalPhp($includeNode, $configPath) |
403 | 403 | { |
404 | - foreach($includeNode as $include) |
|
404 | + foreach ($includeNode as $include) |
|
405 | 405 | { |
406 | - $when = isset($include['when'])?true:false; |
|
407 | - if(!isset($include['file'])) |
|
406 | + $when = isset($include['when']) ?true:false; |
|
407 | + if (!isset($include['file'])) |
|
408 | 408 | throw new TConfigurationException('appconfig_includefile_required'); |
409 | 409 | $filePath = $include['file']; |
410 | - if(isset($this->_includes[$filePath])) |
|
411 | - $this->_includes[$filePath] = '(' . $this->_includes[$filePath] . ') || (' . $when . ')'; |
|
410 | + if (isset($this->_includes[$filePath])) |
|
411 | + $this->_includes[$filePath] = '('.$this->_includes[$filePath].') || ('.$when.')'; |
|
412 | 412 | else |
413 | 413 | $$this->_includes[$filePath] = $when; |
414 | 414 | $this->_empty = false; |
@@ -422,12 +422,12 @@ discard block |
||
422 | 422 | */ |
423 | 423 | protected function loadExternalXml($includeNode, $configPath) |
424 | 424 | { |
425 | - if(($when = $includeNode->getAttribute('when')) === null) |
|
425 | + if (($when = $includeNode->getAttribute('when')) === null) |
|
426 | 426 | $when = true; |
427 | - if(($filePath = $includeNode->getAttribute('file')) === null) |
|
427 | + if (($filePath = $includeNode->getAttribute('file')) === null) |
|
428 | 428 | throw new TConfigurationException('appconfig_includefile_required'); |
429 | - if(isset($this->_includes[$filePath])) |
|
430 | - $this->_includes[$filePath] = '(' . $this->_includes[$filePath] . ') || (' . $when . ')'; |
|
429 | + if (isset($this->_includes[$filePath])) |
|
430 | + $this->_includes[$filePath] = '('.$this->_includes[$filePath].') || ('.$when.')'; |
|
431 | 431 | else |
432 | 432 | $this->_includes[$filePath] = $when; |
433 | 433 | $this->_empty = false; |
@@ -70,8 +70,7 @@ discard block |
||
70 | 70 | { |
71 | 71 | $fcontent = include $fname; |
72 | 72 | $this->loadFromPhp($fcontent, dirname($fname)); |
73 | - } |
|
74 | - else |
|
73 | + } else |
|
75 | 74 | { |
76 | 75 | $dom = new TXmlDocument; |
77 | 76 | $dom->loadFromFile($fname); |
@@ -104,20 +103,25 @@ discard block |
||
104 | 103 | $this->_empty = false; |
105 | 104 | } |
106 | 105 | |
107 | - if(isset($config['paths']) && is_array($config['paths'])) |
|
108 | - $this->loadPathsPhp($config['paths'], $configPath); |
|
106 | + if(isset($config['paths']) && is_array($config['paths'])) { |
|
107 | + $this->loadPathsPhp($config['paths'], $configPath); |
|
108 | + } |
|
109 | 109 | |
110 | - if(isset($config['modules']) && is_array($config['modules'])) |
|
111 | - $this->loadModulesPhp($config['modules'], $configPath); |
|
110 | + if(isset($config['modules']) && is_array($config['modules'])) { |
|
111 | + $this->loadModulesPhp($config['modules'], $configPath); |
|
112 | + } |
|
112 | 113 | |
113 | - if(isset($config['services']) && is_array($config['services'])) |
|
114 | - $this->loadServicesPhp($config['services'], $configPath); |
|
114 | + if(isset($config['services']) && is_array($config['services'])) { |
|
115 | + $this->loadServicesPhp($config['services'], $configPath); |
|
116 | + } |
|
115 | 117 | |
116 | - if(isset($config['parameters']) && is_array($config['parameters'])) |
|
117 | - $this->loadParametersPhp($config['parameters'], $configPath); |
|
118 | + if(isset($config['parameters']) && is_array($config['parameters'])) { |
|
119 | + $this->loadParametersPhp($config['parameters'], $configPath); |
|
120 | + } |
|
118 | 121 | |
119 | - if(isset($config['includes']) && is_array($config['includes'])) |
|
120 | - $this->loadExternalXml($config['includes'], $configPath); |
|
122 | + if(isset($config['includes']) && is_array($config['includes'])) { |
|
123 | + $this->loadExternalXml($config['includes'], $configPath); |
|
124 | + } |
|
121 | 125 | } |
122 | 126 | |
123 | 127 | /** |
@@ -172,14 +176,18 @@ discard block |
||
172 | 176 | foreach($pathsNode['aliases'] as $id => $path) |
173 | 177 | { |
174 | 178 | $path = str_replace('\\', '/', $path); |
175 | - if(preg_match('/^\\/|.:\\/|.:\\\\/', $path)) // if absolute path |
|
179 | + if(preg_match('/^\\/|.:\\/|.:\\\\/', $path)) { |
|
180 | + // if absolute path |
|
176 | 181 | $p = realpath($path); |
177 | - else |
|
178 | - $p = realpath($configPath . DIRECTORY_SEPARATOR . $path); |
|
179 | - if($p === false || !is_dir($p)) |
|
180 | - throw new TConfigurationException('appconfig_aliaspath_invalid', $id, $path); |
|
181 | - if(isset($this->_aliases[$id])) |
|
182 | - throw new TConfigurationException('appconfig_alias_redefined', $id); |
|
182 | + } else { |
|
183 | + $p = realpath($configPath . DIRECTORY_SEPARATOR . $path); |
|
184 | + } |
|
185 | + if($p === false || !is_dir($p)) { |
|
186 | + throw new TConfigurationException('appconfig_aliaspath_invalid', $id, $path); |
|
187 | + } |
|
188 | + if(isset($this->_aliases[$id])) { |
|
189 | + throw new TConfigurationException('appconfig_alias_redefined', $id); |
|
190 | + } |
|
183 | 191 | $this->_aliases[$id] = $p; |
184 | 192 | } |
185 | 193 | } |
@@ -209,27 +217,32 @@ discard block |
||
209 | 217 | if(($id = $element->getAttribute('id')) !== null && ($path = $element->getAttribute('path')) !== null) |
210 | 218 | { |
211 | 219 | $path = str_replace('\\', '/', $path); |
212 | - if(preg_match('/^\\/|.:\\/|.:\\\\/', $path)) // if absolute path |
|
220 | + if(preg_match('/^\\/|.:\\/|.:\\\\/', $path)) { |
|
221 | + // if absolute path |
|
213 | 222 | $p = realpath($path); |
214 | - else |
|
215 | - $p = realpath($configPath . DIRECTORY_SEPARATOR . $path); |
|
216 | - if($p === false || !is_dir($p)) |
|
217 | - throw new TConfigurationException('appconfig_aliaspath_invalid', $id, $path); |
|
218 | - if(isset($this->_aliases[$id])) |
|
219 | - throw new TConfigurationException('appconfig_alias_redefined', $id); |
|
223 | + } else { |
|
224 | + $p = realpath($configPath . DIRECTORY_SEPARATOR . $path); |
|
225 | + } |
|
226 | + if($p === false || !is_dir($p)) { |
|
227 | + throw new TConfigurationException('appconfig_aliaspath_invalid', $id, $path); |
|
228 | + } |
|
229 | + if(isset($this->_aliases[$id])) { |
|
230 | + throw new TConfigurationException('appconfig_alias_redefined', $id); |
|
231 | + } |
|
220 | 232 | $this->_aliases[$id] = $p; |
233 | + } else { |
|
234 | + throw new TConfigurationException('appconfig_alias_invalid'); |
|
221 | 235 | } |
222 | - else |
|
223 | - throw new TConfigurationException('appconfig_alias_invalid'); |
|
224 | 236 | $this->_empty = false; |
225 | 237 | break; |
226 | 238 | } |
227 | 239 | case 'using': |
228 | 240 | { |
229 | - if(($namespace = $element->getAttribute('namespace')) !== null) |
|
230 | - $this->_usings[] = $namespace; |
|
231 | - else |
|
232 | - throw new TConfigurationException('appconfig_using_invalid'); |
|
241 | + if(($namespace = $element->getAttribute('namespace')) !== null) { |
|
242 | + $this->_usings[] = $namespace; |
|
243 | + } else { |
|
244 | + throw new TConfigurationException('appconfig_using_invalid'); |
|
245 | + } |
|
233 | 246 | $this->_empty = false; |
234 | 247 | break; |
235 | 248 | } |
@@ -248,8 +261,9 @@ discard block |
||
248 | 261 | { |
249 | 262 | foreach($modulesNode as $id => $module) |
250 | 263 | { |
251 | - if(!isset($module['class'])) |
|
252 | - throw new TConfigurationException('appconfig_moduletype_required', $id); |
|
264 | + if(!isset($module['class'])) { |
|
265 | + throw new TConfigurationException('appconfig_moduletype_required', $id); |
|
266 | + } |
|
253 | 267 | $type = $module['class']; |
254 | 268 | unset($module['class']); |
255 | 269 | $properties = []; |
@@ -278,17 +292,19 @@ discard block |
||
278 | 292 | $properties = $element->getAttributes(); |
279 | 293 | $id = $properties->itemAt('id'); |
280 | 294 | $type = $properties->remove('class'); |
281 | - if($type === null) |
|
282 | - throw new TConfigurationException('appconfig_moduletype_required', $id); |
|
295 | + if($type === null) { |
|
296 | + throw new TConfigurationException('appconfig_moduletype_required', $id); |
|
297 | + } |
|
283 | 298 | $element->setParent(null); |
284 | - if($id === null) |
|
285 | - $this->_modules[] = [$type,$properties->toArray(),$element]; |
|
286 | - else |
|
287 | - $this->_modules[$id] = [$type,$properties->toArray(),$element]; |
|
299 | + if($id === null) { |
|
300 | + $this->_modules[] = [$type,$properties->toArray(),$element]; |
|
301 | + } else { |
|
302 | + $this->_modules[$id] = [$type,$properties->toArray(),$element]; |
|
303 | + } |
|
288 | 304 | $this->_empty = false; |
305 | + } else { |
|
306 | + throw new TConfigurationException('appconfig_modules_invalid', $element->getTagName()); |
|
289 | 307 | } |
290 | - else |
|
291 | - throw new TConfigurationException('appconfig_modules_invalid', $element->getTagName()); |
|
292 | 308 | } |
293 | 309 | } |
294 | 310 | |
@@ -301,8 +317,9 @@ discard block |
||
301 | 317 | { |
302 | 318 | foreach($servicesNode as $id => $service) |
303 | 319 | { |
304 | - if(!isset($service['class'])) |
|
305 | - throw new TConfigurationException('appconfig_servicetype_required'); |
|
320 | + if(!isset($service['class'])) { |
|
321 | + throw new TConfigurationException('appconfig_servicetype_required'); |
|
322 | + } |
|
306 | 323 | $type = $service['class']; |
307 | 324 | $properties = isset($service['properties']) ? $service['properties'] : []; |
308 | 325 | unset($service['properties']); |
@@ -324,16 +341,18 @@ discard block |
||
324 | 341 | if($element->getTagName() === 'service') |
325 | 342 | { |
326 | 343 | $properties = $element->getAttributes(); |
327 | - if(($id = $properties->itemAt('id')) === null) |
|
328 | - throw new TConfigurationException('appconfig_serviceid_required'); |
|
329 | - if(($type = $properties->remove('class')) === null) |
|
330 | - throw new TConfigurationException('appconfig_servicetype_required', $id); |
|
344 | + if(($id = $properties->itemAt('id')) === null) { |
|
345 | + throw new TConfigurationException('appconfig_serviceid_required'); |
|
346 | + } |
|
347 | + if(($type = $properties->remove('class')) === null) { |
|
348 | + throw new TConfigurationException('appconfig_servicetype_required', $id); |
|
349 | + } |
|
331 | 350 | $element->setParent(null); |
332 | 351 | $this->_services[$id] = [$type,$properties->toArray(),$element]; |
333 | 352 | $this->_empty = false; |
353 | + } else { |
|
354 | + throw new TConfigurationException('appconfig_services_invalid', $element->getTagName()); |
|
334 | 355 | } |
335 | - else |
|
336 | - throw new TConfigurationException('appconfig_services_invalid', $element->getTagName()); |
|
337 | 356 | } |
338 | 357 | } |
339 | 358 | |
@@ -356,8 +375,7 @@ discard block |
||
356 | 375 | $properties['id'] = $id; |
357 | 376 | $this->_parameters[$id] = [$type,$properties]; |
358 | 377 | } |
359 | - } |
|
360 | - else |
|
378 | + } else |
|
361 | 379 | { |
362 | 380 | $this->_parameters[$id] = $parameter; |
363 | 381 | } |
@@ -376,21 +394,23 @@ discard block |
||
376 | 394 | if($element->getTagName() === 'parameter') |
377 | 395 | { |
378 | 396 | $properties = $element->getAttributes(); |
379 | - if(($id = $properties->remove('id')) === null) |
|
380 | - throw new TConfigurationException('appconfig_parameterid_required'); |
|
397 | + if(($id = $properties->remove('id')) === null) { |
|
398 | + throw new TConfigurationException('appconfig_parameterid_required'); |
|
399 | + } |
|
381 | 400 | if(($type = $properties->remove('class')) === null) |
382 | 401 | { |
383 | - if(($value = $properties->remove('value')) === null) |
|
384 | - $this->_parameters[$id] = $element; |
|
385 | - else |
|
386 | - $this->_parameters[$id] = $value; |
|
402 | + if(($value = $properties->remove('value')) === null) { |
|
403 | + $this->_parameters[$id] = $element; |
|
404 | + } else { |
|
405 | + $this->_parameters[$id] = $value; |
|
406 | + } |
|
407 | + } else { |
|
408 | + $this->_parameters[$id] = [$type,$properties->toArray()]; |
|
387 | 409 | } |
388 | - else |
|
389 | - $this->_parameters[$id] = [$type,$properties->toArray()]; |
|
390 | 410 | $this->_empty = false; |
411 | + } else { |
|
412 | + throw new TConfigurationException('appconfig_parameters_invalid', $element->getTagName()); |
|
391 | 413 | } |
392 | - else |
|
393 | - throw new TConfigurationException('appconfig_parameters_invalid', $element->getTagName()); |
|
394 | 414 | } |
395 | 415 | } |
396 | 416 | |
@@ -404,13 +424,15 @@ discard block |
||
404 | 424 | foreach($includeNode as $include) |
405 | 425 | { |
406 | 426 | $when = isset($include['when'])?true:false; |
407 | - if(!isset($include['file'])) |
|
408 | - throw new TConfigurationException('appconfig_includefile_required'); |
|
427 | + if(!isset($include['file'])) { |
|
428 | + throw new TConfigurationException('appconfig_includefile_required'); |
|
429 | + } |
|
409 | 430 | $filePath = $include['file']; |
410 | - if(isset($this->_includes[$filePath])) |
|
411 | - $this->_includes[$filePath] = '(' . $this->_includes[$filePath] . ') || (' . $when . ')'; |
|
412 | - else |
|
413 | - $$this->_includes[$filePath] = $when; |
|
431 | + if(isset($this->_includes[$filePath])) { |
|
432 | + $this->_includes[$filePath] = '(' . $this->_includes[$filePath] . ') || (' . $when . ')'; |
|
433 | + } else { |
|
434 | + $$this->_includes[$filePath] = $when; |
|
435 | + } |
|
414 | 436 | $this->_empty = false; |
415 | 437 | } |
416 | 438 | } |
@@ -422,14 +444,17 @@ discard block |
||
422 | 444 | */ |
423 | 445 | protected function loadExternalXml($includeNode, $configPath) |
424 | 446 | { |
425 | - if(($when = $includeNode->getAttribute('when')) === null) |
|
426 | - $when = true; |
|
427 | - if(($filePath = $includeNode->getAttribute('file')) === null) |
|
428 | - throw new TConfigurationException('appconfig_includefile_required'); |
|
429 | - if(isset($this->_includes[$filePath])) |
|
430 | - $this->_includes[$filePath] = '(' . $this->_includes[$filePath] . ') || (' . $when . ')'; |
|
431 | - else |
|
432 | - $this->_includes[$filePath] = $when; |
|
447 | + if(($when = $includeNode->getAttribute('when')) === null) { |
|
448 | + $when = true; |
|
449 | + } |
|
450 | + if(($filePath = $includeNode->getAttribute('file')) === null) { |
|
451 | + throw new TConfigurationException('appconfig_includefile_required'); |
|
452 | + } |
|
453 | + if(isset($this->_includes[$filePath])) { |
|
454 | + $this->_includes[$filePath] = '(' . $this->_includes[$filePath] . ') || (' . $when . ')'; |
|
455 | + } else { |
|
456 | + $this->_includes[$filePath] = $when; |
|
457 | + } |
|
433 | 458 | $this->_empty = false; |
434 | 459 | } |
435 | 460 |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | */ |
70 | 70 | public function current() |
71 | 71 | { |
72 | - return isset($_SESSION[$this->_key])?$_SESSION[$this->_key]:null; |
|
72 | + return isset($_SESSION[$this->_key]) ? $_SESSION[$this->_key] : null; |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | /** |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | { |
83 | 83 | $this->_key = next($this->_keys); |
84 | 84 | } |
85 | - while(!isset($_SESSION[$this->_key]) && $this->_key !== false); |
|
85 | + while (!isset($_SESSION[$this->_key]) && $this->_key !== false); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | /** |