@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | /** |
137 | 137 | * @param \Classes\Db\DbTable|\Classes\Db\Constrant $table |
138 | 138 | * |
139 | - * @return mixed |
|
139 | + * @return string |
|
140 | 140 | */ |
141 | 141 | |
142 | 142 | public function createClassNamespace ( $table ) |
@@ -225,6 +225,9 @@ discard block |
||
225 | 225 | return true; |
226 | 226 | } |
227 | 227 | |
228 | + /** |
|
229 | + * @return string |
|
230 | + */ |
|
228 | 231 | protected function getFrameworkIni () |
229 | 232 | { |
230 | 233 | return $this->framworkFiles[ 'ini' ]; |
@@ -332,7 +335,6 @@ discard block |
||
332 | 335 | } |
333 | 336 | |
334 | 337 | /** |
335 | - * @param string $schema |
|
336 | 338 | * |
337 | 339 | * @return string |
338 | 340 | */ |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | abstract class AbstractAdapter |
15 | 15 | { |
16 | 16 | |
17 | - protected $arrConfig = array ( |
|
17 | + protected $arrConfig = array( |
|
18 | 18 | ############################# DATABASE |
19 | 19 | //Driver do banco de dados |
20 | 20 | 'driver' => null, |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | //senha do banco |
30 | 30 | 'password' => null, |
31 | 31 | // lista de schemas do banco de dados |
32 | - 'schema' => array (), |
|
32 | + 'schema' => array(), |
|
33 | 33 | |
34 | 34 | 'socket' => null, |
35 | 35 | |
@@ -61,13 +61,13 @@ discard block |
||
61 | 61 | // flags para criar todas as tabelas ou nao |
62 | 62 | 'allTables' => true, |
63 | 63 | //Lista de tabelas a serem ignoradas |
64 | - 'ignoreTable' => array (), |
|
64 | + 'ignoreTable' => array(), |
|
65 | 65 | ); |
66 | 66 | |
67 | 67 | /** |
68 | 68 | * @var string[] um array com todos os campos obrigatorios |
69 | 69 | */ |
70 | - protected $attRequered = array ( |
|
70 | + protected $attRequered = array( |
|
71 | 71 | 'driver' => true, |
72 | 72 | 'database' => true, |
73 | 73 | 'host' => true, |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | 'path' => true |
76 | 76 | ); |
77 | 77 | |
78 | - protected $arrFunc = array (); |
|
78 | + protected $arrFunc = array(); |
|
79 | 79 | |
80 | - private $framworkFiles = array (); |
|
80 | + private $framworkFiles = array(); |
|
81 | 81 | |
82 | - public $reservedWord = array (); |
|
82 | + public $reservedWord = array(); |
|
83 | 83 | |
84 | 84 | const SEPARETOR = ""; |
85 | 85 | |
@@ -88,9 +88,9 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @return bool |
90 | 90 | */ |
91 | - protected function checkConfig () |
|
91 | + protected function checkConfig() |
|
92 | 92 | { |
93 | - if ( array_diff_key ( $this->attRequered, array_filter ( $this->arrConfig ) ) ) { |
|
93 | + if (array_diff_key($this->attRequered, array_filter($this->arrConfig))) { |
|
94 | 94 | return false; |
95 | 95 | } |
96 | 96 | |
@@ -102,33 +102,33 @@ discard block |
||
102 | 102 | * |
103 | 103 | * @return array |
104 | 104 | */ |
105 | - abstract protected function getParams (); |
|
105 | + abstract protected function getParams(); |
|
106 | 106 | |
107 | 107 | /** |
108 | 108 | * Popula as config do generater com as configuraçoes do framework |
109 | 109 | * |
110 | 110 | * @return mixed |
111 | 111 | */ |
112 | - abstract protected function parseFrameworkConfig (); |
|
112 | + abstract protected function parseFrameworkConfig(); |
|
113 | 113 | |
114 | 114 | /** |
115 | 115 | * Cria Instancias dos arquivos que devem ser gerados |
116 | 116 | * |
117 | 117 | * @return \Classes\AdapterMakerFile\AbstractAdapter[] |
118 | 118 | */ |
119 | - abstract public function getMakeFileInstances (); |
|
119 | + abstract public function getMakeFileInstances(); |
|
120 | 120 | |
121 | - abstract protected function init (); |
|
121 | + abstract protected function init(); |
|
122 | 122 | |
123 | 123 | /** |
124 | 124 | * retorna a base do Namespace |
125 | 125 | * |
126 | 126 | * @return array |
127 | 127 | */ |
128 | - protected function getBaseNamespace () |
|
128 | + protected function getBaseNamespace() |
|
129 | 129 | { |
130 | - return array ( |
|
131 | - $this->arrConfig[ 'namespace' ], |
|
130 | + return array( |
|
131 | + $this->arrConfig['namespace'], |
|
132 | 132 | 'Model' |
133 | 133 | ); |
134 | 134 | } |
@@ -139,47 +139,47 @@ discard block |
||
139 | 139 | * @return mixed |
140 | 140 | */ |
141 | 141 | |
142 | - public function createClassNamespace ( $table ) |
|
142 | + public function createClassNamespace($table) |
|
143 | 143 | { |
144 | - $arrNames = $this->getBaseNamespace (); |
|
144 | + $arrNames = $this->getBaseNamespace(); |
|
145 | 145 | |
146 | - if ( isset( $this->arrConfig[ 'folder-database' ] ) |
|
147 | - && $this->arrConfig[ 'folder-database' ] |
|
146 | + if (isset($this->arrConfig['folder-database']) |
|
147 | + && $this->arrConfig['folder-database'] |
|
148 | 148 | ) { |
149 | - $arrNames[] = AbstractMaker::getClassName ( $this->arrConfig[ 'driver' ] ); |
|
149 | + $arrNames[] = AbstractMaker::getClassName($this->arrConfig['driver']); |
|
150 | 150 | } |
151 | 151 | |
152 | - if ( isset( $this->arrConfig[ 'folder-name' ] ) |
|
153 | - && $this->arrConfig[ 'folder-name' ] |
|
152 | + if (isset($this->arrConfig['folder-name']) |
|
153 | + && $this->arrConfig['folder-name'] |
|
154 | 154 | ) { |
155 | - $arrNames[] = AbstractMaker::getClassName ( $this->arrConfig[ 'folder-name' ] ); |
|
155 | + $arrNames[] = AbstractMaker::getClassName($this->arrConfig['folder-name']); |
|
156 | 156 | } |
157 | 157 | |
158 | - if ( $table->hasSchema () ) { |
|
159 | - $arrNames[] = $this->replaceReservedWord ( AbstractMaker::getClassName ( $table->getSchema () ) ); |
|
158 | + if ($table->hasSchema()) { |
|
159 | + $arrNames[] = $this->replaceReservedWord(AbstractMaker::getClassName($table->getSchema())); |
|
160 | 160 | } |
161 | 161 | else { |
162 | - $arrNames[] = $this->replaceReservedWord ( AbstractMaker::getClassName ( $table->getDatabase () ) ); |
|
162 | + $arrNames[] = $this->replaceReservedWord(AbstractMaker::getClassName($table->getDatabase())); |
|
163 | 163 | } |
164 | 164 | |
165 | - return implode ( static::SEPARETOR, array_filter ( $arrNames ) ); |
|
165 | + return implode(static::SEPARETOR, array_filter($arrNames)); |
|
166 | 166 | } |
167 | 167 | |
168 | - public function __construct ( $array ) |
|
168 | + public function __construct($array) |
|
169 | 169 | { |
170 | - $array += array ( |
|
171 | - 'author' => ucfirst ( get_current_user () ), |
|
172 | - 'last_modify' => date ( "d-m-Y H:i:s." ) |
|
170 | + $array += array( |
|
171 | + 'author' => ucfirst(get_current_user()), |
|
172 | + 'last_modify' => date("d-m-Y H:i:s.") |
|
173 | 173 | ); |
174 | 174 | |
175 | - $this->setFrameworkFiles ( $array ); |
|
176 | - $this->parseFrameworkConfig (); |
|
177 | - $this->setParams ( $this->getParams () ); |
|
178 | - $this->setParams ( $array ); |
|
179 | - $this->init (); |
|
180 | - if ( !$this->isValid () ) { |
|
181 | - $var = array_diff_key ( $this->attRequered, array_filter ( $this->arrConfig ) ); |
|
182 | - throw new Exception( $var ); |
|
175 | + $this->setFrameworkFiles($array); |
|
176 | + $this->parseFrameworkConfig(); |
|
177 | + $this->setParams($this->getParams()); |
|
178 | + $this->setParams($array); |
|
179 | + $this->init(); |
|
180 | + if ( ! $this->isValid()) { |
|
181 | + $var = array_diff_key($this->attRequered, array_filter($this->arrConfig)); |
|
182 | + throw new Exception($var); |
|
183 | 183 | } |
184 | 184 | } |
185 | 185 | |
@@ -188,36 +188,36 @@ discard block |
||
188 | 188 | * |
189 | 189 | * @param $array |
190 | 190 | */ |
191 | - public function setFrameworkFiles ( $array ) |
|
191 | + public function setFrameworkFiles($array) |
|
192 | 192 | { |
193 | - $this->framworkFiles[ 'library' ] = isset( $array[ 'framework-path-library' ] ) ? $array[ 'framework-path-library' ] : null; |
|
193 | + $this->framworkFiles['library'] = isset($array['framework-path-library']) ? $array['framework-path-library'] : null; |
|
194 | 194 | |
195 | - $this->framworkFiles[ 'ini' ] = isset( $array[ 'framework-ini' ] ) ? $array[ 'framework-ini' ] : null; |
|
195 | + $this->framworkFiles['ini'] = isset($array['framework-ini']) ? $array['framework-ini'] : null; |
|
196 | 196 | |
197 | - $this->framworkFiles[ 'environment' ] = isset( $array[ 'environment' ] ) ? $array[ 'environment' ] : 'production'; |
|
197 | + $this->framworkFiles['environment'] = isset($array['environment']) ? $array['environment'] : 'production'; |
|
198 | 198 | |
199 | 199 | } |
200 | 200 | |
201 | - protected function isValidFrameworkFiles () |
|
201 | + protected function isValidFrameworkFiles() |
|
202 | 202 | { |
203 | - if ( !is_file ( $this->framworkFiles[ 'ini' ] ) ) { |
|
203 | + if ( ! is_file($this->framworkFiles['ini'])) { |
|
204 | 204 | return false; |
205 | 205 | } |
206 | 206 | |
207 | - if ( !is_dir ( $this->framworkFiles[ 'library' ] ) ) { |
|
207 | + if ( ! is_dir($this->framworkFiles['library'])) { |
|
208 | 208 | return false; |
209 | 209 | } |
210 | 210 | |
211 | 211 | |
212 | - if ( !isset ( $this->framworkFiles[ 'environment' ] ) or empty( $this->framworkFiles[ 'environment' ] ) ) { |
|
212 | + if ( ! isset ($this->framworkFiles['environment']) or empty($this->framworkFiles['environment'])) { |
|
213 | 213 | return false; |
214 | 214 | } |
215 | - set_include_path ( |
|
216 | - implode ( |
|
215 | + set_include_path( |
|
216 | + implode( |
|
217 | 217 | PATH_SEPARATOR, |
218 | - array ( |
|
219 | - realpath ( $this->framworkFiles[ 'library' ] ), |
|
220 | - get_include_path (), |
|
218 | + array( |
|
219 | + realpath($this->framworkFiles['library']), |
|
220 | + get_include_path(), |
|
221 | 221 | ) |
222 | 222 | ) |
223 | 223 | ); |
@@ -225,110 +225,110 @@ discard block |
||
225 | 225 | return true; |
226 | 226 | } |
227 | 227 | |
228 | - protected function getFrameworkIni () |
|
228 | + protected function getFrameworkIni() |
|
229 | 229 | { |
230 | - return $this->framworkFiles[ 'ini' ]; |
|
230 | + return $this->framworkFiles['ini']; |
|
231 | 231 | } |
232 | 232 | |
233 | - protected function getEnvironment () |
|
233 | + protected function getEnvironment() |
|
234 | 234 | { |
235 | - return $this->framworkFiles[ 'environment' ]; |
|
235 | + return $this->framworkFiles['environment']; |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | /** |
239 | 239 | * Popula as variaveis de acordo com o arquivo de configuração do seu framework |
240 | 240 | */ |
241 | - protected function isValid () |
|
241 | + protected function isValid() |
|
242 | 242 | { |
243 | - return $this->checkConfig (); |
|
243 | + return $this->checkConfig(); |
|
244 | 244 | } |
245 | 245 | |
246 | - private function setParams ( $array ) |
|
246 | + private function setParams($array) |
|
247 | 247 | { |
248 | - if ( count ( $array ) > 0 ) { |
|
249 | - $this->arrConfig = array_filter ( $array ) + $this->arrConfig; |
|
248 | + if (count($array) > 0) { |
|
249 | + $this->arrConfig = array_filter($array) + $this->arrConfig; |
|
250 | 250 | } |
251 | 251 | } |
252 | 252 | |
253 | 253 | /** |
254 | 254 | * @return string |
255 | 255 | */ |
256 | - public function getDatabase () |
|
256 | + public function getDatabase() |
|
257 | 257 | { |
258 | - return $this->arrConfig[ 'database' ]; |
|
258 | + return $this->arrConfig['database']; |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | /** |
262 | 262 | * @return bool |
263 | 263 | */ |
264 | - public function hasSchemas () |
|
264 | + public function hasSchemas() |
|
265 | 265 | { |
266 | - return !empty ( $this->arrConfig[ 'schema' ] ); |
|
266 | + return ! empty ($this->arrConfig['schema']); |
|
267 | 267 | } |
268 | 268 | |
269 | 269 | /** |
270 | 270 | * @return string[] |
271 | 271 | */ |
272 | - public function getSchemas () |
|
272 | + public function getSchemas() |
|
273 | 273 | { |
274 | - if ( is_string ( $this->arrConfig[ 'schema' ] ) ) { |
|
275 | - return array ( $this->arrConfig[ 'schema' ] ); |
|
274 | + if (is_string($this->arrConfig['schema'])) { |
|
275 | + return array($this->arrConfig['schema']); |
|
276 | 276 | } |
277 | 277 | |
278 | - return $this->arrConfig[ 'schema' ]; |
|
278 | + return $this->arrConfig['schema']; |
|
279 | 279 | } |
280 | 280 | |
281 | - public function setSchema ( $schema ) |
|
281 | + public function setSchema($schema) |
|
282 | 282 | { |
283 | - $this->arrConfig[ 'schema' ] = $schema; |
|
283 | + $this->arrConfig['schema'] = $schema; |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | /** |
287 | 287 | * @return string |
288 | 288 | */ |
289 | - public function getHost () |
|
289 | + public function getHost() |
|
290 | 290 | { |
291 | - return $this->arrConfig[ 'host' ]; |
|
291 | + return $this->arrConfig['host']; |
|
292 | 292 | } |
293 | 293 | |
294 | 294 | /** |
295 | 295 | * @return int |
296 | 296 | */ |
297 | - public function getPort () |
|
297 | + public function getPort() |
|
298 | 298 | { |
299 | - return $this->arrConfig[ 'port' ]; |
|
299 | + return $this->arrConfig['port']; |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | /** |
303 | 303 | * @return boolean |
304 | 304 | */ |
305 | - public function hasPort () |
|
305 | + public function hasPort() |
|
306 | 306 | { |
307 | - return !empty( $this->arrConfig[ 'port' ] ); |
|
307 | + return ! empty($this->arrConfig['port']); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | /** |
311 | 311 | * @return string |
312 | 312 | */ |
313 | - public function getSocket () |
|
313 | + public function getSocket() |
|
314 | 314 | { |
315 | - return $this->arrConfig[ 'socket' ]; |
|
315 | + return $this->arrConfig['socket']; |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | /** |
319 | 319 | * @return string |
320 | 320 | */ |
321 | - public function getUser () |
|
321 | + public function getUser() |
|
322 | 322 | { |
323 | - return $this->arrConfig[ 'username' ]; |
|
323 | + return $this->arrConfig['username']; |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | /** |
327 | 327 | * @return string |
328 | 328 | */ |
329 | - public function getPassword () |
|
329 | + public function getPassword() |
|
330 | 330 | { |
331 | - return $this->arrConfig[ 'password' ]; |
|
331 | + return $this->arrConfig['password']; |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | /** |
@@ -336,10 +336,10 @@ discard block |
||
336 | 336 | * |
337 | 337 | * @return string |
338 | 338 | */ |
339 | - public function replaceReservedWord ( $palavra ) |
|
339 | + public function replaceReservedWord($palavra) |
|
340 | 340 | { |
341 | - if ( isset( $this->reservedWord[ strtolower ( $palavra ) ] ) ) { |
|
342 | - return $this->reservedWord[ strtolower ( $palavra ) ]; |
|
341 | + if (isset($this->reservedWord[strtolower($palavra)])) { |
|
342 | + return $this->reservedWord[strtolower($palavra)]; |
|
343 | 343 | } |
344 | 344 | |
345 | 345 | return $palavra; |
@@ -348,9 +348,9 @@ discard block |
||
348 | 348 | /** |
349 | 349 | * @return bool |
350 | 350 | */ |
351 | - public function isStatusEnabled () |
|
351 | + public function isStatusEnabled() |
|
352 | 352 | { |
353 | - return (bool) $this->arrConfig[ 'status' ]; |
|
353 | + return (bool) $this->arrConfig['status']; |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | /** |
@@ -358,9 +358,9 @@ discard block |
||
358 | 358 | * |
359 | 359 | * @return string |
360 | 360 | */ |
361 | - public function __get ( $str ) |
|
361 | + public function __get($str) |
|
362 | 362 | { |
363 | - $arr = array ( |
|
363 | + $arr = array( |
|
364 | 364 | 'namespace', |
365 | 365 | 'framework', |
366 | 366 | 'author', |
@@ -373,8 +373,8 @@ discard block |
||
373 | 373 | 'folder-name' |
374 | 374 | ); |
375 | 375 | |
376 | - if ( in_array ( $str, $arr ) ) { |
|
377 | - return $this->arrConfig[ strtolower ( $str ) ]; |
|
376 | + if (in_array($str, $arr)) { |
|
377 | + return $this->arrConfig[strtolower($str)]; |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | return; |
@@ -134,8 +134,7 @@ |
||
134 | 134 | } |
135 | 135 | |
136 | 136 | |
137 | - } |
|
138 | - else { |
|
137 | + } else { |
|
139 | 138 | $url = array ( |
140 | 139 | $this->baseLocation, |
141 | 140 | $driverBase, |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | '$this->belongsTo(\'%s\', \'%s\', \'%s\', array(\'alias\' => \'%s\'))', |
55 | 55 | $objColumn->getName (), |
56 | 56 | $makerFile->getConfig () |
57 | - ->createClassNamespace ( $constrant ) . Phalcon::SEPARETOR . AbstractMaker::getClassName ( |
|
57 | + ->createClassNamespace ( $constrant ) . Phalcon::SEPARETOR . AbstractMaker::getClassName ( |
|
58 | 58 | $constrant->getTable () |
59 | 59 | ), |
60 | 60 | $constrant->getColumn (), |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | '$this->hasMany(\'%s\', \'%s\', \'%s\', array(\'alias\' => \'%s\'))', |
87 | 87 | $objColumn->getName (), |
88 | 88 | $makerFile->getConfig () |
89 | - ->createClassNamespace ( $dependence ) |
|
89 | + ->createClassNamespace ( $dependence ) |
|
90 | 90 | . Phalcon::SEPARETOR |
91 | 91 | . AbstractMaker::getClassName ( $dependence->getTable () ), |
92 | 92 | $dependence->getColumn (), |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | protected $fileTpl = "entity.php"; |
21 | 21 | protected $overwrite = true; |
22 | 22 | |
23 | - protected $validFunc = array (); |
|
23 | + protected $validFunc = array(); |
|
24 | 24 | |
25 | 25 | private $intersectDependence = false; |
26 | 26 | |
@@ -30,11 +30,11 @@ discard block |
||
30 | 30 | * |
31 | 31 | * @return array |
32 | 32 | */ |
33 | - public function parseRelation ( \Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable ) |
|
33 | + public function parseRelation(\Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable) |
|
34 | 34 | { |
35 | - return array ( |
|
36 | - 'mapParents' => $this->listParents ( $makerFile, $dbTable ), |
|
37 | - 'mapDependents' => $this->listDependence ( $makerFile, $dbTable ) |
|
35 | + return array( |
|
36 | + 'mapParents' => $this->listParents($makerFile, $dbTable), |
|
37 | + 'mapDependents' => $this->listDependence($makerFile, $dbTable) |
|
38 | 38 | ); |
39 | 39 | } |
40 | 40 | |
@@ -44,26 +44,26 @@ discard block |
||
44 | 44 | * |
45 | 45 | * @return array |
46 | 46 | */ |
47 | - private function listParents ( \Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable ) |
|
47 | + private function listParents(\Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable) |
|
48 | 48 | { |
49 | 49 | $mapParents = ''; |
50 | - $references = array (); |
|
51 | - foreach ( $dbTable->getForeingkeys () as $objColumn ) { |
|
52 | - $constrant = $objColumn->getFks (); |
|
53 | - $references[] = sprintf ( |
|
50 | + $references = array(); |
|
51 | + foreach ($dbTable->getForeingkeys() as $objColumn) { |
|
52 | + $constrant = $objColumn->getFks(); |
|
53 | + $references[] = sprintf( |
|
54 | 54 | '$this->belongsTo(\'%s\', \'%s\', \'%s\', array(\'alias\' => \'%s\'))', |
55 | - $objColumn->getName (), |
|
56 | - $makerFile->getConfig () |
|
57 | - ->createClassNamespace ( $constrant ) . Phalcon::SEPARETOR . AbstractMaker::getClassName ( |
|
58 | - $constrant->getTable () |
|
55 | + $objColumn->getName(), |
|
56 | + $makerFile->getConfig() |
|
57 | + ->createClassNamespace($constrant) . Phalcon::SEPARETOR . AbstractMaker::getClassName( |
|
58 | + $constrant->getTable() |
|
59 | 59 | ), |
60 | - $constrant->getColumn (), |
|
61 | - AbstractMaker::getClassName ( $constrant->getTable () ) |
|
60 | + $constrant->getColumn(), |
|
61 | + AbstractMaker::getClassName($constrant->getTable()) |
|
62 | 62 | ); |
63 | 63 | } |
64 | 64 | |
65 | - if ( sizeof ( $references ) > 0 ) { |
|
66 | - $mapParents = join ( ";\n\t\t", $references ) . ";\n"; |
|
65 | + if (sizeof($references) > 0) { |
|
66 | + $mapParents = join(";\n\t\t", $references) . ";\n"; |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | |
@@ -76,28 +76,28 @@ discard block |
||
76 | 76 | * |
77 | 77 | * @return array |
78 | 78 | */ |
79 | - private function listDependence ( \Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable ) |
|
79 | + private function listDependence(\Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable) |
|
80 | 80 | { |
81 | 81 | $mapDependence = ''; |
82 | - $references = array (); |
|
83 | - foreach ( $dbTable->getDependences () as $objColumn ) { |
|
84 | - foreach ( $objColumn->getDependences () as $dependence ) { |
|
85 | - $references[] = sprintf ( |
|
82 | + $references = array(); |
|
83 | + foreach ($dbTable->getDependences() as $objColumn) { |
|
84 | + foreach ($objColumn->getDependences() as $dependence) { |
|
85 | + $references[] = sprintf( |
|
86 | 86 | '$this->hasMany(\'%s\', \'%s\', \'%s\', array(\'alias\' => \'%s\'))', |
87 | - $objColumn->getName (), |
|
88 | - $makerFile->getConfig () |
|
89 | - ->createClassNamespace ( $dependence ) |
|
87 | + $objColumn->getName(), |
|
88 | + $makerFile->getConfig() |
|
89 | + ->createClassNamespace($dependence) |
|
90 | 90 | . Phalcon::SEPARETOR |
91 | - . AbstractMaker::getClassName ( $dependence->getTable () ), |
|
92 | - $dependence->getColumn (), |
|
93 | - AbstractMaker::getClassName ( $dependence->getTable () ) |
|
91 | + . AbstractMaker::getClassName($dependence->getTable()), |
|
92 | + $dependence->getColumn(), |
|
93 | + AbstractMaker::getClassName($dependence->getTable()) |
|
94 | 94 | ); |
95 | 95 | |
96 | 96 | } |
97 | 97 | } |
98 | 98 | |
99 | - if ( sizeof ( $references ) > 0 ) { |
|
100 | - $mapDependence = join ( ";\n\t\t", $references ) . ";"; |
|
99 | + if (sizeof($references) > 0) { |
|
100 | + $mapDependence = join(";\n\t\t", $references) . ";"; |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | return $mapDependence; |
@@ -1,35 +1,35 @@ discard block |
||
1 | 1 | <?="<?php\n"?> |
2 | -<?php $className = $objTables->getNamespace(). '_Entity_' . \Classes\Maker\AbstractMaker::getClassName ( $objTables->getName () )?> |
|
2 | +<?php $className = $objTables->getNamespace() . '_Entity_' . \Classes\Maker\AbstractMaker::getClassName($objTables->getName())?> |
|
3 | 3 | |
4 | 4 | /** |
5 | 5 | * Application Entity |
6 | 6 | * |
7 | - * <?=$this->config->last_modify."\n"?> |
|
7 | + * <?=$this->config->last_modify . "\n"?> |
|
8 | 8 | * |
9 | - * @package <?=$objTables->getNamespace()."\n"?> |
|
9 | + * @package <?=$objTables->getNamespace() . "\n"?> |
|
10 | 10 | * @subpackage Entity |
11 | 11 | * |
12 | - * @author <?=$this->config->author."\n"?> |
|
12 | + * @author <?=$this->config->author . "\n"?> |
|
13 | 13 | * |
14 | - * @copyright <?=$this->config->copyright."\n"?> |
|
15 | - * @license <?=$this->config->license."\n"?> |
|
16 | - * @link <?=$this->config->link."\n"?> |
|
14 | + * @copyright <?=$this->config->copyright . "\n"?> |
|
15 | + * @license <?=$this->config->license . "\n"?> |
|
16 | + * @link <?=$this->config->link . "\n"?> |
|
17 | 17 | */ |
18 | 18 | |
19 | 19 | /** |
20 | 20 | * Abstract class for entity |
21 | 21 | */ |
22 | 22 | |
23 | -abstract class <?=$className?> extends <?=$this->config->namespace?$this->config->namespace."_":""?>Model_<?=$objMakeFile->getParentClass() . "\n"?> |
|
23 | +abstract class <?=$className?> extends <?=$this->config->namespace ? $this->config->namespace . "_" : ""?>Model_<?=$objMakeFile->getParentClass() . "\n"?> |
|
24 | 24 | { |
25 | 25 | |
26 | 26 | <?php foreach ($objTables->getColumns() as $column): ?> |
27 | 27 | /** |
28 | - * Database constraint in the column <?=$column->getName()."\n"?> |
|
28 | + * Database constraint in the column <?=$column->getName() . "\n"?> |
|
29 | 29 | * |
30 | 30 | */ |
31 | 31 | const <?=strtoupper($column->getName())?> = '<?=$objTables->getName()?>.<?=$column->getName()?>'; |
32 | -<?php endforeach;?> |
|
32 | +<?php endforeach; ?> |
|
33 | 33 | |
34 | 34 | /** |
35 | 35 | * Nome da tabela DbTable do model |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * @var string |
38 | 38 | * @access protected |
39 | 39 | */ |
40 | - protected $_tableClass = '<?=$objTables->getNamespace()?>_DbTable_<?=\Classes\Maker\AbstractMaker::getClassName ( $objTables->getName () )?>'; |
|
40 | + protected $_tableClass = '<?=$objTables->getNamespace()?>_DbTable_<?=\Classes\Maker\AbstractMaker::getClassName($objTables->getName())?>'; |
|
41 | 41 | |
42 | 42 | /** |
43 | 43 | * @see <?=$this->config->namespace?>Model_EntityAbstract::$_columnsList |
@@ -45,17 +45,17 @@ discard block |
||
45 | 45 | protected $_columnsList = array( |
46 | 46 | <?php foreach ($objTables->getColumns() as $column): ?> |
47 | 47 | self::<?=strtoupper($column->getName())?> => '<?=strtolower(\Classes\Maker\AbstractMaker::getClassName($column->getName()))?>', |
48 | -<?php endforeach;?> |
|
48 | +<?php endforeach; ?> |
|
49 | 49 | ); |
50 | 50 | |
51 | 51 | /** |
52 | 52 | * @see <?=$this->config->namespace?>Model_EntityAbstract::$_filters |
53 | 53 | */ |
54 | 54 | protected $_filters = array( |
55 | -<?php foreach ( $objTables->getColumns () as $column ): ?> |
|
55 | +<?php foreach ($objTables->getColumns() as $column): ?> |
|
56 | 56 | <?php |
57 | 57 | $filters = null; |
58 | - switch ( ucfirst ( $column->getType () ) ) |
|
58 | + switch (ucfirst($column->getType())) |
|
59 | 59 | { |
60 | 60 | case 'String': |
61 | 61 | $filters = 'StripTags", "StringTrim'; |
@@ -66,50 +66,50 @@ discard block |
||
66 | 66 | case 'Date': |
67 | 67 | break; |
68 | 68 | default: |
69 | - $filters = ucfirst ( $column->getType () ); |
|
69 | + $filters = ucfirst($column->getType()); |
|
70 | 70 | break; |
71 | 71 | } |
72 | 72 | ?> |
73 | 73 | '<?=$column->getName()?>'=>array ( |
74 | - <?=( !empty( $filters ) ) ? "\"{$filters}\"\n" : null; ?> |
|
74 | + <?=( ! empty($filters)) ? "\"{$filters}\"\n" : null; ?> |
|
75 | 75 | ), |
76 | -<?php endforeach;?> |
|
76 | +<?php endforeach; ?> |
|
77 | 77 | ); |
78 | 78 | |
79 | 79 | /** |
80 | 80 | * @see <?=$this->config->namespace?>Model_EntityAbstract::$_validators |
81 | 81 | */ |
82 | 82 | protected $_validators= array( |
83 | -<?php foreach ( $objTables->getColumns () as $column ): ?> |
|
83 | +<?php foreach ($objTables->getColumns() as $column): ?> |
|
84 | 84 | <?php |
85 | - $validators = array (); |
|
85 | + $validators = array(); |
|
86 | 86 | |
87 | - $validators[] = $column->isNullable () ? "'allowEmpty' => true" : "'NotEmpty'"; |
|
87 | + $validators[] = $column->isNullable() ? "'allowEmpty' => true" : "'NotEmpty'"; |
|
88 | 88 | |
89 | - switch ( ucfirst ( $column->getType () ) ) |
|
89 | + switch (ucfirst($column->getType())) |
|
90 | 90 | { |
91 | 91 | case 'String': |
92 | - if ( $column->getMaxLength () ) |
|
92 | + if ($column->getMaxLength()) |
|
93 | 93 | { |
94 | - $validators[] = "array( 'StringLength', array( 'max' => " . $column->getMaxLength () . " ) )"; |
|
94 | + $validators[] = "array( 'StringLength', array( 'max' => " . $column->getMaxLength() . " ) )"; |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | break; |
98 | 98 | case 'Boolean': |
99 | 99 | break; |
100 | 100 | default: |
101 | - $name = ucfirst ( $column->getType () ); |
|
101 | + $name = ucfirst($column->getType()); |
|
102 | 102 | $validators[] = "'$name'"; |
103 | 103 | break; |
104 | 104 | } |
105 | - $validators = implode ( ", ", $validators )?> |
|
106 | - '<?= $column->getName () ?>' => array ( |
|
107 | - <?=( !empty( $validators ) ) ? "{$validators}\n" : null?> |
|
105 | + $validators = implode(", ", $validators)?> |
|
106 | + '<?= $column->getName() ?>' => array ( |
|
107 | + <?=( ! empty($validators)) ? "{$validators}\n" : null?> |
|
108 | 108 | ), |
109 | 109 | <?php endforeach; ?> |
110 | 110 | ); |
111 | 111 | |
112 | -<?php if( $objTables->hasPrimaryKey() ):?> |
|
112 | +<?php if ($objTables->hasPrimaryKey()):?> |
|
113 | 113 | /** |
114 | 114 | * Nome da Primary Key |
115 | 115 | * |
@@ -118,7 +118,7 @@ discard block |
||
118 | 118 | */ |
119 | 119 | |
120 | 120 | protected $_primary = array( |
121 | - <?php foreach($objTables->getPrimarykeys() as $pks) : ?> |
|
121 | + <?php foreach ($objTables->getPrimarykeys() as $pks) : ?> |
|
122 | 122 | '<?=$pks->getName()?>', |
123 | 123 | <?php endforeach ?> |
124 | 124 | ); |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | */ |
133 | 133 | protected $_parent_<?=$parent['name']?>; |
134 | 134 | |
135 | -<?php endforeach;?> |
|
135 | +<?php endforeach; ?> |
|
136 | 136 | <?php foreach ($depends as $depend): ?> |
137 | 137 | /** |
138 | 138 | * Depends relation <?=\Classes\Maker\AbstractMaker::getClassName($depend['table']) . "\n"?> |
@@ -141,13 +141,13 @@ discard block |
||
141 | 141 | */ |
142 | 142 | protected $_depend_<?=$depend['name']?>; |
143 | 143 | |
144 | -<?php endforeach;?> |
|
144 | +<?php endforeach; ?> |
|
145 | 145 | <?php foreach ($objTables->getColumns() as $column): ?> |
146 | 146 | /** |
147 | 147 | * |
148 | - * Sets column <?=$column->getName()."\n"?> |
|
148 | + * Sets column <?=$column->getName() . "\n"?> |
|
149 | 149 | * |
150 | -<?php if ($column->getType()=='date'): ?> |
|
150 | +<?php if ($column->getType() == 'date'): ?> |
|
151 | 151 | * Stored in ISO 8601 format. |
152 | 152 | * |
153 | 153 | * @param string|Zend_Date $<?=$column->getName() . "\n"?> |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | */ |
159 | 159 | public function set<?=\Classes\Maker\AbstractMaker::getClassName($column->getName())?>($<?=$column->getName()?>) |
160 | 160 | { |
161 | -<?php switch ( $column->getType () ): |
|
161 | +<?php switch ($column->getType()): |
|
162 | 162 | case 'date': ?> |
163 | 163 | if (! empty($<?=$column->getName()?>)) |
164 | 164 | { |
@@ -197,16 +197,16 @@ discard block |
||
197 | 197 | /** |
198 | 198 | * Gets column <?=$column->getName() . "\n"?> |
199 | 199 | * |
200 | -<?php if ($column->getType()=='date'): ?> |
|
200 | +<?php if ($column->getType() == 'date'): ?> |
|
201 | 201 | * @param boolean $returnZendDate |
202 | 202 | * @return Zend_Date|null|string Zend_Date representation of this datetime if enabled, or ISO 8601 string if not |
203 | 203 | <?php else: ?> |
204 | 204 | * @return <?=$column->getType() . "\n"?> |
205 | 205 | <?php endif; ?> |
206 | 206 | */ |
207 | - public function get<?=\Classes\Maker\AbstractMaker::getClassName($column->getName())?>(<?php if ($column->getType()=='date'): ?>$returnZendDate = false <?php endif;?>) |
|
207 | + public function get<?=\Classes\Maker\AbstractMaker::getClassName($column->getName())?>(<?php if ($column->getType() == 'date'): ?>$returnZendDate = false <?php endif; ?>) |
|
208 | 208 | { |
209 | -<?php if ($column->getType()=='date'): ?> |
|
209 | +<?php if ($column->getType() == 'date'): ?> |
|
210 | 210 | if ($returnZendDate) |
211 | 211 | { |
212 | 212 | if ($this->_data['<?=$column->getName()?>'] === null) |
@@ -232,7 +232,7 @@ discard block |
||
232 | 232 | { |
233 | 233 | if ($this->_parent_<?=$parent['name']?> === null) |
234 | 234 | { |
235 | - $this->_parent_<?=$parent['name']?> = $this->findParentRow('<?=$objTables->getNamespace()?>_DbTable_<?=\Classes\Maker\AbstractMaker::getClassName ($parent['table'])?>', '<?=\Classes\Maker\AbstractMaker::getClassName($parent['name'])?>'); |
|
235 | + $this->_parent_<?=$parent['name']?> = $this->findParentRow('<?=$objTables->getNamespace()?>_DbTable_<?=\Classes\Maker\AbstractMaker::getClassName($parent['table'])?>', '<?=\Classes\Maker\AbstractMaker::getClassName($parent['name'])?>'); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | return $this->_parent_<?=$parent['name']?>; |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | { |
252 | 252 | if ($this->_depend_<?=$depend['name']?> === null) |
253 | 253 | { |
254 | - $this->_depend_<?=$depend['name']?> = $this->findDependentRowset('<?=$objTables->getNamespace()?>_DbTable_<?=\Classes\Maker\AbstractMaker::getClassName ($depend['table'])?>'); |
|
254 | + $this->_depend_<?=$depend['name']?> = $this->findDependentRowset('<?=$objTables->getNamespace()?>_DbTable_<?=\Classes\Maker\AbstractMaker::getClassName($depend['table'])?>'); |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | return $this->_depend_<?=$depend['name']?>; |
@@ -3,20 +3,20 @@ discard block |
||
3 | 3 | /** |
4 | 4 | * Application Model DbTables |
5 | 5 | * |
6 | - * <?=$this->config->last_modify."\n"?> |
|
6 | + * <?=$this->config->last_modify . "\n"?> |
|
7 | 7 | * |
8 | 8 | * Tabela definida por 'tablename' |
9 | 9 | * |
10 | 10 | * @package <?=$objTables->getNamespace()?><?="\n"?> |
11 | 11 | * @subpackage DbTable |
12 | - * @author <?=$this->config->author."\n"?> |
|
12 | + * @author <?=$this->config->author . "\n"?> |
|
13 | 13 | * |
14 | - * @copyright <?=$this->config->copyright."\n"?> |
|
15 | - * @license <?=$this->config->license."\n"?> |
|
16 | - * @link <?=$this->config->link."\n"?> |
|
14 | + * @copyright <?=$this->config->copyright . "\n"?> |
|
15 | + * @license <?=$this->config->license . "\n"?> |
|
16 | + * @link <?=$this->config->link . "\n"?> |
|
17 | 17 | */ |
18 | 18 | |
19 | -class <?=$objTables->getNamespace()?>_DbTable_<?=\Classes\Maker\AbstractMaker::getClassName ( $objTables->getName () )?> extends <?=$this->config->namespace?$this->config->namespace."_":""?>Model_<?=$objMakeFile->getParentClass() . "\n"?> |
|
19 | +class <?=$objTables->getNamespace()?>_DbTable_<?=\Classes\Maker\AbstractMaker::getClassName($objTables->getName())?> extends <?=$this->config->namespace ? $this->config->namespace . "_" : ""?>Model_<?=$objMakeFile->getParentClass() . "\n"?> |
|
20 | 20 | { |
21 | 21 | /** |
22 | 22 | * Nome da tabela do banco de dados |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * @access protected |
26 | 26 | */ |
27 | 27 | protected $_name = '<?=$objTables->getName()?>'; |
28 | -<?php if($objTables->hasSchema()): ?> |
|
28 | +<?php if ($objTables->hasSchema()): ?> |
|
29 | 29 | |
30 | 30 | /** |
31 | 31 | * Schema da tabela do banco de dados |
@@ -42,9 +42,9 @@ discard block |
||
42 | 42 | * @var string |
43 | 43 | * @access protected |
44 | 44 | */ |
45 | - protected $_rowClass = '<?=$objTables->getNamespace()?>_<?=\Classes\Maker\AbstractMaker::getClassName ( $objTables->getName () )?>'; |
|
45 | + protected $_rowClass = '<?=$objTables->getNamespace()?>_<?=\Classes\Maker\AbstractMaker::getClassName($objTables->getName())?>'; |
|
46 | 46 | |
47 | -<?php if( $objTables->hasPrimaryKey() ):?> |
|
47 | +<?php if ($objTables->hasPrimaryKey()):?> |
|
48 | 48 | /** |
49 | 49 | * Nome da Primary Key |
50 | 50 | * |
@@ -52,12 +52,12 @@ discard block |
||
52 | 52 | * @access protected |
53 | 53 | */ |
54 | 54 | protected $_primary = array( |
55 | -<?php foreach($objTables->getPrimaryKeys() as $pks):?> |
|
55 | +<?php foreach ($objTables->getPrimaryKeys() as $pks):?> |
|
56 | 56 | '<?=$pks->getName()?>', |
57 | 57 | <?php endforeach; ?> |
58 | 58 | ); |
59 | 59 | <?php endif ?> |
60 | -<?php if($this->config->{'folder-name'}):?> |
|
60 | +<?php if ($this->config->{'folder-name'}):?> |
|
61 | 61 | /** |
62 | 62 | * Initialize database adapter. |
63 | 63 | * |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | parent::_setupDatabaseAdapter(); |
73 | 73 | } |
74 | 74 | <?php endif ?> |
75 | -<?php if( $objTables->hasSequences() ) : ?> |
|
75 | +<?php if ($objTables->hasSequences()) : ?> |
|
76 | 76 | |
77 | 77 | /** |
78 | 78 | * Definir a lógica para os novos valores na chave primária. |
@@ -80,9 +80,9 @@ discard block |
||
80 | 80 | * |
81 | 81 | * @var mixed |
82 | 82 | */ |
83 | -<?php if ( 1 == count($objTables->getSequences() ) ) : ?> |
|
84 | -<?php if(strpos($this->config->driver, 'pgsql')): ?> |
|
85 | -<?php $seqs = $objTables->getSequences();reset($seqs);$seq = current($seqs);?> |
|
83 | +<?php if (1 == count($objTables->getSequences())) : ?> |
|
84 | +<?php if (strpos($this->config->driver, 'pgsql')): ?> |
|
85 | +<?php $seqs = $objTables->getSequences(); reset($seqs); $seq = current($seqs); ?> |
|
86 | 86 | protected $_sequence = '<?=$seq->getSequence() ?>'; |
87 | 87 | <?php else: ?> |
88 | 88 | protected $_sequence = true; |
@@ -3,17 +3,17 @@ discard block |
||
3 | 3 | /** |
4 | 4 | * Application Model DbTables |
5 | 5 | * |
6 | - * <?=$this->config->last_modify."\n"?> |
|
6 | + * <?=$this->config->last_modify . "\n"?> |
|
7 | 7 | * |
8 | 8 | * Classe Abstract pai de todas as tabelas |
9 | 9 | * |
10 | 10 | * @package <?=$this->config->namespace?>Model |
11 | 11 | * @subpackage DbTable |
12 | - * @author <?=$this->config->author."\n"?> |
|
12 | + * @author <?=$this->config->author . "\n"?> |
|
13 | 13 | * |
14 | - * @copyright <?=$this->config->copyright."\n"?> |
|
15 | - * @license <?=$this->config->license."\n"?> |
|
16 | - * @link <?=$this->config->link."\n"?> |
|
14 | + * @copyright <?=$this->config->copyright . "\n"?> |
|
15 | + * @license <?=$this->config->license . "\n"?> |
|
16 | + * @link <?=$this->config->link . "\n"?> |
|
17 | 17 | * |
18 | 18 | * @abstract |
19 | 19 | */ |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | * Zend DB Table Abstract class |
23 | 23 | */ |
24 | 24 | |
25 | -abstract class <?=$this->config->namespace?$this->config->namespace."_":""?>Model_TableAbstract extends Zend_Db_Table_Abstract |
|
25 | +abstract class <?=$this->config->namespace ? $this->config->namespace . "_" : ""?>Model_TableAbstract extends Zend_Db_Table_Abstract |
|
26 | 26 | { |
27 | 27 | /** |
28 | 28 | * Nome da tabela do banco de dados |
@@ -3,18 +3,18 @@ discard block |
||
3 | 3 | /** |
4 | 4 | * Application Entity |
5 | 5 | * |
6 | - * <?=$this->config->last_modify."\n"?> |
|
6 | + * <?=$this->config->last_modify . "\n"?> |
|
7 | 7 | * |
8 | 8 | * @package <?=$this->config->namespace?>Model |
9 | 9 | * @subpackage Model |
10 | - * @author <?=$this->config->author."\n"?> |
|
10 | + * @author <?=$this->config->author . "\n"?> |
|
11 | 11 | * |
12 | - * @copyright <?=$this->config->copyright."\n"?> |
|
13 | - * @license <?=$this->config->license."\n"?> |
|
14 | - * @link <?=$this->config->link."\n"?> |
|
12 | + * @copyright <?=$this->config->copyright . "\n"?> |
|
13 | + * @license <?=$this->config->license . "\n"?> |
|
14 | + * @link <?=$this->config->link . "\n"?> |
|
15 | 15 | */ |
16 | 16 | |
17 | -abstract class <?=$this->config->namespace?$this->config->namespace."_":""?>Model_EntityAbstract extends Zend_Db_Table_Row_Abstract |
|
17 | +abstract class <?=$this->config->namespace ? $this->config->namespace . "_" : ""?>Model_EntityAbstract extends Zend_Db_Table_Row_Abstract |
|
18 | 18 | { |
19 | 19 | |
20 | 20 | /** |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | |
75 | 75 | /** |
76 | 76 | * @param array $data |
77 | - * @return <?=$this->config->namespace?$this->config->namespace."_":""?>>Model_EntityAbstract |
|
77 | + * @return <?=$this->config->namespace ? $this->config->namespace . "_" : ""?>>Model_EntityAbstract |
|
78 | 78 | */ |
79 | 79 | public static function getIntance($data = array()) |
80 | 80 | { |
@@ -3,21 +3,21 @@ |
||
3 | 3 | /** |
4 | 4 | * Data Model implementation for this class |
5 | 5 | * |
6 | - * <?=$this->config->last_modify."\n"?> |
|
6 | + * <?=$this->config->last_modify . "\n"?> |
|
7 | 7 | * |
8 | - * @see <?=$objTables->getNamespace()?>\<?=$this->getClassName ( $objTables->getName () ). "\n"?> |
|
8 | + * @see <?=$objTables->getNamespace()?>\<?=$this->getClassName($objTables->getName()) . "\n"?> |
|
9 | 9 | * |
10 | - * @author <?=$this->config->author."\n"?> |
|
10 | + * @author <?=$this->config->author . "\n"?> |
|
11 | 11 | * |
12 | - * @copyright <?=$this->config->copyright."\n"?> |
|
13 | - * @license <?=$this->config->license."\n"?> |
|
14 | - * @link <?=$this->config->link."\n"?> |
|
12 | + * @copyright <?=$this->config->copyright . "\n"?> |
|
13 | + * @license <?=$this->config->license . "\n"?> |
|
14 | + * @link <?=$this->config->link . "\n"?> |
|
15 | 15 | */ |
16 | 16 | |
17 | 17 | |
18 | 18 | namespace <?=$objTables->getNamespace()?>; |
19 | 19 | |
20 | -class <?=$this->getClassName ( $objTables->getName () )?> extends \<?=$objTables->getNamespace()?>\Entity\<?=$this->getClassName ( $objTables->getName () ). "\n"?> |
|
20 | +class <?=$this->getClassName($objTables->getName())?> extends \<?=$objTables->getNamespace()?>\Entity\<?=$this->getClassName($objTables->getName()) . "\n"?> |
|
21 | 21 | { |
22 | 22 | /* Codifique aqui */ |
23 | 23 | } |
@@ -3,42 +3,42 @@ discard block |
||
3 | 3 | /** |
4 | 4 | * Mvc Model |
5 | 5 | * |
6 | - * <?=$this->config->last_modify."\n"?> |
|
6 | + * <?=$this->config->last_modify . "\n"?> |
|
7 | 7 | * |
8 | 8 | * @package <?=$objTables->getNamespace()?>\Entity |
9 | 9 | * @subpackage Model |
10 | - * @author <?=$this->config->author."\n"?> |
|
10 | + * @author <?=$this->config->author . "\n"?> |
|
11 | 11 | * |
12 | - * @copyright <?=$this->config->copyright."\n"?> |
|
13 | - * @license <?=$this->config->license."\n"?> |
|
14 | - * @link <?=$this->config->link."\n"?> |
|
12 | + * @copyright <?=$this->config->copyright . "\n"?> |
|
13 | + * @license <?=$this->config->license . "\n"?> |
|
14 | + * @link <?=$this->config->link . "\n"?> |
|
15 | 15 | */ |
16 | 16 | |
17 | 17 | namespace <?=$objTables->getNamespace()?>\Entity; |
18 | 18 | |
19 | 19 | use Phalcon\Validation; |
20 | 20 | |
21 | -abstract class <?=\Classes\Maker\AbstractMaker::getClassName ( $objTables->getName () )?> extends \Phalcon\Mvc\Model |
|
21 | +abstract class <?=\Classes\Maker\AbstractMaker::getClassName($objTables->getName())?> extends \Phalcon\Mvc\Model |
|
22 | 22 | { |
23 | 23 | |
24 | 24 | <?php foreach ($objTables->getColumns() as $column): ?> |
25 | 25 | /** |
26 | - * column <?=$column->getName()."\n"?> |
|
26 | + * column <?=$column->getName() . "\n"?> |
|
27 | 27 | * |
28 | -<?php if($column->isPrimaryKey()):?> |
|
28 | +<?php if ($column->isPrimaryKey()):?> |
|
29 | 29 | * @Primary |
30 | 30 | <?php endif ?> |
31 | -<?php if($column->hasSequence()):?> |
|
31 | +<?php if ($column->hasSequence()):?> |
|
32 | 32 | * @Identity |
33 | 33 | <?php endif ?> |
34 | - * @Column(type="<?=$column->getType()?>", nullable=<?=$column->isNullable () ? "true" : "false"?><?php |
|
35 | -if ( $column->getMaxLength () ): ?> |
|
36 | -, length=<?=$column->getMaxLength ()?> |
|
34 | + * @Column(type="<?=$column->getType()?>", nullable=<?=$column->isNullable() ? "true" : "false"?><?php |
|
35 | +if ($column->getMaxLength()): ?> |
|
36 | +, length=<?=$column->getMaxLength()?> |
|
37 | 37 | <?php endif ?>) |
38 | 38 | */ |
39 | 39 | protected $<?=$column->getName()?>; |
40 | 40 | |
41 | -<?php endforeach;?> |
|
41 | +<?php endforeach; ?> |
|
42 | 42 | /** |
43 | 43 | * Validations and business logic |
44 | 44 | * |
@@ -49,14 +49,14 @@ discard block |
||
49 | 49 | $validator = new Validation(); |
50 | 50 | |
51 | 51 | <?php foreach ($objTables->getColumns() as $column): ?> |
52 | -<?php if(strtolower($column->getName()) == 'email'):?> |
|
52 | +<?php if (strtolower($column->getName()) == 'email'):?> |
|
53 | 53 | $validator->add( |
54 | 54 | 'email', |
55 | 55 | new \Phalcon\Validation\Validator\Email() |
56 | 56 | ); |
57 | 57 | |
58 | 58 | <?php endif ?> |
59 | -<?php endforeach;?> |
|
59 | +<?php endforeach; ?> |
|
60 | 60 | return $this->validate($validator); |
61 | 61 | } |
62 | 62 | |
@@ -65,11 +65,11 @@ discard block |
||
65 | 65 | */ |
66 | 66 | public function initialize() |
67 | 67 | { |
68 | - <?=$mapDependents."\n"?> |
|
69 | - <?=$mapParents."\n"?> |
|
68 | + <?=$mapDependents . "\n"?> |
|
69 | + <?=$mapParents . "\n"?> |
|
70 | 70 | } |
71 | 71 | |
72 | -<?php if($objTables->hasSchema()): ?> |
|
72 | +<?php if ($objTables->hasSchema()): ?> |
|
73 | 73 | /** |
74 | 74 | * Returns schema name where table mapped is located |
75 | 75 | * |
@@ -91,11 +91,11 @@ discard block |
||
91 | 91 | return '<?=$objTables->getName()?>'; |
92 | 92 | } |
93 | 93 | |
94 | -<?php if( $objTables->hasSequences() ) : ?> |
|
94 | +<?php if ($objTables->hasSequences()) : ?> |
|
95 | 95 | public function getSequenceName() |
96 | 96 | { |
97 | -<?php if ( 1 == count($objTables->getSequences() ) ) : ?> |
|
98 | - <?php $seqs = $objTables->getSequences();reset($seqs);$seq = current($seqs);?> |
|
97 | +<?php if (1 == count($objTables->getSequences())) : ?> |
|
98 | + <?php $seqs = $objTables->getSequences(); reset($seqs); $seq = current($seqs); ?> |
|
99 | 99 | return "<?=$seq->getSequence() ?>"; |
100 | 100 | <?php endif ?> |
101 | 101 | } |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * Allows to query a set of records that match the specified conditions |
106 | 106 | * |
107 | 107 | * @param mixed $parameters |
108 | - * @return \<?=$objTables->getNamespace()?>\<?=\Classes\Maker\AbstractMaker::getClassName ( $objTables->getName () )?>[] |
|
108 | + * @return \<?=$objTables->getNamespace()?>\<?=\Classes\Maker\AbstractMaker::getClassName($objTables->getName())?>[] |
|
109 | 109 | */ |
110 | 110 | public static function find($parameters = null) |
111 | 111 | { |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | * Allows to query the first record that match the specified conditions |
117 | 117 | * |
118 | 118 | * @param mixed $parameters |
119 | - * @return \<?=$objTables->getNamespace()?>\<?=\Classes\Maker\AbstractMaker::getClassName ( $objTables->getName () )."\n"?> |
|
119 | + * @return \<?=$objTables->getNamespace()?>\<?=\Classes\Maker\AbstractMaker::getClassName($objTables->getName()) . "\n"?> |
|
120 | 120 | */ |
121 | 121 | public static function findFirst($parameters = null) |
122 | 122 | { |
@@ -125,17 +125,17 @@ discard block |
||
125 | 125 | |
126 | 126 | |
127 | 127 | <?php foreach ($objTables->getColumns() as $column): ?> |
128 | - public function set<?=$this->getClassName ( $column->getName () )?>( $<?=$column->getName()?> ) |
|
128 | + public function set<?=$this->getClassName($column->getName())?>( $<?=$column->getName()?> ) |
|
129 | 129 | { |
130 | 130 | $this-><?=$column->getName()?> = $<?=$column->getName()?>; |
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
134 | - * @return <?=$column->getType ()."\n" ?> |
|
134 | + * @return <?=$column->getType() . "\n" ?> |
|
135 | 135 | **/ |
136 | - public function get<?=$this->getClassName ( $column->getName () )?>() |
|
136 | + public function get<?=$this->getClassName($column->getName())?>() |
|
137 | 137 | { |
138 | - return (<?=$column->getType () ?>) $this-><?=$column->getName()?>; |
|
138 | + return (<?=$column->getType() ?>) $this-><?=$column->getName()?>; |
|
139 | 139 | } |
140 | -<?php endforeach;?> |
|
140 | +<?php endforeach; ?> |
|
141 | 141 | } |
142 | 142 | \ No newline at end of file |
@@ -135,7 +135,7 @@ |
||
135 | 135 | $configIni = isset( $argv[ 'config-ini' ] ) |
136 | 136 | ? $argv[ 'config-ini' ] |
137 | 137 | : $this->_basePath |
138 | - . $this->configIniDefault; |
|
138 | + . $this->configIniDefault; |
|
139 | 139 | |
140 | 140 | $configTemp = $this->loadIniFile ( realpath ( $configIni ) ); |
141 | 141 | $configCurrent = self::parseConfigEnv ( $configTemp, $argv ); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | /** |
53 | 53 | * @var array |
54 | 54 | */ |
55 | - private $argv = array (); |
|
55 | + private $argv = array(); |
|
56 | 56 | |
57 | 57 | /** |
58 | 58 | * @var \Classes\AdapterConfig\AbstractAdapter |
@@ -64,22 +64,22 @@ discard block |
||
64 | 64 | */ |
65 | 65 | private $adapterDriver; |
66 | 66 | |
67 | - private $frameworkList = array ( |
|
67 | + private $frameworkList = array( |
|
68 | 68 | 'none', |
69 | 69 | 'zf1', |
70 | 70 | 'phalcon' |
71 | 71 | ); |
72 | 72 | |
73 | - public function __construct ( $argv, $basePath ) |
|
73 | + public function __construct($argv, $basePath) |
|
74 | 74 | { |
75 | - if ( array_key_exists ( 'help', $argv ) ) { |
|
76 | - die ( $this->getUsage () ); |
|
75 | + if (array_key_exists('help', $argv)) { |
|
76 | + die ($this->getUsage()); |
|
77 | 77 | } |
78 | - if ( array_key_exists ( 'status', $argv ) ) { |
|
79 | - $argv[ 'status' ] = true; |
|
78 | + if (array_key_exists('status', $argv)) { |
|
79 | + $argv['status'] = true; |
|
80 | 80 | } |
81 | 81 | |
82 | - $this->argv = $this->parseConfig ( $basePath, $argv ); |
|
82 | + $this->argv = $this->parseConfig($basePath, $argv); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | * |
88 | 88 | * @return string |
89 | 89 | */ |
90 | - public function getUsage () |
|
90 | + public function getUsage() |
|
91 | 91 | { |
92 | - $version = $this->getVersion (); |
|
92 | + $version = $this->getVersion(); |
|
93 | 93 | |
94 | 94 | return <<<EOF |
95 | 95 | parameters: |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | EOF; |
113 | 113 | } |
114 | 114 | |
115 | - public function getVersion () |
|
115 | + public function getVersion() |
|
116 | 116 | { |
117 | 117 | $version = static::$version; |
118 | 118 | |
@@ -128,28 +128,28 @@ discard block |
||
128 | 128 | * @return array |
129 | 129 | * @throws \Exception |
130 | 130 | */ |
131 | - private function parseConfig ( $basePath, $argv ) |
|
131 | + private function parseConfig($basePath, $argv) |
|
132 | 132 | { |
133 | - $this->_basePath = dirname ( $basePath ); |
|
133 | + $this->_basePath = dirname($basePath); |
|
134 | 134 | |
135 | - $configIni = isset( $argv[ 'config-ini' ] ) |
|
136 | - ? $argv[ 'config-ini' ] |
|
135 | + $configIni = isset($argv['config-ini']) |
|
136 | + ? $argv['config-ini'] |
|
137 | 137 | : $this->_basePath |
138 | 138 | . $this->configIniDefault; |
139 | 139 | |
140 | - $configTemp = $this->loadIniFile ( realpath ( $configIni ) ); |
|
141 | - $configCurrent = self::parseConfigEnv ( $configTemp, $argv ); |
|
140 | + $configTemp = $this->loadIniFile(realpath($configIni)); |
|
141 | + $configCurrent = self::parseConfigEnv($configTemp, $argv); |
|
142 | 142 | |
143 | - if ( !isset( $configCurrent[ 'framework' ] ) ) { |
|
144 | - throw new \Exception( "configure which framework you want to use! \n" ); |
|
143 | + if ( ! isset($configCurrent['framework'])) { |
|
144 | + throw new \Exception("configure which framework you want to use! \n"); |
|
145 | 145 | } |
146 | 146 | |
147 | - if ( !in_array ( $configCurrent[ 'framework' ], $this->frameworkList ) ) { |
|
148 | - $frameworks = implode ( "\n\t", $this->frameworkList ); |
|
149 | - throw new \Exception( "list of frameworks: \n\t\033[1;33m" . $frameworks . "\n\033[0m" ); |
|
147 | + if ( ! in_array($configCurrent['framework'], $this->frameworkList)) { |
|
148 | + $frameworks = implode("\n\t", $this->frameworkList); |
|
149 | + throw new \Exception("list of frameworks: \n\t\033[1;33m" . $frameworks . "\n\033[0m"); |
|
150 | 150 | } |
151 | 151 | |
152 | - return $argv + array_filter ( $configCurrent ); |
|
152 | + return $argv + array_filter($configCurrent); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -159,20 +159,20 @@ discard block |
||
159 | 159 | * |
160 | 160 | * @return string |
161 | 161 | */ |
162 | - private static function parseConfigEnv ( $configTemp, $argv ) |
|
162 | + private static function parseConfigEnv($configTemp, $argv) |
|
163 | 163 | { |
164 | - $thisSection = isset( $configTemp[ key ( $configTemp ) ][ 'config-env' ] ) ? $configTemp[ key ( |
|
164 | + $thisSection = isset($configTemp[key($configTemp)]['config-env']) ? $configTemp[key( |
|
165 | 165 | $configTemp |
166 | - ) ][ 'config-env' ] : null; |
|
166 | + )]['config-env'] : null; |
|
167 | 167 | |
168 | - $thisSection = isset( $argv[ 'config-env' ] ) ? $argv[ 'config-env' ] : $thisSection; |
|
168 | + $thisSection = isset($argv['config-env']) ? $argv['config-env'] : $thisSection; |
|
169 | 169 | |
170 | - if ( isset( $configTemp[ $thisSection ][ 'extends' ] ) ) { |
|
170 | + if (isset($configTemp[$thisSection]['extends'])) { |
|
171 | 171 | #faz marge da config principal com a config extendida |
172 | - return $configTemp[ $thisSection ] + $configTemp[ $configTemp[ $thisSection ][ 'extends' ] ]; |
|
172 | + return $configTemp[$thisSection] + $configTemp[$configTemp[$thisSection]['extends']]; |
|
173 | 173 | } |
174 | 174 | |
175 | - return $configTemp[ key ( $configTemp ) ]; |
|
175 | + return $configTemp[key($configTemp)]; |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | /** |
@@ -186,29 +186,29 @@ discard block |
||
186 | 186 | * @throws \Exception |
187 | 187 | * @return array |
188 | 188 | */ |
189 | - protected function loadIniFile ( $filename ) |
|
189 | + protected function loadIniFile($filename) |
|
190 | 190 | { |
191 | - if ( !is_file ( $filename ) ) { |
|
192 | - throw new \Exception( "configuration file does not exist! \n" ); |
|
191 | + if ( ! is_file($filename)) { |
|
192 | + throw new \Exception("configuration file does not exist! \n"); |
|
193 | 193 | } |
194 | 194 | |
195 | - $loaded = parse_ini_file ( $filename, true ); |
|
196 | - $iniArray = array (); |
|
197 | - foreach ( $loaded as $key => $data ) { |
|
198 | - $pieces = explode ( $this->sectionSeparator, $key ); |
|
199 | - $thisSection = trim ( $pieces[ 0 ] ); |
|
200 | - switch ( count ( $pieces ) ) { |
|
195 | + $loaded = parse_ini_file($filename, true); |
|
196 | + $iniArray = array(); |
|
197 | + foreach ($loaded as $key => $data) { |
|
198 | + $pieces = explode($this->sectionSeparator, $key); |
|
199 | + $thisSection = trim($pieces[0]); |
|
200 | + switch (count($pieces)) { |
|
201 | 201 | case 1: |
202 | - $iniArray[ $thisSection ] = $data; |
|
202 | + $iniArray[$thisSection] = $data; |
|
203 | 203 | break; |
204 | 204 | |
205 | 205 | case 2: |
206 | - $extendedSection = trim ( $pieces[ 1 ] ); |
|
207 | - $iniArray[ $thisSection ] = array_merge ( array ( 'extends' => $extendedSection ), $data ); |
|
206 | + $extendedSection = trim($pieces[1]); |
|
207 | + $iniArray[$thisSection] = array_merge(array('extends' => $extendedSection), $data); |
|
208 | 208 | break; |
209 | 209 | |
210 | 210 | default: |
211 | - throw new \Exception( "Section '$thisSection' may not extend multiple sections in $filename" ); |
|
211 | + throw new \Exception("Section '$thisSection' may not extend multiple sections in $filename"); |
|
212 | 212 | } |
213 | 213 | } |
214 | 214 | |
@@ -221,15 +221,15 @@ discard block |
||
221 | 221 | * @return \Classes\AdapterConfig\AbstractAdapter |
222 | 222 | * |
223 | 223 | */ |
224 | - private function factoryConfig () |
|
224 | + private function factoryConfig() |
|
225 | 225 | { |
226 | - switch ( strtolower ( $this->argv[ 'framework' ] ) ) { |
|
226 | + switch (strtolower($this->argv['framework'])) { |
|
227 | 227 | case 'zf1': |
228 | - return new ZendFrameworkOne( $this->argv ); |
|
228 | + return new ZendFrameworkOne($this->argv); |
|
229 | 229 | case 'phalcon': |
230 | - return new Phalcon( $this->argv ); |
|
230 | + return new Phalcon($this->argv); |
|
231 | 231 | default: |
232 | - return new None( $this->argv ); |
|
232 | + return new None($this->argv); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | } |
@@ -241,31 +241,31 @@ discard block |
||
241 | 241 | * |
242 | 242 | * @return AdaptersDriver\AbsractAdapter |
243 | 243 | */ |
244 | - private function factoryDriver ( AdapterConfig\AbstractAdapter $config ) |
|
244 | + private function factoryDriver(AdapterConfig\AbstractAdapter $config) |
|
245 | 245 | { |
246 | - switch ( $this->argv[ 'driver' ] ) { |
|
246 | + switch ($this->argv['driver']) { |
|
247 | 247 | case 'pgsql': |
248 | 248 | case 'pdo_pgsql': |
249 | - return new Pgsql( $config ); |
|
249 | + return new Pgsql($config); |
|
250 | 250 | case 'mysql': |
251 | 251 | case 'pdo_mysql': |
252 | - return new Mysql( $config ); |
|
252 | + return new Mysql($config); |
|
253 | 253 | case 'mssql': |
254 | - return new Mssql( $config ); |
|
254 | + return new Mssql($config); |
|
255 | 255 | case 'dblib': |
256 | - return new Dblib( $config ); |
|
256 | + return new Dblib($config); |
|
257 | 257 | case 'sqlsrv': |
258 | - return new Sqlsrv( $config ); |
|
258 | + return new Sqlsrv($config); |
|
259 | 259 | } |
260 | 260 | } |
261 | 261 | |
262 | 262 | /** |
263 | 263 | * @return AdapterConfig\AbstractAdapter |
264 | 264 | */ |
265 | - public function getAdapterConfig () |
|
265 | + public function getAdapterConfig() |
|
266 | 266 | { |
267 | - if ( !$this->adapterConfig instanceof AbstractAdapter ) { |
|
268 | - $this->adapterConfig = $this->factoryConfig (); |
|
267 | + if ( ! $this->adapterConfig instanceof AbstractAdapter) { |
|
268 | + $this->adapterConfig = $this->factoryConfig(); |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | return $this->adapterConfig; |
@@ -274,10 +274,10 @@ discard block |
||
274 | 274 | /** |
275 | 275 | * @return AdaptersDriver\AbsractAdapter |
276 | 276 | */ |
277 | - public function getAdapterDriver ( AdapterConfig\AbstractAdapter $config ) |
|
277 | + public function getAdapterDriver(AdapterConfig\AbstractAdapter $config) |
|
278 | 278 | { |
279 | - if ( !$this->adapterDriver ) { |
|
280 | - $this->adapterDriver = $this->factoryDriver ( $config ); |
|
279 | + if ( ! $this->adapterDriver) { |
|
280 | + $this->adapterDriver = $this->factoryDriver($config); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | return $this->adapterDriver; |