@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public function generateAllDaosAndBeans($daoFactoryClassName, $daonamespace, $beannamespace, $support, $storeInUtc, $castDatesToDateTime) { |
63 | 63 | // TODO: migrate $this->daoNamespace to $daonamespace that is passed in parameter! |
64 | - $classNameMapper = ClassNameMapper::createFromComposerFile($this->rootPath.'composer.json'); |
|
64 | + $classNameMapper = ClassNameMapper::createFromComposerFile($this->rootPath.'composer.json'); |
|
65 | 65 | |
66 | 66 | $this->daoNamespace = $daonamespace; |
67 | 67 | $this->beanNamespace = $beannamespace; |
@@ -91,10 +91,10 @@ discard block |
||
91 | 91 | $beanName = $this->getBeanNameFromTableName($tableName); |
92 | 92 | $baseBeanName = $this->getBaseBeanNameFromTableName($tableName); |
93 | 93 | |
94 | - $connection = $this->dbConnection; |
|
95 | - if ($connection instanceof CachedConnection){ |
|
96 | - $connection->cacheService->purgeAll(); |
|
97 | - } |
|
94 | + $connection = $this->dbConnection; |
|
95 | + if ($connection instanceof CachedConnection){ |
|
96 | + $connection->cacheService->purgeAll(); |
|
97 | + } |
|
98 | 98 | |
99 | 99 | $this->generateBean($beanName, $baseBeanName, $tableName, $beannamespace, $classNameMapper, $storeInUtc, $castDatesToDateTime); |
100 | 100 | $this->generateDao($daoName, $daoName."Base", $beanName, $tableName, $classNameMapper, $support); |
@@ -130,16 +130,16 @@ discard block |
||
130 | 130 | return TDBMDaoGenerator::toSingular(TDBMDaoGenerator::toCamelCase($tableName))."BaseBean"; |
131 | 131 | } |
132 | 132 | |
133 | - /** |
|
134 | - * Writes the PHP bean file with all getters and setters from the table passed in parameter. |
|
135 | - * |
|
136 | - * @param string $className The name of the class |
|
137 | - * @param string $baseClassName The name of the base class which will be extended (name only, no directory) |
|
138 | - * @param string $tableName The name of the table |
|
139 | - * @param string $beannamespace The namespace of the bean |
|
140 | - * @param ClassNameMapper $classNameMapper |
|
141 | - * @throws TDBMException |
|
142 | - */ |
|
133 | + /** |
|
134 | + * Writes the PHP bean file with all getters and setters from the table passed in parameter. |
|
135 | + * |
|
136 | + * @param string $className The name of the class |
|
137 | + * @param string $baseClassName The name of the base class which will be extended (name only, no directory) |
|
138 | + * @param string $tableName The name of the table |
|
139 | + * @param string $beannamespace The namespace of the bean |
|
140 | + * @param ClassNameMapper $classNameMapper |
|
141 | + * @throws TDBMException |
|
142 | + */ |
|
143 | 143 | public function generateBean($className, $baseClassName, $tableName, $beannamespace, ClassNameMapper $classNameMapper, $storeInUtc, $castDatesToDateTime) { |
144 | 144 | $table = $this->dbConnection->getTableFromDbModel($tableName); |
145 | 145 | |
@@ -367,25 +367,25 @@ discard block |
||
367 | 367 | $str .= "} |
368 | 368 | ?>"; |
369 | 369 | |
370 | - $possibleBaseFileNames = $classNameMapper->getPossibleFileNames($beannamespace."\\".$baseClassName); |
|
371 | - if (!$possibleBaseFileNames) { |
|
372 | - throw new TDBMException('Sorry, autoload namespace issue. The class "'.$beannamespace."\\".$baseClassName.'" is not autoloadable.'); |
|
373 | - } |
|
374 | - $possibleBaseFileName = $this->rootPath.$possibleBaseFileNames[0]; |
|
370 | + $possibleBaseFileNames = $classNameMapper->getPossibleFileNames($beannamespace."\\".$baseClassName); |
|
371 | + if (!$possibleBaseFileNames) { |
|
372 | + throw new TDBMException('Sorry, autoload namespace issue. The class "'.$beannamespace."\\".$baseClassName.'" is not autoloadable.'); |
|
373 | + } |
|
374 | + $possibleBaseFileName = $this->rootPath.$possibleBaseFileNames[0]; |
|
375 | 375 | |
376 | - $this->ensureDirectoryExist($possibleBaseFileName); |
|
376 | + $this->ensureDirectoryExist($possibleBaseFileName); |
|
377 | 377 | file_put_contents($possibleBaseFileName, $str); |
378 | 378 | @chmod($possibleBaseFileName, 0664); |
379 | 379 | |
380 | 380 | |
381 | 381 | |
382 | - $possibleFileNames = $classNameMapper->getPossibleFileNames($beannamespace."\\".$className); |
|
383 | - if (!$possibleFileNames) { |
|
384 | - throw new TDBMException('Sorry, autoload namespace issue. The class "'.$beannamespace."\\".$className.'" is not autoloadable.'); |
|
385 | - } |
|
386 | - $possibleFileName = $this->rootPath.$possibleFileNames[0]; |
|
382 | + $possibleFileNames = $classNameMapper->getPossibleFileNames($beannamespace."\\".$className); |
|
383 | + if (!$possibleFileNames) { |
|
384 | + throw new TDBMException('Sorry, autoload namespace issue. The class "'.$beannamespace."\\".$className.'" is not autoloadable.'); |
|
385 | + } |
|
386 | + $possibleFileName = $this->rootPath.$possibleFileNames[0]; |
|
387 | 387 | |
388 | - if (!file_exists($possibleFileName)) { |
|
388 | + if (!file_exists($possibleFileName)) { |
|
389 | 389 | $str = "<?php |
390 | 390 | /* |
391 | 391 | * This file has been automatically generated by TDBM. |
@@ -403,7 +403,7 @@ discard block |
||
403 | 403 | { |
404 | 404 | |
405 | 405 | }"; |
406 | - $this->ensureDirectoryExist($possibleFileName); |
|
406 | + $this->ensureDirectoryExist($possibleFileName); |
|
407 | 407 | file_put_contents($possibleFileName ,$str); |
408 | 408 | @chmod($possibleFileName, 0664); |
409 | 409 | } |
@@ -659,21 +659,21 @@ discard block |
||
659 | 659 | } |
660 | 660 | ?>"; |
661 | 661 | |
662 | - $possibleBaseFileNames = $classNameMapper->getPossibleFileNames($this->daoNamespace."\\".$baseClassName); |
|
663 | - if (!$possibleBaseFileNames) { |
|
664 | - throw new TDBMException('Sorry, autoload namespace issue. The class "'.$baseClassName.'" is not autoloadable.'); |
|
665 | - } |
|
666 | - $possibleBaseFileName = $this->rootPath.$possibleBaseFileNames[0]; |
|
662 | + $possibleBaseFileNames = $classNameMapper->getPossibleFileNames($this->daoNamespace."\\".$baseClassName); |
|
663 | + if (!$possibleBaseFileNames) { |
|
664 | + throw new TDBMException('Sorry, autoload namespace issue. The class "'.$baseClassName.'" is not autoloadable.'); |
|
665 | + } |
|
666 | + $possibleBaseFileName = $this->rootPath.$possibleBaseFileNames[0]; |
|
667 | 667 | |
668 | - $this->ensureDirectoryExist($possibleBaseFileName); |
|
668 | + $this->ensureDirectoryExist($possibleBaseFileName); |
|
669 | 669 | file_put_contents($possibleBaseFileName ,$str); |
670 | 670 | @chmod($possibleBaseFileName, 0664); |
671 | 671 | |
672 | - $possibleFileNames = $classNameMapper->getPossibleFileNames($this->daoNamespace."\\".$className); |
|
673 | - if (!$possibleFileNames) { |
|
674 | - throw new TDBMException('Sorry, autoload namespace issue. The class "'.$className.'" is not autoloadable.'); |
|
675 | - } |
|
676 | - $possibleFileName = $this->rootPath.$possibleFileNames[0]; |
|
672 | + $possibleFileNames = $classNameMapper->getPossibleFileNames($this->daoNamespace."\\".$className); |
|
673 | + if (!$possibleFileNames) { |
|
674 | + throw new TDBMException('Sorry, autoload namespace issue. The class "'.$className.'" is not autoloadable.'); |
|
675 | + } |
|
676 | + $possibleFileName = $this->rootPath.$possibleFileNames[0]; |
|
677 | 677 | |
678 | 678 | // Now, let's generate the "editable" class |
679 | 679 | if (!file_exists($possibleFileName)) { |
@@ -693,7 +693,7 @@ discard block |
||
693 | 693 | { |
694 | 694 | |
695 | 695 | }"; |
696 | - $this->ensureDirectoryExist($possibleFileName); |
|
696 | + $this->ensureDirectoryExist($possibleFileName); |
|
697 | 697 | file_put_contents($possibleFileName ,$str); |
698 | 698 | @chmod($possibleFileName, 0664); |
699 | 699 | } |
@@ -760,13 +760,13 @@ discard block |
||
760 | 760 | } |
761 | 761 | ?>'; |
762 | 762 | |
763 | - $possibleFileNames = $classNameMapper->getPossibleFileNames($daoNamespace."\\".$daoFactoryClassName); |
|
764 | - if (!$possibleFileNames) { |
|
765 | - throw new TDBMException('Sorry, autoload namespace issue. The class "'.$daoNamespace."\\".$daoFactoryClassName.'" is not autoloadable.'); |
|
766 | - } |
|
767 | - $possibleFileName = $this->rootPath.$possibleFileNames[0]; |
|
763 | + $possibleFileNames = $classNameMapper->getPossibleFileNames($daoNamespace."\\".$daoFactoryClassName); |
|
764 | + if (!$possibleFileNames) { |
|
765 | + throw new TDBMException('Sorry, autoload namespace issue. The class "'.$daoNamespace."\\".$daoFactoryClassName.'" is not autoloadable.'); |
|
766 | + } |
|
767 | + $possibleFileName = $this->rootPath.$possibleFileNames[0]; |
|
768 | 768 | |
769 | - $this->ensureDirectoryExist($possibleFileName); |
|
769 | + $this->ensureDirectoryExist($possibleFileName); |
|
770 | 770 | file_put_contents($possibleFileName ,$str); |
771 | 771 | } |
772 | 772 | |
@@ -882,22 +882,22 @@ discard block |
||
882 | 882 | return strtolower(substr($str, 0, 1)).substr($str, 1); |
883 | 883 | } |
884 | 884 | |
885 | - /** |
|
886 | - * Ensures the file passed in parameter can be written in its directory. |
|
887 | - * @param string $fileName |
|
888 | - */ |
|
889 | - private function ensureDirectoryExist($fileName) { |
|
890 | - $dirName = dirname($fileName); |
|
891 | - if (!file_exists($dirName)) { |
|
892 | - $old = umask(0); |
|
893 | - $result = mkdir($dirName, 0775, true); |
|
894 | - umask($old); |
|
895 | - if ($result == false) { |
|
896 | - echo "Unable to create directory: ".$dirName."."; |
|
897 | - exit; |
|
898 | - } |
|
899 | - } |
|
900 | - } |
|
885 | + /** |
|
886 | + * Ensures the file passed in parameter can be written in its directory. |
|
887 | + * @param string $fileName |
|
888 | + */ |
|
889 | + private function ensureDirectoryExist($fileName) { |
|
890 | + $dirName = dirname($fileName); |
|
891 | + if (!file_exists($dirName)) { |
|
892 | + $old = umask(0); |
|
893 | + $result = mkdir($dirName, 0775, true); |
|
894 | + umask($old); |
|
895 | + if ($result == false) { |
|
896 | + echo "Unable to create directory: ".$dirName."."; |
|
897 | + exit; |
|
898 | + } |
|
899 | + } |
|
900 | + } |
|
901 | 901 | |
902 | 902 | /** |
903 | 903 | * @param string $rootPath |
@@ -170,26 +170,26 @@ discard block |
||
170 | 170 | $this->TDBMObject_state = $state; |
171 | 171 | } |
172 | 172 | |
173 | - /** |
|
174 | - * Internal TDBM method, you should not use this. |
|
175 | - * Loads the db_row property of the object from the $row array. |
|
176 | - * Any row having a key starting with 'tdbm_reserved_col_' is ignored. |
|
177 | - * |
|
178 | - * @param array $row |
|
179 | - * @param array|null $colsArray A big optimization to avoid calling strpos to many times. This array should |
|
180 | - * contain as keys the list of interesting columns. If null, this list will be initialized. |
|
181 | - */ |
|
173 | + /** |
|
174 | + * Internal TDBM method, you should not use this. |
|
175 | + * Loads the db_row property of the object from the $row array. |
|
176 | + * Any row having a key starting with 'tdbm_reserved_col_' is ignored. |
|
177 | + * |
|
178 | + * @param array $row |
|
179 | + * @param array|null $colsArray A big optimization to avoid calling strpos to many times. This array should |
|
180 | + * contain as keys the list of interesting columns. If null, this list will be initialized. |
|
181 | + */ |
|
182 | 182 | public function loadFromRow($row, &$colsArray) { |
183 | - if ($colsArray === null) { |
|
184 | - foreach ($row as $key=>$value) { |
|
185 | - if (strpos($key, 'tdbm_reserved_col_')!==0) { |
|
186 | - $colsArray[$key] = true; |
|
187 | - } |
|
188 | - } |
|
189 | - } |
|
190 | - |
|
191 | - $this->db_row = array_intersect_key($row, $colsArray); |
|
192 | - $this->TDBMObject_state = "loaded"; |
|
183 | + if ($colsArray === null) { |
|
184 | + foreach ($row as $key=>$value) { |
|
185 | + if (strpos($key, 'tdbm_reserved_col_')!==0) { |
|
186 | + $colsArray[$key] = true; |
|
187 | + } |
|
188 | + } |
|
189 | + } |
|
190 | + |
|
191 | + $this->db_row = array_intersect_key($row, $colsArray); |
|
192 | + $this->TDBMObject_state = "loaded"; |
|
193 | 193 | } |
194 | 194 | |
195 | 195 | /** |
@@ -325,9 +325,9 @@ discard block |
||
325 | 325 | |
326 | 326 | /** |
327 | 327 | * Saves the current object by INSERTing or UPDAT(E)ing it in the database. |
328 | - * |
|
329 | - * This method must be called only from the DAOs. |
|
330 | - * @internal |
|
328 | + * |
|
329 | + * This method must be called only from the DAOs. |
|
330 | + * @internal |
|
331 | 331 | */ |
332 | 332 | public function save() { |
333 | 333 | if (!is_array($this->db_row)) { |
@@ -510,10 +510,10 @@ discard block |
||
510 | 510 | * |
511 | 511 | * @param string $func_name |
512 | 512 | * @param $values |
513 | - * @return TDBMObjectArray A TDBMObjectArray containing the resulting objects of the query. |
|
514 | - * @throws TDBMException |
|
513 | + * @return TDBMObjectArray A TDBMObjectArray containing the resulting objects of the query. |
|
514 | + * @throws TDBMException |
|
515 | 515 | */ |
516 | - public function __call($func_name, $values) { |
|
516 | + public function __call($func_name, $values) { |
|
517 | 517 | |
518 | 518 | if (strpos($func_name,"get_") === 0) { |
519 | 519 | $table = substr($func_name,4); |
@@ -548,48 +548,48 @@ discard block |
||
548 | 548 | } |
549 | 549 | |
550 | 550 | /** |
551 | - * Implements array behaviour for our object. |
|
552 | - * |
|
553 | - * @param string $offset |
|
554 | - * @param string $value |
|
555 | - */ |
|
551 | + * Implements array behaviour for our object. |
|
552 | + * |
|
553 | + * @param string $offset |
|
554 | + * @param string $value |
|
555 | + */ |
|
556 | 556 | public function offsetSet($offset, $value) { |
557 | 557 | $this->__set($offset, $value); |
558 | - } |
|
558 | + } |
|
559 | 559 | /** |
560 | 560 | * Implements array behaviour for our object. |
561 | 561 | * |
562 | 562 | * @param string $offset |
563 | - * @return bool |
|
563 | + * @return bool |
|
564 | 564 | */ |
565 | - public function offsetExists($offset) { |
|
566 | - $this->_dbLoadIfNotLoaded(); |
|
567 | - return isset($this->db_row[$offset]); |
|
568 | - } |
|
565 | + public function offsetExists($offset) { |
|
566 | + $this->_dbLoadIfNotLoaded(); |
|
567 | + return isset($this->db_row[$offset]); |
|
568 | + } |
|
569 | 569 | /** |
570 | 570 | * Implements array behaviour for our object. |
571 | 571 | * |
572 | 572 | * @param string $offset |
573 | 573 | */ |
574 | - public function offsetUnset($offset) { |
|
574 | + public function offsetUnset($offset) { |
|
575 | 575 | $this->__set($offset, null); |
576 | - } |
|
576 | + } |
|
577 | 577 | /** |
578 | 578 | * Implements array behaviour for our object. |
579 | 579 | * |
580 | 580 | * @param string $offset |
581 | - * @return mixed|null |
|
581 | + * @return mixed|null |
|
582 | 582 | */ |
583 | - public function offsetGet($offset) { |
|
584 | - return $this->__get($offset); |
|
585 | - } |
|
583 | + public function offsetGet($offset) { |
|
584 | + return $this->__get($offset); |
|
585 | + } |
|
586 | 586 | |
587 | 587 | private $_validIterator = false; |
588 | 588 | /** |
589 | 589 | * Implements iterator behaviour for our object (so we can each column). |
590 | 590 | */ |
591 | 591 | public function rewind() { |
592 | - $this->_dbLoadIfNotLoaded(); |
|
592 | + $this->_dbLoadIfNotLoaded(); |
|
593 | 593 | if (count($this->db_row)>0) { |
594 | 594 | $this->_validIterator = true; |
595 | 595 | } else { |
@@ -677,21 +677,21 @@ discard block |
||
677 | 677 | return $sql_where; |
678 | 678 | } |
679 | 679 | |
680 | - /** |
|
681 | - * Override the native php clone function for TDBMObjects |
|
682 | - */ |
|
683 | - public function __clone(){ |
|
684 | - $this->_dbLoadIfNotLoaded(); |
|
685 | - //First lets set the status to new (to enter the save function) |
|
686 | - $this->TDBMObject_state = "new"; |
|
687 | - |
|
688 | - // Add the current TDBMObject to the save object list |
|
689 | - $this->tdbmService->_addToToSaveObjectList($this); |
|
690 | - |
|
691 | - //Now unset the PK from the row |
|
692 | - $pk_array = $this->getPrimaryKey(); |
|
693 | - foreach ($pk_array as $pk) { |
|
694 | - $this->db_row[$pk] = null; |
|
695 | - } |
|
696 | - } |
|
680 | + /** |
|
681 | + * Override the native php clone function for TDBMObjects |
|
682 | + */ |
|
683 | + public function __clone(){ |
|
684 | + $this->_dbLoadIfNotLoaded(); |
|
685 | + //First lets set the status to new (to enter the save function) |
|
686 | + $this->TDBMObject_state = "new"; |
|
687 | + |
|
688 | + // Add the current TDBMObject to the save object list |
|
689 | + $this->tdbmService->_addToToSaveObjectList($this); |
|
690 | + |
|
691 | + //Now unset the PK from the row |
|
692 | + $pk_array = $this->getPrimaryKey(); |
|
693 | + foreach ($pk_array as $pk) { |
|
694 | + $this->db_row[$pk] = null; |
|
695 | + } |
|
696 | + } |
|
697 | 697 | } |
698 | 698 | \ No newline at end of file |