@@ -92,9 +92,9 @@ discard block |
||
92 | 92 | public function __construct($table, $connection) |
93 | 93 | { |
94 | 94 | $this->_connection = $connection; |
95 | - if (is_string($table)) { |
|
95 | + if(is_string($table)) { |
|
96 | 96 | $this->setTableName($table); |
97 | - } elseif ($table instanceof TDbTableInfo) { |
|
97 | + } elseif($table instanceof TDbTableInfo) { |
|
98 | 98 | $this->setTableInfo($table); |
99 | 99 | } else { |
100 | 100 | throw new TDbException('dbtablegateway_invalid_table_info'); |
@@ -242,7 +242,7 @@ discard block |
||
242 | 242 | public function findAll($criteria = null, $parameters = []) |
243 | 243 | { |
244 | 244 | $args = func_num_args() > 1 ? array_slice(func_get_args(), 1) : null; |
245 | - if ($criteria !== null) { |
|
245 | + if($criteria !== null) { |
|
246 | 246 | $criteria = $this->getCriteria($criteria, $parameters, $args); |
247 | 247 | } |
248 | 248 | return $this->getCommand()->findAll($criteria); |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | */ |
263 | 263 | public function findByPk($keys) |
264 | 264 | { |
265 | - if (func_num_args() > 1) { |
|
265 | + if(func_num_args() > 1) { |
|
266 | 266 | $keys = func_get_args(); |
267 | 267 | } |
268 | 268 | return $this->getCommand()->findByPk($keys); |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | */ |
288 | 288 | public function findAllByPks($keys) |
289 | 289 | { |
290 | - if (func_num_args() > 1) { |
|
290 | + if(func_num_args() > 1) { |
|
291 | 291 | $keys = func_get_args(); |
292 | 292 | } |
293 | 293 | return $this->getCommand()->findAllByPk($keys); |
@@ -336,7 +336,7 @@ discard block |
||
336 | 336 | */ |
337 | 337 | public function deleteByPk($keys) |
338 | 338 | { |
339 | - if (func_num_args() > 1) { |
|
339 | + if(func_num_args() > 1) { |
|
340 | 340 | $keys = func_get_args(); |
341 | 341 | } |
342 | 342 | return $this->getCommand()->deleteByPk($keys); |
@@ -347,7 +347,7 @@ discard block |
||
347 | 347 | */ |
348 | 348 | public function deleteAllByPks($keys) |
349 | 349 | { |
350 | - if (func_num_args() > 1) { |
|
350 | + if(func_num_args() > 1) { |
|
351 | 351 | $keys = func_get_args(); |
352 | 352 | } |
353 | 353 | return $this->deleteByPk($keys); |
@@ -362,7 +362,7 @@ discard block |
||
362 | 362 | public function count($criteria = null, $parameters = []) |
363 | 363 | { |
364 | 364 | $args = func_num_args() > 1 ? array_slice(func_get_args(), 1) : null; |
365 | - if ($criteria !== null) { |
|
365 | + if($criteria !== null) { |
|
366 | 366 | $criteria = $this->getCriteria($criteria, $parameters, $args); |
367 | 367 | } |
368 | 368 | return $this->getCommand()->count($criteria); |
@@ -420,10 +420,10 @@ discard block |
||
420 | 420 | */ |
421 | 421 | protected function getCriteria($criteria, $parameters, $args) |
422 | 422 | { |
423 | - if (is_string($criteria)) { |
|
423 | + if(is_string($criteria)) { |
|
424 | 424 | $useArgs = !is_array($parameters) && is_array($args); |
425 | 425 | return new TSqlCriteria($criteria, $useArgs ? $args : $parameters); |
426 | - } elseif ($criteria instanceof TSqlCriteria) { |
|
426 | + } elseif($criteria instanceof TSqlCriteria) { |
|
427 | 427 | return $criteria; |
428 | 428 | } else { |
429 | 429 | throw new TDbException('dbtablegateway_invalid_criteria'); |
@@ -462,20 +462,20 @@ discard block |
||
462 | 462 | public function __call($method, $args) |
463 | 463 | { |
464 | 464 | $delete = false; |
465 | - if ($findOne = substr(strtolower($method), 0, 6) === 'findby') { |
|
465 | + if($findOne = substr(strtolower($method), 0, 6) === 'findby') { |
|
466 | 466 | $condition = $method[6] === '_' ? substr($method, 7) : substr($method, 6); |
467 | - } elseif (substr(strtolower($method), 0, 9) === 'findallby') { |
|
467 | + } elseif(substr(strtolower($method), 0, 9) === 'findallby') { |
|
468 | 468 | $condition = $method[9] === '_' ? substr($method, 10) : substr($method, 9); |
469 | - } elseif ($delete = substr(strtolower($method), 0, 8) === 'deleteby') { |
|
469 | + } elseif($delete = substr(strtolower($method), 0, 8) === 'deleteby') { |
|
470 | 470 | $condition = $method[8] === '_' ? substr($method, 9) : substr($method, 8); |
471 | - } elseif ($delete = substr(strtolower($method), 0, 11) === 'deleteallby') { |
|
471 | + } elseif($delete = substr(strtolower($method), 0, 11) === 'deleteallby') { |
|
472 | 472 | $condition = $method[11] === '_' ? substr($method, 12) : substr($method, 11); |
473 | 473 | } else { |
474 | 474 | return null; |
475 | 475 | } |
476 | 476 | |
477 | 477 | $criteria = $this->getCommand()->createCriteriaFromString($method, $condition, $args); |
478 | - if ($delete) { |
|
478 | + if($delete) { |
|
479 | 479 | return $this->deleteAll($criteria); |
480 | 480 | } else { |
481 | 481 | return $findOne ? $this->find($criteria) : $this->findAll($criteria); |
@@ -227,12 +227,12 @@ discard block |
||
227 | 227 | */ |
228 | 228 | public function __construct($data = [], $connection = null) |
229 | 229 | { |
230 | - if ($connection !== null) { |
|
230 | + if($connection !== null) { |
|
231 | 231 | $this->setDbConnection($connection); |
232 | 232 | } |
233 | 233 | $this->setupColumnMapping(); |
234 | 234 | $this->setupRelations(); |
235 | - if (!empty($data)) { //$data may be an object |
|
235 | + if(!empty($data)) { //$data may be an object |
|
236 | 236 | $this->copyFrom($data); |
237 | 237 | } |
238 | 238 | } |
@@ -247,7 +247,7 @@ discard block |
||
247 | 247 | */ |
248 | 248 | public function __get($name) |
249 | 249 | { |
250 | - if ($this->hasRecordRelation($name) && !$this->canGetProperty($name)) { |
|
250 | + if($this->hasRecordRelation($name) && !$this->canGetProperty($name)) { |
|
251 | 251 | $this->fetchResultsFor($name); |
252 | 252 | return $this->$name; |
253 | 253 | } |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | */ |
265 | 265 | public function __set($name, $value) |
266 | 266 | { |
267 | - if ($this->hasRecordRelation($name) && !$this->canSetProperty($name)) { |
|
267 | + if($this->hasRecordRelation($name) && !$this->canSetProperty($name)) { |
|
268 | 268 | $this->$name = $value; |
269 | 269 | } else { |
270 | 270 | parent::__set($name, $value); |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | private function setupColumnMapping() |
278 | 278 | { |
279 | 279 | $className = get_class($this); |
280 | - if (!isset(self::$_columnMapping[$className])) { |
|
280 | + if(!isset(self::$_columnMapping[$className])) { |
|
281 | 281 | $class = new ReflectionClass($className); |
282 | 282 | self::$_columnMapping[$className] = $class->getStaticPropertyValue('COLUMN_MAPPING'); |
283 | 283 | } |
@@ -289,11 +289,11 @@ discard block |
||
289 | 289 | private function setupRelations() |
290 | 290 | { |
291 | 291 | $className = get_class($this); |
292 | - if (!isset(self::$_relations[$className])) { |
|
292 | + if(!isset(self::$_relations[$className])) { |
|
293 | 293 | $class = new ReflectionClass($className); |
294 | 294 | $relations = []; |
295 | - foreach ($class->getStaticPropertyValue('RELATIONS') as $key => $value) { |
|
296 | - $relations[strtolower($key)] = [$key,$value]; |
|
295 | + foreach($class->getStaticPropertyValue('RELATIONS') as $key => $value) { |
|
296 | + $relations[strtolower($key)] = [$key, $value]; |
|
297 | 297 | } |
298 | 298 | self::$_relations[$className] = $relations; |
299 | 299 | } |
@@ -305,13 +305,13 @@ discard block |
||
305 | 305 | */ |
306 | 306 | public function copyFrom($data) |
307 | 307 | { |
308 | - if (is_object($data)) { |
|
308 | + if(is_object($data)) { |
|
309 | 309 | $data = get_object_vars($data); |
310 | 310 | } |
311 | - if (!is_array($data)) { |
|
311 | + if(!is_array($data)) { |
|
312 | 312 | throw new TActiveRecordException('ar_data_invalid', get_class($this)); |
313 | 313 | } |
314 | - foreach ($data as $name => $value) { |
|
314 | + foreach($data as $name => $value) { |
|
315 | 315 | $this->setColumnValue($name, $value); |
316 | 316 | } |
317 | 317 | } |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | |
320 | 320 | public static function getActiveDbConnection() |
321 | 321 | { |
322 | - if (($db = self::getRecordManager()->getDbConnection()) !== null) { |
|
322 | + if(($db = self::getRecordManager()->getDbConnection()) !== null) { |
|
323 | 323 | $db->setActive(true); |
324 | 324 | } |
325 | 325 | return $db; |
@@ -332,7 +332,7 @@ discard block |
||
332 | 332 | */ |
333 | 333 | public function getDbConnection() |
334 | 334 | { |
335 | - if ($this->_connection === null) { |
|
335 | + if($this->_connection === null) { |
|
336 | 336 | $this->_connection = self::getActiveDbConnection(); |
337 | 337 | } |
338 | 338 | return $this->_connection; |
@@ -364,20 +364,20 @@ discard block |
||
364 | 364 | */ |
365 | 365 | public function equals(TActiveRecord $record, $strict = false) |
366 | 366 | { |
367 | - if ($record === null || get_class($this) !== get_class($record)) { |
|
367 | + if($record === null || get_class($this) !== get_class($record)) { |
|
368 | 368 | return false; |
369 | 369 | } |
370 | 370 | $tableInfo = $this->getRecordTableInfo(); |
371 | 371 | $pks = $tableInfo->getPrimaryKeys(); |
372 | 372 | $properties = count($pks) > 0 ? $pks : $tableInfo->getColumns()->getKeys(); |
373 | 373 | $equals = true; |
374 | - foreach ($properties as $prop) { |
|
375 | - if ($strict) { |
|
374 | + foreach($properties as $prop) { |
|
375 | + if($strict) { |
|
376 | 376 | $equals = $equals && $this->getColumnValue($prop) === $record->getColumnValue($prop); |
377 | 377 | } else { |
378 | 378 | $equals = $equals && $this->getColumnValue($prop) == $record->getColumnValue($prop); |
379 | 379 | } |
380 | - if (!$equals) { |
|
380 | + if(!$equals) { |
|
381 | 381 | return false; |
382 | 382 | } |
383 | 383 | } |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | public static function finder($className = __CLASS__) |
397 | 397 | { |
398 | 398 | static $finders = []; |
399 | - if (!isset($finders[$className])) { |
|
399 | + if(!isset($finders[$className])) { |
|
400 | 400 | $f = Prado::createComponent($className); |
401 | 401 | $finders[$className] = $f; |
402 | 402 | } |
@@ -429,15 +429,15 @@ discard block |
||
429 | 429 | { |
430 | 430 | $gateway = $this->getRecordGateway(); |
431 | 431 | $param = new TActiveRecordChangeEventParameter(); |
432 | - if ($this->_recordState === self::STATE_NEW) { |
|
432 | + if($this->_recordState === self::STATE_NEW) { |
|
433 | 433 | $this->onInsert($param); |
434 | - if ($param->getIsValid() && $gateway->insert($this)) { |
|
434 | + if($param->getIsValid() && $gateway->insert($this)) { |
|
435 | 435 | $this->_recordState = self::STATE_LOADED; |
436 | 436 | return true; |
437 | 437 | } |
438 | - } elseif ($this->_recordState === self::STATE_LOADED) { |
|
438 | + } elseif($this->_recordState === self::STATE_LOADED) { |
|
439 | 439 | $this->onUpdate($param); |
440 | - if ($param->getIsValid() && $gateway->update($this)) { |
|
440 | + if($param->getIsValid() && $gateway->update($this)) { |
|
441 | 441 | return true; |
442 | 442 | } |
443 | 443 | } else { |
@@ -454,11 +454,11 @@ discard block |
||
454 | 454 | */ |
455 | 455 | public function delete() |
456 | 456 | { |
457 | - if ($this->_recordState === self::STATE_LOADED) { |
|
457 | + if($this->_recordState === self::STATE_LOADED) { |
|
458 | 458 | $gateway = $this->getRecordGateway(); |
459 | 459 | $param = new TActiveRecordChangeEventParameter(); |
460 | 460 | $this->onDelete($param); |
461 | - if ($param->getIsValid() && $gateway->delete($this)) { |
|
461 | + if($param->getIsValid() && $gateway->delete($this)) { |
|
462 | 462 | $this->_recordState = self::STATE_DELETED; |
463 | 463 | return true; |
464 | 464 | } |
@@ -494,10 +494,10 @@ discard block |
||
494 | 494 | */ |
495 | 495 | public function deleteByPk($keys) |
496 | 496 | { |
497 | - if (func_num_args() > 1) { |
|
497 | + if(func_num_args() > 1) { |
|
498 | 498 | $keys = func_get_args(); |
499 | 499 | } |
500 | - return $this->getRecordGateway()->deleteRecordsByPk($this, (array)$keys); |
|
500 | + return $this->getRecordGateway()->deleteRecordsByPk($this, (array) $keys); |
|
501 | 501 | } |
502 | 502 | |
503 | 503 | /** |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | */ |
506 | 506 | public function deleteAllByPks($keys) |
507 | 507 | { |
508 | - if (func_num_args() > 1) { |
|
508 | + if(func_num_args() > 1) { |
|
509 | 509 | $keys = func_get_args(); |
510 | 510 | } |
511 | 511 | return $this->deleteByPk($keys); |
@@ -542,7 +542,7 @@ discard block |
||
542 | 542 | protected function populateObjects($reader) |
543 | 543 | { |
544 | 544 | $result = []; |
545 | - foreach ($reader as $data) { |
|
545 | + foreach($reader as $data) { |
|
546 | 546 | $result[] = $this->populateObject($data); |
547 | 547 | } |
548 | 548 | return $result; |
@@ -559,7 +559,7 @@ discard block |
||
559 | 559 | */ |
560 | 560 | public static function createRecord($type, $data) |
561 | 561 | { |
562 | - if (empty($data)) { |
|
562 | + if(empty($data)) { |
|
563 | 563 | return null; |
564 | 564 | } |
565 | 565 | $record = new $type($data); |
@@ -603,7 +603,7 @@ discard block |
||
603 | 603 | public function findAll($criteria = null, $parameters = []) |
604 | 604 | { |
605 | 605 | $args = func_num_args() > 1 ? array_slice(func_get_args(), 1) : null; |
606 | - if ($criteria !== null) { |
|
606 | + if($criteria !== null) { |
|
607 | 607 | $criteria = $this->getRecordCriteria($criteria, $parameters, $args); |
608 | 608 | } |
609 | 609 | $result = $this->getRecordGateway()->findRecordsByCriteria($this, $criteria, true); |
@@ -624,10 +624,10 @@ discard block |
||
624 | 624 | */ |
625 | 625 | public function findByPk($keys) |
626 | 626 | { |
627 | - if ($keys === null) { |
|
627 | + if($keys === null) { |
|
628 | 628 | return null; |
629 | 629 | } |
630 | - if (func_num_args() > 1) { |
|
630 | + if(func_num_args() > 1) { |
|
631 | 631 | $keys = func_get_args(); |
632 | 632 | } |
633 | 633 | $data = $this->getRecordGateway()->findRecordByPK($this, $keys); |
@@ -653,10 +653,10 @@ discard block |
||
653 | 653 | */ |
654 | 654 | public function findAllByPks($keys) |
655 | 655 | { |
656 | - if (func_num_args() > 1) { |
|
656 | + if(func_num_args() > 1) { |
|
657 | 657 | $keys = func_get_args(); |
658 | 658 | } |
659 | - $result = $this->getRecordGateway()->findRecordsByPks($this, (array)$keys); |
|
659 | + $result = $this->getRecordGateway()->findRecordsByPks($this, (array) $keys); |
|
660 | 660 | return $this->populateObjects($result); |
661 | 661 | } |
662 | 662 | |
@@ -720,7 +720,7 @@ discard block |
||
720 | 720 | public function count($criteria = null, $parameters = []) |
721 | 721 | { |
722 | 722 | $args = func_num_args() > 1 ? array_slice(func_get_args(), 1) : null; |
723 | - if ($criteria !== null) { |
|
723 | + if($criteria !== null) { |
|
724 | 724 | $criteria = $this->getRecordCriteria($criteria, $parameters, $args); |
725 | 725 | } |
726 | 726 | return $this->getRecordGateway()->countRecords($this, $criteria); |
@@ -735,7 +735,7 @@ discard block |
||
735 | 735 | */ |
736 | 736 | protected function getRelationHandler($name, $args = []) |
737 | 737 | { |
738 | - if (($context = $this->createRelationContext($name)) !== null) { |
|
738 | + if(($context = $this->createRelationContext($name)) !== null) { |
|
739 | 739 | $criteria = $this->getRecordCriteria(count($args) > 0 ? $args[0] : null, array_slice($args, 1)); |
740 | 740 | return $context->getRelationHandler($criteria); |
741 | 741 | } else { |
@@ -754,7 +754,7 @@ discard block |
||
754 | 754 | */ |
755 | 755 | protected function createRelationContext($name) |
756 | 756 | { |
757 | - if (($definition = $this->getRecordRelation($name)) !== null) { |
|
757 | + if(($definition = $this->getRecordRelation($name)) !== null) { |
|
758 | 758 | list($property, $relation) = $definition; |
759 | 759 | return new TActiveRecordRelationContext($this, $property, $relation); |
760 | 760 | } else { |
@@ -799,7 +799,7 @@ discard block |
||
799 | 799 | */ |
800 | 800 | protected function fetchResultsFor($property) |
801 | 801 | { |
802 | - if (($context = $this->createRelationContext($property)) !== null) { |
|
802 | + if(($context = $this->createRelationContext($property)) !== null) { |
|
803 | 803 | return $context->getRelationHandler()->fetchResultsInto($this); |
804 | 804 | } else { |
805 | 805 | return false; |
@@ -838,19 +838,19 @@ discard block |
||
838 | 838 | public function __call($method, $args) |
839 | 839 | { |
840 | 840 | $delete = false; |
841 | - if (strncasecmp($method, 'with', 4) === 0) { |
|
841 | + if(strncasecmp($method, 'with', 4) === 0) { |
|
842 | 842 | $property = $method[4] === '_' ? substr($method, 5) : substr($method, 4); |
843 | 843 | return $this->getRelationHandler($property, $args); |
844 | - } elseif ($findOne = strncasecmp($method, 'findby', 6) === 0) { |
|
844 | + } elseif($findOne = strncasecmp($method, 'findby', 6) === 0) { |
|
845 | 845 | $condition = $method[6] === '_' ? substr($method, 7) : substr($method, 6); |
846 | - } elseif (strncasecmp($method, 'findallby', 9) === 0) { |
|
846 | + } elseif(strncasecmp($method, 'findallby', 9) === 0) { |
|
847 | 847 | $condition = $method[9] === '_' ? substr($method, 10) : substr($method, 9); |
848 | - } elseif ($delete = strncasecmp($method, 'deleteby', 8) === 0) { |
|
848 | + } elseif($delete = strncasecmp($method, 'deleteby', 8) === 0) { |
|
849 | 849 | $condition = $method[8] === '_' ? substr($method, 9) : substr($method, 8); |
850 | - } elseif ($delete = strncasecmp($method, 'deleteallby', 11) === 0) { |
|
850 | + } elseif($delete = strncasecmp($method, 'deleteallby', 11) === 0) { |
|
851 | 851 | $condition = $method[11] === '_' ? substr($method, 12) : substr($method, 11); |
852 | 852 | } else { |
853 | - if ($this->getInvalidFinderResult() == TActiveRecordInvalidFinderResult::Exception) { |
|
853 | + if($this->getInvalidFinderResult() == TActiveRecordInvalidFinderResult::Exception) { |
|
854 | 854 | throw new TActiveRecordException('ar_invalid_finder_method', $method); |
855 | 855 | } else { |
856 | 856 | return null; |
@@ -858,7 +858,7 @@ discard block |
||
858 | 858 | } |
859 | 859 | |
860 | 860 | $criteria = $this->getRecordGateway()->getCommand($this)->createCriteriaFromString($method, $condition, $args); |
861 | - if ($delete) { |
|
861 | + if($delete) { |
|
862 | 862 | return $this->deleteAll($criteria); |
863 | 863 | } else { |
864 | 864 | return $findOne ? $this->find($criteria) : $this->findAll($criteria); |
@@ -872,7 +872,7 @@ discard block |
||
872 | 872 | */ |
873 | 873 | public function getInvalidFinderResult() |
874 | 874 | { |
875 | - if ($this->_invalidFinderResult !== null) { |
|
875 | + if($this->_invalidFinderResult !== null) { |
|
876 | 876 | return $this->_invalidFinderResult; |
877 | 877 | } |
878 | 878 | |
@@ -887,7 +887,7 @@ discard block |
||
887 | 887 | */ |
888 | 888 | public function setInvalidFinderResult($value) |
889 | 889 | { |
890 | - if ($value === null) { |
|
890 | + if($value === null) { |
|
891 | 891 | $this->_invalidFinderResult = null; |
892 | 892 | } else { |
893 | 893 | $this->_invalidFinderResult = TPropertyValue::ensureEnum($value, 'Prado\\Data\\ActiveRecord\\TActiveRecordInvalidFinderResult'); |
@@ -905,10 +905,10 @@ discard block |
||
905 | 905 | */ |
906 | 906 | protected function getRecordCriteria($criteria, $parameters, $args = []) |
907 | 907 | { |
908 | - if (is_string($criteria)) { |
|
908 | + if(is_string($criteria)) { |
|
909 | 909 | $useArgs = !is_array($parameters) && is_array($args); |
910 | 910 | return new TActiveRecordCriteria($criteria, $useArgs ? $args : $parameters); |
911 | - } elseif ($criteria instanceof TSqlCriteria) { |
|
911 | + } elseif($criteria instanceof TSqlCriteria) { |
|
912 | 912 | return $criteria; |
913 | 913 | } else { |
914 | 914 | return new TActiveRecordCriteria(); |
@@ -989,7 +989,7 @@ discard block |
||
989 | 989 | public function getColumnValue($columnName) |
990 | 990 | { |
991 | 991 | $className = get_class($this); |
992 | - if (isset(self::$_columnMapping[$className][$columnName])) { |
|
992 | + if(isset(self::$_columnMapping[$className][$columnName])) { |
|
993 | 993 | $columnName = self::$_columnMapping[$className][$columnName]; |
994 | 994 | } |
995 | 995 | return $this->$columnName; |
@@ -1005,7 +1005,7 @@ discard block |
||
1005 | 1005 | public function setColumnValue($columnName, $value) |
1006 | 1006 | { |
1007 | 1007 | $className = get_class($this); |
1008 | - if (isset(self::$_columnMapping[$className][$columnName])) { |
|
1008 | + if(isset(self::$_columnMapping[$className][$columnName])) { |
|
1009 | 1009 | $columnName = self::$_columnMapping[$className][$columnName]; |
1010 | 1010 | } |
1011 | 1011 | $this->$columnName = $value; |
@@ -1050,7 +1050,7 @@ discard block |
||
1050 | 1050 | public function toArray() |
1051 | 1051 | { |
1052 | 1052 | $result = []; |
1053 | - foreach ($this->getRecordTableInfo()->getLowerCaseColumnNames() as $columnName) { |
|
1053 | + foreach($this->getRecordTableInfo()->getLowerCaseColumnNames() as $columnName) { |
|
1054 | 1054 | $result[$columnName] = $this->getColumnValue($columnName); |
1055 | 1055 | } |
1056 | 1056 |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | protected function getRecordPropertyValues($record) |
59 | 59 | { |
60 | 60 | $data = []; |
61 | - foreach ($this->getTableInfo()->getColumns() as $name => $column) { |
|
61 | + foreach($this->getTableInfo()->getColumns() as $name => $column) { |
|
62 | 62 | $data[] = $record->getColumnValue($name); |
63 | 63 | } |
64 | 64 | return $data; |
@@ -71,8 +71,8 @@ discard block |
||
71 | 71 | protected function getRecordPkValues($record) |
72 | 72 | { |
73 | 73 | $data = []; |
74 | - foreach ($this->getTableInfo()->getColumns() as $name => $column) { |
|
75 | - if ($column->getIsPrimaryKey()) { |
|
74 | + foreach($this->getTableInfo()->getColumns() as $name => $column) { |
|
75 | + if($column->getIsPrimaryKey()) { |
|
76 | 76 | $data[] = $record->getColumnValue($name); |
77 | 77 | } |
78 | 78 | } |
@@ -124,10 +124,10 @@ discard block |
||
124 | 124 | */ |
125 | 125 | protected function getRecordObject($pk = null) |
126 | 126 | { |
127 | - if ($this->_record === null) { |
|
128 | - if ($pk !== null) { |
|
127 | + if($this->_record === null) { |
|
128 | + if($pk !== null) { |
|
129 | 129 | $this->_record = $this->getRecordFinder()->findByPk($pk); |
130 | - if ($this->_record === null) { |
|
130 | + if($this->_record === null) { |
|
131 | 131 | throw new TConfigurationException( |
132 | 132 | 'scaffold_invalid_record_pk', |
133 | 133 | $this->getRecordClass(), |
@@ -136,7 +136,7 @@ discard block |
||
136 | 136 | } |
137 | 137 | } else { |
138 | 138 | $class = $this->getRecordClass(); |
139 | - if ($class !== null) { |
|
139 | + if($class !== null) { |
|
140 | 140 | $this->_record = Prado::createComponent($class); |
141 | 141 | } else { |
142 | 142 | throw new TConfigurationException( |
@@ -204,7 +204,7 @@ discard block |
||
204 | 204 | public function onPreRender($param) |
205 | 205 | { |
206 | 206 | parent::onPreRender($param); |
207 | - if ($this->getEnableDefaultStyle()) { |
|
207 | + if($this->getEnableDefaultStyle()) { |
|
208 | 208 | $url = $this->publishAsset($this->getDefaultStyle() . '.css'); |
209 | 209 | $this->getPage()->getClientScript()->registerStyleSheetFile($url, $url); |
210 | 210 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | */ |
64 | 64 | public function onLoad($param) |
65 | 65 | { |
66 | - if ($this->getVisible()) { |
|
66 | + if($this->getVisible()) { |
|
67 | 67 | $this->initializeEditForm(); |
68 | 68 | } |
69 | 69 | } |
@@ -117,12 +117,12 @@ discard block |
||
117 | 117 | { |
118 | 118 | $record = $this->getCurrentRecord(); |
119 | 119 | $classPath = $this->getEditRenderer(); |
120 | - if ($classPath === '') { |
|
120 | + if($classPath === '') { |
|
121 | 121 | $columns = $this->getTableInfo()->getColumns(); |
122 | 122 | $this->getInputRepeater()->setDataSource($columns); |
123 | 123 | $this->getInputRepeater()->dataBind(); |
124 | 124 | } else { |
125 | - if ($this->_editRenderer === null) { |
|
125 | + if($this->_editRenderer === null) { |
|
126 | 126 | $this->createEditRenderer($record, $classPath); |
127 | 127 | } else { |
128 | 128 | $this->_editRenderer->setData($record); |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | protected function createEditRenderer($record, $classPath) |
141 | 141 | { |
142 | 142 | $this->_editRenderer = Prado::createComponent($classPath); |
143 | - if ($this->_editRenderer instanceof IScaffoldEditRenderer) { |
|
143 | + if($this->_editRenderer instanceof IScaffoldEditRenderer) { |
|
144 | 144 | $index = $this->getControls()->remove($this->getInputRepeater()); |
145 | 145 | $this->getControls()->insertAt($index, $this->_editRenderer); |
146 | 146 | $this->_editRenderer->setData($record); |
@@ -159,10 +159,10 @@ discard block |
||
159 | 159 | protected function createRepeaterEditItem($sender, $param) |
160 | 160 | { |
161 | 161 | $type = $param->getItem()->getItemType(); |
162 | - if ($type == TListItemType::Item || $type == TListItemType::AlternatingItem) { |
|
162 | + if($type == TListItemType::Item || $type == TListItemType::AlternatingItem) { |
|
163 | 163 | $item = $param->getItem(); |
164 | 164 | $column = $item->getData(); |
165 | - if ($column === null) { |
|
165 | + if($column === null) { |
|
166 | 166 | return; |
167 | 167 | } |
168 | 168 | |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | */ |
179 | 179 | public function bubbleEvent($sender, $param) |
180 | 180 | { |
181 | - switch (strtolower($param->getCommandName())) { |
|
181 | + switch(strtolower($param->getCommandName())) { |
|
182 | 182 | case 'save': |
183 | 183 | return $this->doSave() ? false : true; |
184 | 184 | case 'clear': |
@@ -196,12 +196,12 @@ discard block |
||
196 | 196 | */ |
197 | 197 | protected function doSave() |
198 | 198 | { |
199 | - if ($this->getPage()->getIsValid()) { |
|
199 | + if($this->getPage()->getIsValid()) { |
|
200 | 200 | $record = $this->getCurrentRecord(); |
201 | - if ($this->_editRenderer === null) { |
|
201 | + if($this->_editRenderer === null) { |
|
202 | 202 | $table = $this->getTableInfo(); |
203 | 203 | $builder = $this->getScaffoldInputBuilder($record); |
204 | - foreach ($this->getInputRepeater()->getItems() as $item) { |
|
204 | + foreach($this->getInputRepeater()->getItems() as $item) { |
|
205 | 205 | $column = $table->getColumn($item->getCustomData()); |
206 | 206 | $builder->loadScaffoldInput($this, $item, $column, $record); |
207 | 207 | } |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | } |
211 | 211 | $record->save(); |
212 | 212 | return true; |
213 | - } elseif ($this->_editRenderer !== null) { |
|
213 | + } elseif($this->_editRenderer !== null) { |
|
214 | 214 | //preserve the form data. |
215 | 215 | $this->_editRenderer->updateRecord($this->getCurrentRecord()); |
216 | 216 | } |
@@ -263,7 +263,7 @@ discard block |
||
263 | 263 | { |
264 | 264 | static $_builders = []; |
265 | 265 | $class = get_class($record); |
266 | - if (!isset($_builders[$class])) { |
|
266 | + if(!isset($_builders[$class])) { |
|
267 | 267 | $_builders[$class] = TScaffoldInputBase::createInputBuilder($record); |
268 | 268 | } |
269 | 269 | return $_builders[$class]; |
@@ -64,11 +64,11 @@ discard block |
||
64 | 64 | $table = $this->getTableInfo(); |
65 | 65 | $sorts = ['Sort By', str_repeat('-', 15)]; |
66 | 66 | $headers = []; |
67 | - foreach ($table->getColumns() as $name => $colum) { |
|
67 | + foreach($table->getColumns() as $name => $colum) { |
|
68 | 68 | $fname = ucwords(str_replace('_', ' ', $name)); |
69 | 69 | $sorts[$name . ' ASC'] = $fname . ' Ascending'; |
70 | 70 | $sorts[$name . ' DESC'] = $fname . ' Descending'; |
71 | - $headers[] = $fname ; |
|
71 | + $headers[] = $fname; |
|
72 | 72 | } |
73 | 73 | $this->_sort->setDataSource($sorts); |
74 | 74 | $this->_sort->dataBind(); |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | public function onPreRender($param) |
83 | 83 | { |
84 | 84 | parent::onPreRender($param); |
85 | - if (!$this->getPage()->getIsPostBack() || $this->getViewState('CurrentClass') != $this->getRecordClass()) { |
|
85 | + if(!$this->getPage()->getIsPostBack() || $this->getViewState('CurrentClass') != $this->getRecordClass()) { |
|
86 | 86 | $this->initializeSort(); |
87 | 87 | $this->setViewState('CurrentClass', $this->getRecordClass()); |
88 | 88 | } |
@@ -110,18 +110,18 @@ discard block |
||
110 | 110 | $total = $this->_list->getVirtualItemCount(); |
111 | 111 | $limit = $this->_list->getPageSize(); |
112 | 112 | $offset = $this->_list->getCurrentPageIndex() * $limit; |
113 | - if ($offset + $limit > $total) { |
|
113 | + if($offset + $limit > $total) { |
|
114 | 114 | $limit = $total - $offset; |
115 | 115 | } |
116 | 116 | $criteria = new TActiveRecordCriteria($this->getSearchCondition(), $this->getSearchParameters()); |
117 | - if ($limit > 0) { |
|
117 | + if($limit > 0) { |
|
118 | 118 | $criteria->setLimit($limit); |
119 | - if ($offset <= $total) { |
|
119 | + if($offset <= $total) { |
|
120 | 120 | $criteria->setOffset($offset); |
121 | 121 | } |
122 | 122 | } |
123 | 123 | $order = explode(' ', $this->_sort->getSelectedValue(), 2); |
124 | - if (is_array($order) && count($order) === 2) { |
|
124 | + if(is_array($order) && count($order) === 2) { |
|
125 | 125 | $criteria->OrdersBy[$order[0]] = $order[1]; |
126 | 126 | } |
127 | 127 | return $criteria; |
@@ -164,7 +164,7 @@ discard block |
||
164 | 164 | */ |
165 | 165 | public function bubbleEvent($sender, $param) |
166 | 166 | { |
167 | - switch (strtolower($param->getCommandName())) { |
|
167 | + switch(strtolower($param->getCommandName())) { |
|
168 | 168 | case 'delete': |
169 | 169 | return $this->deleteRecord($sender, $param); |
170 | 170 | case 'edit': |
@@ -179,8 +179,8 @@ discard block |
||
179 | 179 | */ |
180 | 180 | protected function initializeEdit($sender, $param) |
181 | 181 | { |
182 | - if (($ctrl = $this->getEditViewControl()) !== null) { |
|
183 | - if ($param instanceof TRepeaterCommandEventParameter) { |
|
182 | + if(($ctrl = $this->getEditViewControl()) !== null) { |
|
183 | + if($param instanceof TRepeaterCommandEventParameter) { |
|
184 | 184 | $pk = $param->getItem()->getCustomData(); |
185 | 185 | $ctrl->setRecordPk($pk); |
186 | 186 | $ctrl->initializeEditForm(); |
@@ -193,7 +193,7 @@ discard block |
||
193 | 193 | */ |
194 | 194 | protected function deleteRecord($sender, $param) |
195 | 195 | { |
196 | - if ($param instanceof TRepeaterCommandEventParameter) { |
|
196 | + if($param instanceof TRepeaterCommandEventParameter) { |
|
197 | 197 | $pk = $param->getItem()->getCustomData(); |
198 | 198 | $this->getRecordFinder()->deleteByPk($pk); |
199 | 199 | } |
@@ -205,9 +205,9 @@ discard block |
||
205 | 205 | protected function listItemCreated($sender, $param) |
206 | 206 | { |
207 | 207 | $item = $param->getItem(); |
208 | - if ($item instanceof IItemDataRenderer) { |
|
208 | + if($item instanceof IItemDataRenderer) { |
|
209 | 209 | $type = $item->getItemType(); |
210 | - if ($type == TListItemType::Item || $type == TListItemType::AlternatingItem) { |
|
210 | + if($type == TListItemType::Item || $type == TListItemType::AlternatingItem) { |
|
211 | 211 | $this->populateField($sender, $param); |
212 | 212 | } |
213 | 213 | } |
@@ -220,9 +220,9 @@ discard block |
||
220 | 220 | protected function populateField($sender, $param) |
221 | 221 | { |
222 | 222 | $item = $param->getItem(); |
223 | - if (($data = $item->getData()) !== null) { |
|
223 | + if(($data = $item->getData()) !== null) { |
|
224 | 224 | $item->setCustomData($this->getRecordPkValues($data)); |
225 | - if (($prop = $item->findControl('_properties')) !== null) { |
|
225 | + if(($prop = $item->findControl('_properties')) !== null) { |
|
226 | 226 | $item->_properties->setDataSource($this->getRecordPropertyValues($data)); |
227 | 227 | $item->_properties->dataBind(); |
228 | 228 | } |
@@ -294,9 +294,9 @@ discard block |
||
294 | 294 | */ |
295 | 295 | protected function getEditViewControl() |
296 | 296 | { |
297 | - if (($id = $this->getEditViewID()) !== null) { |
|
297 | + if(($id = $this->getEditViewID()) !== null) { |
|
298 | 298 | $ctrl = $this->getParent()->findControl($id); |
299 | - if ($ctrl === null) { |
|
299 | + if($ctrl === null) { |
|
300 | 300 | throw new TConfigurationException('scaffold_unable_to_find_edit_view', $id); |
301 | 301 | } |
302 | 302 | return $ctrl; |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | { |
17 | 17 | protected function createControl($container, $column, $record) |
18 | 18 | { |
19 | - switch (strtolower($column->getDbType())) { |
|
19 | + switch(strtolower($column->getDbType())) { |
|
20 | 20 | case 'bit': |
21 | 21 | return $this->createBooleanControl($container, $column, $record); |
22 | 22 | case 'text': |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | return $this->createDateTimeControl($container, $column, $record); |
30 | 30 | default: |
31 | 31 | $control = $this->createDefaultControl($container, $column, $record); |
32 | - if ($column->getIsExcluded()) { |
|
32 | + if($column->getIsExcluded()) { |
|
33 | 33 | $control->setEnabled(false); |
34 | 34 | } |
35 | 35 | return $control; |
@@ -38,14 +38,14 @@ discard block |
||
38 | 38 | |
39 | 39 | protected function getControlValue($container, $column, $record) |
40 | 40 | { |
41 | - switch (strtolower($column->getDbType())) { |
|
41 | + switch(strtolower($column->getDbType())) { |
|
42 | 42 | case 'boolean': |
43 | 43 | return $container->findControl(self::DEFAULT_ID)->getChecked(); |
44 | 44 | case 'datetime': case 'smalldatetime': |
45 | 45 | return $this->getDateTimeValue($container, $column, $record); |
46 | 46 | default: |
47 | 47 | $value = $this->getDefaultControlValue($container, $column, $record); |
48 | - if (trim($value) === '' && $column->getAllowNull()) { |
|
48 | + if(trim($value) === '' && $column->getAllowNull()) { |
|
49 | 49 | return null; |
50 | 50 | } else { |
51 | 51 | return $value; |
@@ -27,7 +27,7 @@ discard block |
||
27 | 27 | { |
28 | 28 | $record->getDbConnection()->setActive(true); //must be connected before retrieving driver name! |
29 | 29 | $driver = $record->getDbConnection()->getDriverName(); |
30 | - switch (strtolower($driver)) { |
|
30 | + switch(strtolower($driver)) { |
|
31 | 31 | case 'sqlite': //sqlite 3 |
32 | 32 | case 'sqlite2': //sqlite 2 |
33 | 33 | require_once(dirname(__FILE__) . '/TSqliteScaffoldInput.php'); |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | $this->_parent = $parent; |
59 | 59 | $item->setCustomData($column->getColumnId()); |
60 | 60 | $this->createControl($item->_input, $column, $record); |
61 | - if ($item->_input->findControl(self::DEFAULT_ID)) { |
|
61 | + if($item->_input->findControl(self::DEFAULT_ID)) { |
|
62 | 62 | $this->createControlLabel($item->_label, $column, $record); |
63 | 63 | } |
64 | 64 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | public function loadScaffoldInput($parent, $item, $column, $record) |
74 | 74 | { |
75 | 75 | $this->_parent = $parent; |
76 | - if ($this->getIsEnabled($column, $record)) { |
|
76 | + if($this->getIsEnabled($column, $record)) { |
|
77 | 77 | $prop = $column->getColumnId(); |
78 | 78 | $record->setColumnValue($prop, $this->getControlValue($item->_input, $column, $record)); |
79 | 79 | } |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | protected function getRecordPropertyValue($column, $record) |
89 | 89 | { |
90 | 90 | $value = $record->getColumnValue($column->getColumnId()); |
91 | - if ($column->getDefaultValue() !== TDbTableColumn::UNDEFINED_VALUE && $value === null) { |
|
91 | + if($column->getDefaultValue() !== TDbTableColumn::UNDEFINED_VALUE && $value === null) { |
|
92 | 92 | return $column->getDefaultValue(); |
93 | 93 | } else { |
94 | 94 | return $value; |
@@ -17,7 +17,7 @@ discard block |
||
17 | 17 | { |
18 | 18 | protected function createControl($container, $column, $record) |
19 | 19 | { |
20 | - switch (strtolower($column->getDbType())) { |
|
20 | + switch(strtolower($column->getDbType())) { |
|
21 | 21 | case 'date': |
22 | 22 | return $this->createDateControl($container, $column, $record); |
23 | 23 | case 'time': |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | |
38 | 38 | protected function getControlValue($container, $column, $record) |
39 | 39 | { |
40 | - switch (strtolower($column->getDbType())) { |
|
40 | + switch(strtolower($column->getDbType())) { |
|
41 | 41 | case 'date': |
42 | 42 | return $container->findControl(self::DEFAULT_ID)->getDate(); |
43 | 43 | case 'time': |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | { |
17 | 17 | protected function createControl($container, $column, $record) |
18 | 18 | { |
19 | - switch (strtolower($column->getDbType())) { |
|
19 | + switch(strtolower($column->getDbType())) { |
|
20 | 20 | case 'boolean': |
21 | 21 | return $this->createBooleanControl($container, $column, $record); |
22 | 22 | case 'date': |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | |
39 | 39 | protected function getControlValue($container, $column, $record) |
40 | 40 | { |
41 | - switch (strtolower($column->getDbType())) { |
|
41 | + switch(strtolower($column->getDbType())) { |
|
42 | 42 | case 'boolean': |
43 | 43 | return $container->findControl(self::DEFAULT_ID)->getChecked(); |
44 | 44 | case 'date': |