@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | |
23 | 23 | const SEPARETOR = "_"; |
24 | 24 | |
25 | - protected function init () |
|
25 | + protected function init() |
|
26 | 26 | { |
27 | 27 | } |
28 | 28 | |
@@ -31,50 +31,50 @@ discard block |
||
31 | 31 | * |
32 | 32 | * @return array |
33 | 33 | */ |
34 | - protected function getParams () |
|
34 | + protected function getParams() |
|
35 | 35 | { |
36 | - if ( ! $this->config or ! $this->isValidFrameworkFiles () ) |
|
36 | + if ( ! $this->config or ! $this->isValidFrameworkFiles()) |
|
37 | 37 | { |
38 | - return array (); |
|
38 | + return array(); |
|
39 | 39 | } |
40 | 40 | |
41 | - return array ( |
|
41 | + return array( |
|
42 | 42 | //Driver do banco de dados |
43 | - 'driver' => $this->config[ 'adapter' ] , |
|
43 | + 'driver' => $this->config['adapter'], |
|
44 | 44 | //Nome do banco de dados |
45 | - 'database' => $this->config[ 'params' ][ 'dbname' ] , |
|
45 | + 'database' => $this->config['params']['dbname'], |
|
46 | 46 | //Host do banco |
47 | - 'host' => $this->config[ 'params' ][ 'host' ] , |
|
47 | + 'host' => $this->config['params']['host'], |
|
48 | 48 | //Port do banco |
49 | - 'port' => isset( $this->config[ 'params' ][ 'port' ] ) |
|
50 | - ? $this->config[ 'params' ][ 'port' ] : '' , |
|
49 | + 'port' => isset($this->config['params']['port']) |
|
50 | + ? $this->config['params']['port'] : '', |
|
51 | 51 | //usuario do banco |
52 | - 'username' => $this->config[ 'params' ][ 'username' ] , |
|
52 | + 'username' => $this->config['params']['username'], |
|
53 | 53 | //senha do banco |
54 | - 'password' => $this->config[ 'params' ][ 'password' ] , |
|
54 | + 'password' => $this->config['params']['password'], |
|
55 | 55 | ); |
56 | 56 | } |
57 | 57 | |
58 | - protected function parseFrameworkConfig () |
|
58 | + protected function parseFrameworkConfig() |
|
59 | 59 | { |
60 | - if ( ! $this->isValidFrameworkFiles () ) |
|
60 | + if ( ! $this->isValidFrameworkFiles()) |
|
61 | 61 | { |
62 | 62 | return; |
63 | 63 | } |
64 | 64 | |
65 | - $frameworkIni = $this->getFrameworkIni (); |
|
65 | + $frameworkIni = $this->getFrameworkIni(); |
|
66 | 66 | |
67 | 67 | require_once 'Zend/Config/Ini.php'; |
68 | 68 | |
69 | 69 | $objConfig = new \Zend_Config_Ini( |
70 | - realpath ( $frameworkIni ) , $this->getEnvironment () |
|
70 | + realpath($frameworkIni), $this->getEnvironment() |
|
71 | 71 | ); |
72 | 72 | |
73 | - $arrConfig = $objConfig->toArray (); |
|
73 | + $arrConfig = $objConfig->toArray(); |
|
74 | 74 | |
75 | - if ( isset( $arrConfig[ 'resources' ][ 'db' ] ) ) |
|
75 | + if (isset($arrConfig['resources']['db'])) |
|
76 | 76 | { |
77 | - $this->config = $arrConfig[ 'resources' ][ 'db' ]; |
|
77 | + $this->config = $arrConfig['resources']['db']; |
|
78 | 78 | } |
79 | 79 | } |
80 | 80 | |
@@ -83,12 +83,12 @@ discard block |
||
83 | 83 | * |
84 | 84 | * @return \Classes\AdapterMakerFile\AbstractAdapter[] |
85 | 85 | */ |
86 | - public function getMakeFileInstances () |
|
86 | + public function getMakeFileInstances() |
|
87 | 87 | { |
88 | - return array ( |
|
89 | - DbTable::getInstance () , |
|
90 | - Entity::getInstance () , |
|
91 | - Model::getInstance () |
|
88 | + return array( |
|
89 | + DbTable::getInstance(), |
|
90 | + Entity::getInstance(), |
|
91 | + Model::getInstance() |
|
92 | 92 | ); |
93 | 93 | } |
94 | 94 |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | |
23 | 23 | const SEPARETOR = "_"; |
24 | 24 | |
25 | - protected function init () |
|
25 | + protected function init() |
|
26 | 26 | { |
27 | 27 | } |
28 | 28 | |
@@ -31,12 +31,12 @@ discard block |
||
31 | 31 | * |
32 | 32 | * @return array |
33 | 33 | */ |
34 | - protected function getParams () |
|
34 | + protected function getParams() |
|
35 | 35 | { |
36 | 36 | |
37 | 37 | } |
38 | 38 | |
39 | - protected function parseFrameworkConfig () |
|
39 | + protected function parseFrameworkConfig() |
|
40 | 40 | { |
41 | 41 | // TODO: Implement parseFrameworkConfig() method. |
42 | 42 | } |
@@ -46,12 +46,12 @@ discard block |
||
46 | 46 | * |
47 | 47 | * @return \Classes\AdapterMakerFile\AbstractAdapter[] |
48 | 48 | */ |
49 | - public function getMakeFileInstances () |
|
49 | + public function getMakeFileInstances() |
|
50 | 50 | { |
51 | - return array ( |
|
52 | - DbTable::getInstance (), |
|
53 | - Entity::getInstance (), |
|
54 | - Model::getInstance () |
|
51 | + return array( |
|
52 | + DbTable::getInstance(), |
|
53 | + Entity::getInstance(), |
|
54 | + Model::getInstance() |
|
55 | 55 | ); |
56 | 56 | } |
57 | 57 |
@@ -19,6 +19,6 @@ |
||
19 | 19 | |
20 | 20 | public function parseRelation ( \Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable ) |
21 | 21 | { |
22 | - return array(); |
|
22 | + return array(); |
|
23 | 23 | } |
24 | 24 | } |
@@ -12,9 +12,9 @@ |
||
12 | 12 | /** |
13 | 13 | * @var void |
14 | 14 | */ |
15 | - protected $fileTpl = "model.php"; |
|
15 | + protected $fileTpl = "model.php"; |
|
16 | 16 | |
17 | - public function parseRelation ( \Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable ) |
|
17 | + public function parseRelation(\Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable) |
|
18 | 18 | { |
19 | 19 | return array(); |
20 | 20 | } |
@@ -70,6 +70,9 @@ |
||
70 | 70 | return $this; |
71 | 71 | } |
72 | 72 | |
73 | + /** |
|
74 | + * @return string |
|
75 | + */ |
|
73 | 76 | public function getDatabase (){ |
74 | 77 | return $this->database; |
75 | 78 | } |
@@ -21,11 +21,11 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @author Pedro Alarcao <[email protected]> |
23 | 23 | */ |
24 | - final private function __construct () |
|
24 | + final private function __construct() |
|
25 | 25 | { |
26 | 26 | } |
27 | 27 | |
28 | - public static function getInstance () |
|
28 | + public static function getInstance() |
|
29 | 29 | { |
30 | 30 | return new self(); |
31 | 31 | } |
@@ -55,34 +55,34 @@ discard block |
||
55 | 55 | * |
56 | 56 | * @return Constrant |
57 | 57 | */ |
58 | - public function populate ( $array ) |
|
58 | + public function populate($array) |
|
59 | 59 | { |
60 | - if ( isset( $array[ 'schema' ] ) ) |
|
60 | + if (isset($array['schema'])) |
|
61 | 61 | { |
62 | - $this->schema = $array[ 'schema' ]; |
|
62 | + $this->schema = $array['schema']; |
|
63 | 63 | } |
64 | 64 | |
65 | - $this->database = $array[ 'database' ]; |
|
66 | - $this->constrant = $array[ 'constrant' ]; |
|
67 | - $this->table = $array[ 'table' ]; |
|
68 | - $this->column = $array[ 'column' ]; |
|
65 | + $this->database = $array['database']; |
|
66 | + $this->constrant = $array['constrant']; |
|
67 | + $this->table = $array['table']; |
|
68 | + $this->column = $array['column']; |
|
69 | 69 | |
70 | 70 | return $this; |
71 | 71 | } |
72 | 72 | |
73 | - public function getDatabase (){ |
|
73 | + public function getDatabase() { |
|
74 | 74 | return $this->database; |
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
78 | 78 | * @return string |
79 | 79 | */ |
80 | - public function getNameConstrant () |
|
80 | + public function getNameConstrant() |
|
81 | 81 | { |
82 | 82 | return $this->constrant; |
83 | 83 | } |
84 | 84 | |
85 | - public function hasSchema () |
|
85 | + public function hasSchema() |
|
86 | 86 | { |
87 | 87 | return (bool) $this->schema; |
88 | 88 | } |
@@ -90,7 +90,7 @@ discard block |
||
90 | 90 | /** |
91 | 91 | * @return string |
92 | 92 | */ |
93 | - public function getSchema () |
|
93 | + public function getSchema() |
|
94 | 94 | { |
95 | 95 | return $this->schema; |
96 | 96 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | /** |
99 | 99 | * @return string |
100 | 100 | */ |
101 | - public function getTable () |
|
101 | + public function getTable() |
|
102 | 102 | { |
103 | 103 | return $this->table; |
104 | 104 | } |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | /** |
107 | 107 | * @return string |
108 | 108 | */ |
109 | - public function getColumn () |
|
109 | + public function getColumn() |
|
110 | 110 | { |
111 | 111 | return $this->column; |
112 | 112 | } |
@@ -140,9 +140,12 @@ discard block |
||
140 | 140 | * Stored in ISO 8601 format. |
141 | 141 | * |
142 | 142 | * @param string|Zend_Date $<?=$column->getName() . "\n"?> |
143 | -<?php else: ?> |
|
143 | +<?php else { |
|
144 | + : ?> |
|
144 | 145 | * @param <?=$column->getType()?> $<?=$column->getName() . "\n"?> |
145 | -<?php endif; ?> |
|
146 | +<?php endif; |
|
147 | +} |
|
148 | +?> |
|
146 | 149 | * @return <?=$className . "\n"?> |
147 | 150 | */ |
148 | 151 | public function set<?=\Classes\Maker\AbstractMaker::getClassName($column->getName())?>($<?=$column->getName()?>) |
@@ -189,9 +192,12 @@ discard block |
||
189 | 192 | <?php if ($column->getType()=='date'): ?> |
190 | 193 | * @param boolean $returnZendDate |
191 | 194 | * @return Zend_Date|null|string Zend_Date representation of this datetime if enabled, or ISO 8601 string if not |
192 | -<?php else: ?> |
|
195 | +<?php else { |
|
196 | + : ?> |
|
193 | 197 | * @return <?=$column->getType() . "\n"?> |
194 | -<?php endif; ?> |
|
198 | +<?php endif; |
|
199 | +} |
|
200 | +?> |
|
195 | 201 | */ |
196 | 202 | public function get<?=\Classes\Maker\AbstractMaker::getClassName($column->getName())?>(<?php if ($column->getType()=='date'): ?>$returnZendDate = false <?php endif;?>) |
197 | 203 | { |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?= "<?php\n" ?> |
2 | -<?php $className = $objTables->getNamespace () . '_Entity_' . \Classes\Maker\AbstractMaker::getClassName ( |
|
3 | - $objTables->getName () |
|
2 | +<?php $className = $objTables->getNamespace() . '_Entity_' . \Classes\Maker\AbstractMaker::getClassName( |
|
3 | + $objTables->getName() |
|
4 | 4 | ) ?> |
5 | 5 | |
6 | 6 | /** |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * |
9 | 9 | * <?= $this->config->last_modify . "\n" ?> |
10 | 10 | * |
11 | - * @package <?= $objTables->getNamespace () . "\n" ?> |
|
11 | + * @package <?= $objTables->getNamespace() . "\n" ?> |
|
12 | 12 | * @subpackage Entity |
13 | 13 | * |
14 | 14 | * @author <?= $this->config->author . "\n" ?> |
@@ -24,16 +24,16 @@ discard block |
||
24 | 24 | */ |
25 | 25 | |
26 | 26 | abstract class <?= $className ?> extends <?= $this->config->namespace ? $this->config->namespace |
27 | - . "_" : "" ?>Model_<?= $objMakeFile->getParentClass ( |
|
27 | + . "_" : "" ?>Model_<?= $objMakeFile->getParentClass( |
|
28 | 28 | ) . "\n" ?> |
29 | 29 | { |
30 | 30 | |
31 | -<?php foreach ( $objTables->getColumns () as $column ): ?> |
|
31 | +<?php foreach ($objTables->getColumns() as $column): ?> |
|
32 | 32 | /** |
33 | - * Database constraint in the column <?= $column->getName () . "\n" ?> |
|
33 | + * Database constraint in the column <?= $column->getName() . "\n" ?> |
|
34 | 34 | * |
35 | 35 | */ |
36 | - const <?= strtoupper ( $column->getName () ) ?> = '<?= $objTables->getName () ?>.<?= $column->getName () ?>'; |
|
36 | + const <?= strtoupper($column->getName()) ?> = '<?= $objTables->getName() ?>.<?= $column->getName() ?>'; |
|
37 | 37 | <?php endforeach; ?> |
38 | 38 | |
39 | 39 | /** |
@@ -42,17 +42,17 @@ discard block |
||
42 | 42 | * @var string |
43 | 43 | * @access protected |
44 | 44 | */ |
45 | - protected $_tableClass = '<?= $objTables->getNamespace () ?>_DbTable_<?= \Classes\Maker\AbstractMaker::getClassName ( |
|
46 | - $objTables->getName () |
|
45 | + protected $_tableClass = '<?= $objTables->getNamespace() ?>_DbTable_<?= \Classes\Maker\AbstractMaker::getClassName( |
|
46 | + $objTables->getName() |
|
47 | 47 | ) ?>'; |
48 | 48 | |
49 | 49 | /** |
50 | 50 | * @see <?= $this->config->namespace ?>Model_EntityAbstract::$_columnsList |
51 | 51 | */ |
52 | 52 | protected $_columnsList = array( |
53 | -<?php foreach ( $objTables->getColumns () as $column ): ?> |
|
54 | - self::<?= strtoupper ( $column->getName () ) ?> => '<?= strtolower ( |
|
55 | - \Classes\Maker\AbstractMaker::getClassName ( $column->getName () ) |
|
53 | +<?php foreach ($objTables->getColumns() as $column): ?> |
|
54 | + self::<?= strtoupper($column->getName()) ?> => '<?= strtolower( |
|
55 | + \Classes\Maker\AbstractMaker::getClassName($column->getName()) |
|
56 | 56 | ) ?>', |
57 | 57 | <?php endforeach; ?> |
58 | 58 | ); |
@@ -61,10 +61,10 @@ discard block |
||
61 | 61 | * @see <?= $this->config->namespace ?>Model_EntityAbstract::$_filters |
62 | 62 | */ |
63 | 63 | protected $_filters = array( |
64 | -<?php foreach ( $objTables->getColumns () as $column ): ?> |
|
64 | +<?php foreach ($objTables->getColumns() as $column): ?> |
|
65 | 65 | <?php |
66 | 66 | $filters = null; |
67 | - switch ( ucfirst ( $column->getType () ) ) { |
|
67 | + switch (ucfirst($column->getType())) { |
|
68 | 68 | case 'String': |
69 | 69 | $filters = 'StripTags", "StringTrim'; |
70 | 70 | break; |
@@ -74,12 +74,12 @@ discard block |
||
74 | 74 | case 'Date': |
75 | 75 | break; |
76 | 76 | default: |
77 | - $filters = ucfirst ( $column->getType () ); |
|
77 | + $filters = ucfirst($column->getType()); |
|
78 | 78 | break; |
79 | 79 | } |
80 | 80 | ?> |
81 | - '<?= $column->getName () ?>' => array ( |
|
82 | - <?= ( !empty( $filters ) ) ? "\"{$filters}\"\n" : null; ?> |
|
81 | + '<?= $column->getName() ?>' => array ( |
|
82 | + <?= ( ! empty($filters)) ? "\"{$filters}\"\n" : null; ?> |
|
83 | 83 | ), |
84 | 84 | <?php endforeach; ?> |
85 | 85 | ); |
@@ -88,34 +88,34 @@ discard block |
||
88 | 88 | * @see <?= $this->config->namespace ?>Model_EntityAbstract::$_validators |
89 | 89 | */ |
90 | 90 | protected $_validators= array( |
91 | -<?php foreach ( $objTables->getColumns () as $column ): ?> |
|
91 | +<?php foreach ($objTables->getColumns() as $column): ?> |
|
92 | 92 | <?php |
93 | - $validators = array (); |
|
93 | + $validators = array(); |
|
94 | 94 | |
95 | - $validators[] = $column->isNullable () ? "'allowEmpty' => true" : "'NotEmpty'"; |
|
95 | + $validators[] = $column->isNullable() ? "'allowEmpty' => true" : "'NotEmpty'"; |
|
96 | 96 | |
97 | - switch ( ucfirst ( $column->getType () ) ) { |
|
97 | + switch (ucfirst($column->getType())) { |
|
98 | 98 | case 'String': |
99 | - if ( $column->getMaxLength () ) { |
|
100 | - $validators[] = "array( 'StringLength', array( 'max' => " . $column->getMaxLength () . " ) )"; |
|
99 | + if ($column->getMaxLength()) { |
|
100 | + $validators[] = "array( 'StringLength', array( 'max' => " . $column->getMaxLength() . " ) )"; |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | break; |
104 | 104 | case 'Boolean': |
105 | 105 | break; |
106 | 106 | default: |
107 | - $name = ucfirst ( $column->getType () ); |
|
107 | + $name = ucfirst($column->getType()); |
|
108 | 108 | $validators[] = "'$name'"; |
109 | 109 | break; |
110 | 110 | } |
111 | -$validators = implode ( ", ", $validators ) ?> |
|
112 | - '<?= $column->getName () ?>' => array ( |
|
113 | - <?= ( !empty( $validators ) ) ? "{$validators}\n" : null ?> |
|
111 | +$validators = implode(", ", $validators) ?> |
|
112 | + '<?= $column->getName() ?>' => array ( |
|
113 | + <?= ( ! empty($validators)) ? "{$validators}\n" : null ?> |
|
114 | 114 | ), |
115 | 115 | <?php endforeach; ?> |
116 | 116 | ); |
117 | 117 | |
118 | -<?php if ( $objTables->hasPrimaryKey () ): ?> |
|
118 | +<?php if ($objTables->hasPrimaryKey()): ?> |
|
119 | 119 | /** |
120 | 120 | * Nome da Primary Key |
121 | 121 | * |
@@ -123,83 +123,83 @@ discard block |
||
123 | 123 | * @access protected |
124 | 124 | */ |
125 | 125 | protected $_primary = array( |
126 | -<?php foreach ( $objTables->getPrimarykeys () as $pks ) : ?> |
|
127 | - '<?= $pks->getName () ?>', |
|
126 | +<?php foreach ($objTables->getPrimarykeys() as $pks) : ?> |
|
127 | + '<?= $pks->getName() ?>', |
|
128 | 128 | <?php endforeach ?> |
129 | 129 | ); |
130 | 130 | <?php endif ?> |
131 | 131 | |
132 | -<?php foreach ( $parents as $parent ): ?> |
|
132 | +<?php foreach ($parents as $parent): ?> |
|
133 | 133 | /** |
134 | - * Parent relation <?= \Classes\Maker\AbstractMaker::getClassName ( $parent[ 'table' ] ) . "\n" ?> |
|
134 | + * Parent relation <?= \Classes\Maker\AbstractMaker::getClassName($parent['table']) . "\n" ?> |
|
135 | 135 | * |
136 | - * - CONSTRAINT in DB <?= $parent[ 'name' ] . "\n" ?> |
|
136 | + * - CONSTRAINT in DB <?= $parent['name'] . "\n" ?> |
|
137 | 137 | * |
138 | - * @var <?= $parent[ 'variable' ] . "\n" ?> |
|
138 | + * @var <?= $parent['variable'] . "\n" ?> |
|
139 | 139 | */ |
140 | - protected $_parent_<?= $parent[ 'variable' ] ?>; |
|
140 | + protected $_parent_<?= $parent['variable'] ?>; |
|
141 | 141 | |
142 | 142 | <?php endforeach; ?> |
143 | -<?php foreach ( $depends as $depend ): ?> |
|
143 | +<?php foreach ($depends as $depend): ?> |
|
144 | 144 | /** |
145 | - * Depends relation <?= \Classes\Maker\AbstractMaker::getClassName ( $depend[ 'table' ] ) . "\n" ?> |
|
145 | + * Depends relation <?= \Classes\Maker\AbstractMaker::getClassName($depend['table']) . "\n" ?> |
|
146 | 146 | * |
147 | - * - CONSTRAINT in DB <?= $depend[ 'name' ] . "\n" ?> |
|
147 | + * - CONSTRAINT in DB <?= $depend['name'] . "\n" ?> |
|
148 | 148 | * |
149 | - * @var <?= $depend[ 'variable' ] . "\n" ?> |
|
149 | + * @var <?= $depend['variable'] . "\n" ?> |
|
150 | 150 | */ |
151 | - protected $_depend_<?= $depend[ 'variable' ] ?>; |
|
151 | + protected $_depend_<?= $depend['variable'] ?>; |
|
152 | 152 | |
153 | 153 | <?php endforeach; ?> |
154 | -<?php foreach ( $objTables->getColumns () as $column ): ?> |
|
154 | +<?php foreach ($objTables->getColumns() as $column): ?> |
|
155 | 155 | /** |
156 | 156 | * |
157 | - * Sets column <?= $column->getName () . "\n" ?> |
|
157 | + * Sets column <?= $column->getName() . "\n" ?> |
|
158 | 158 | * |
159 | -<?php if ( $column->equalType ( 'date' ) ): ?> |
|
159 | +<?php if ($column->equalType('date')): ?> |
|
160 | 160 | * Stored in ISO 8601 format. |
161 | 161 | * |
162 | - * @param string|Zend_Date $<?= $column->getName () . "\n" ?> |
|
162 | + * @param string|Zend_Date $<?= $column->getName() . "\n" ?> |
|
163 | 163 | <?php else: ?> |
164 | - * @param <?= $column->getType () ?> $<?= $column->getName () . "\n" ?> |
|
164 | + * @param <?= $column->getType() ?> $<?= $column->getName() . "\n" ?> |
|
165 | 165 | <?php endif; ?> |
166 | 166 | * @return <?= $className . "\n" ?> |
167 | 167 | */ |
168 | - public function set<?= \Classes\Maker\AbstractMaker::getClassName ( $column->getName () ) ?>($<?= $column->getName ( |
|
168 | + public function set<?= \Classes\Maker\AbstractMaker::getClassName($column->getName()) ?>($<?= $column->getName( |
|
169 | 169 | ) ?>) |
170 | 170 | { |
171 | -<?php switch ( $column->getType () ): |
|
171 | +<?php switch ($column->getType()): |
|
172 | 172 | case 'date': ?> |
173 | - if (! empty($<?= $column->getName () ?>)) |
|
173 | + if (! empty($<?= $column->getName() ?>)) |
|
174 | 174 | { |
175 | - if (! $<?= $column->getName () ?> instanceof Zend_Date) |
|
175 | + if (! $<?= $column->getName() ?> instanceof Zend_Date) |
|
176 | 176 | { |
177 | - $<?= $column->getName () ?> = new Zend_Date($<?= $column->getName () ?>); |
|
177 | + $<?= $column->getName() ?> = new Zend_Date($<?= $column->getName() ?>); |
|
178 | 178 | } |
179 | 179 | |
180 | - $this-><?= $column->getName () ?> = $<?= $column->getName () ?>->toString(Zend_Date::ISO_8601); |
|
180 | + $this-><?= $column->getName() ?> = $<?= $column->getName() ?>->toString(Zend_Date::ISO_8601); |
|
181 | 181 | } |
182 | 182 | |
183 | 183 | <?php break ?> |
184 | 184 | <?php case 'boolean': ?> |
185 | - $this-><?= $column->getName () ?> = $<?= $column->getName () ?> ? true : false; |
|
185 | + $this-><?= $column->getName() ?> = $<?= $column->getName() ?> ? true : false; |
|
186 | 186 | |
187 | 187 | <?php break ?> |
188 | 188 | <?php default: ?> |
189 | - $<?= $column->getName () ?> = (<?= ucfirst ( $column->getType () ) ?>) $<?= $column->getName () ?> ; |
|
190 | - $input = new Zend_Filter_Input($this->_filters, $this->_validators, array('<?= $column->getName ( |
|
191 | - ) ?>'=>$<?= $column->getName () ?> )); |
|
189 | + $<?= $column->getName() ?> = (<?= ucfirst($column->getType()) ?>) $<?= $column->getName() ?> ; |
|
190 | + $input = new Zend_Filter_Input($this->_filters, $this->_validators, array('<?= $column->getName( |
|
191 | + ) ?>'=>$<?= $column->getName() ?> )); |
|
192 | 192 | |
193 | - if(!$input->isValid ('<?= $column->getName () ?>')) |
|
193 | + if(!$input->isValid ('<?= $column->getName() ?>')) |
|
194 | 194 | { |
195 | 195 | $errors = $input->getMessages (); |
196 | - foreach ( $errors['<?= $column->getName () ?>'] as $key => $value ) |
|
196 | + foreach ( $errors['<?= $column->getName() ?>'] as $key => $value ) |
|
197 | 197 | { |
198 | 198 | throw new Exception ( $value ); |
199 | 199 | } |
200 | 200 | } |
201 | 201 | |
202 | - $this-><?= $column->getName () ?> = $<?= $column->getName () ?> ; |
|
202 | + $this-><?= $column->getName() ?> = $<?= $column->getName() ?> ; |
|
203 | 203 | |
204 | 204 | <?php break ?> |
205 | 205 | <?php endswitch ?> |
@@ -207,71 +207,71 @@ discard block |
||
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
210 | - * Gets column <?= $column->getName () . "\n" ?> |
|
210 | + * Gets column <?= $column->getName() . "\n" ?> |
|
211 | 211 | * |
212 | -<?php if ( $column->equalType ( 'date' ) ): ?> |
|
212 | +<?php if ($column->equalType('date')): ?> |
|
213 | 213 | * @param boolean $returnZendDate |
214 | 214 | * @return Zend_Date|null|string Zend_Date representation of this datetime if enabled, or ISO 8601 string if not |
215 | 215 | <?php else: ?> |
216 | - * @return <?= $column->getType () . "\n" ?> |
|
216 | + * @return <?= $column->getType() . "\n" ?> |
|
217 | 217 | <?php endif; ?> |
218 | 218 | */ |
219 | - public function get<?= \Classes\Maker\AbstractMaker::getClassName ( |
|
220 | - $column->getName () |
|
221 | - ) ?>(<?php if ( $column->equalType ( 'date' ) ): ?>$returnZendDate = false <?php endif; ?>) |
|
219 | + public function get<?= \Classes\Maker\AbstractMaker::getClassName( |
|
220 | + $column->getName() |
|
221 | + ) ?>(<?php if ($column->equalType('date')): ?>$returnZendDate = false <?php endif; ?>) |
|
222 | 222 | { |
223 | -<?php if ( $column->equalType ( 'date' ) ): ?> |
|
223 | +<?php if ($column->equalType('date')): ?> |
|
224 | 224 | if ($returnZendDate) |
225 | 225 | { |
226 | - if ($this->_data['<?= $column->getName () ?>'] === null) |
|
226 | + if ($this->_data['<?= $column->getName() ?>'] === null) |
|
227 | 227 | { |
228 | 228 | return null; |
229 | 229 | } |
230 | 230 | |
231 | - return new Zend_Date($this-><?= $column->getName () ?>, Zend_Date::ISO_8601); |
|
231 | + return new Zend_Date($this-><?= $column->getName() ?>, Zend_Date::ISO_8601); |
|
232 | 232 | } |
233 | 233 | <?php endif; ?> |
234 | - return $this-><?= $column->getName () ?>; |
|
234 | + return $this-><?= $column->getName() ?>; |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | <?php endforeach; ?> |
238 | -<?php foreach ( $parents as $parent ): ?> |
|
238 | +<?php foreach ($parents as $parent): ?> |
|
239 | 239 | /** |
240 | - * Gets parent <?= $parent[ 'table' ] . "\n" ?> |
|
240 | + * Gets parent <?= $parent['table'] . "\n" ?> |
|
241 | 241 | * |
242 | - * @return <?= $parent[ 'class' ] . "\n" ?> |
|
242 | + * @return <?= $parent['class'] . "\n" ?> |
|
243 | 243 | */ |
244 | - public function get<?= $parent[ 'function' ] ?>() |
|
244 | + public function get<?= $parent['function'] ?>() |
|
245 | 245 | { |
246 | - if ($this->_parent_<?= $parent[ 'variable' ] ?> === null) |
|
246 | + if ($this->_parent_<?= $parent['variable'] ?> === null) |
|
247 | 247 | { |
248 | - $this->_parent_<?= $parent[ 'variable' ] ?> = $this->findParentRow('<?= $objTables->getNamespace ( |
|
249 | - ) ?>_DbTable_<?= \Classes\Maker\AbstractMaker::getClassName ( |
|
250 | - $parent[ 'table' ] |
|
251 | - ) ?>', '<?= \Classes\Maker\AbstractMaker::getClassName ( $parent[ 'variable' ] ) ?>'); |
|
248 | + $this->_parent_<?= $parent['variable'] ?> = $this->findParentRow('<?= $objTables->getNamespace( |
|
249 | + ) ?>_DbTable_<?= \Classes\Maker\AbstractMaker::getClassName( |
|
250 | + $parent['table'] |
|
251 | + ) ?>', '<?= \Classes\Maker\AbstractMaker::getClassName($parent['variable']) ?>'); |
|
252 | 252 | } |
253 | 253 | |
254 | - return $this->_parent_<?= $parent[ 'variable' ] ?>; |
|
254 | + return $this->_parent_<?= $parent['variable'] ?>; |
|
255 | 255 | } |
256 | 256 | |
257 | 257 | <?php endforeach; ?> |
258 | 258 | |
259 | 259 | |
260 | -<?php foreach ( $depends as $depend ): ?> |
|
260 | +<?php foreach ($depends as $depend): ?> |
|
261 | 261 | /** |
262 | - * Gets dependent <?= $depend[ 'table' ] . "\n" ?> |
|
262 | + * Gets dependent <?= $depend['table'] . "\n" ?> |
|
263 | 263 | * |
264 | - * @return <?= $depend[ 'class' ] . "\n" ?> |
|
264 | + * @return <?= $depend['class'] . "\n" ?> |
|
265 | 265 | */ |
266 | - public function get<?= $depend[ 'function' ] ?>() |
|
266 | + public function get<?= $depend['function'] ?>() |
|
267 | 267 | { |
268 | - if ($this->_depend_<?= $depend[ 'variable' ] ?> === null) |
|
268 | + if ($this->_depend_<?= $depend['variable'] ?> === null) |
|
269 | 269 | { |
270 | - $this->_depend_<?= $depend[ 'variable' ] ?> = $this->findDependentRowset('<?= $objTables->getNamespace ( |
|
271 | - ) ?>_DbTable_<?= \Classes\Maker\AbstractMaker::getClassName ( $depend[ 'table' ] ) ?>'); |
|
270 | + $this->_depend_<?= $depend['variable'] ?> = $this->findDependentRowset('<?= $objTables->getNamespace( |
|
271 | + ) ?>_DbTable_<?= \Classes\Maker\AbstractMaker::getClassName($depend['table']) ?>'); |
|
272 | 272 | } |
273 | 273 | |
274 | - return $this->_depend_<?= $depend[ 'variable' ] ?>; |
|
274 | + return $this->_depend_<?= $depend['variable'] ?>; |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | <?php endforeach; ?> |
@@ -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 | */ |
@@ -391,7 +391,7 @@ |
||
391 | 391 | $matches = preg_grep ( '*\.*' , $this->getTablesName () ); |
392 | 392 | if ( count ( $matches ) ) |
393 | 393 | { |
394 | - die("error: Table name must not contain the schema\n"); |
|
394 | + die("error: Table name must not contain the schema\n"); |
|
395 | 395 | } |
396 | 396 | } |
397 | 397 |
@@ -16,85 +16,85 @@ discard block |
||
16 | 16 | abstract class AbstractAdapter |
17 | 17 | { |
18 | 18 | |
19 | - protected $arrConfig = array ( |
|
19 | + protected $arrConfig = array( |
|
20 | 20 | ############################# DATABASE |
21 | 21 | //Driver do banco de dados |
22 | - 'driver' => null , |
|
22 | + 'driver' => null, |
|
23 | 23 | //Nome do banco de dados |
24 | - 'database' => null , |
|
24 | + 'database' => null, |
|
25 | 25 | //Host do banco |
26 | - 'host' => 'localhost' , |
|
26 | + 'host' => 'localhost', |
|
27 | 27 | //Port do banco |
28 | - 'port' => '' , |
|
28 | + 'port' => '', |
|
29 | 29 | //usuario do banco |
30 | - 'username' => null , |
|
30 | + 'username' => null, |
|
31 | 31 | //senha do banco |
32 | - 'password' => null , |
|
32 | + 'password' => null, |
|
33 | 33 | // lista de schemas do banco de dados |
34 | - 'schema' => array () , |
|
35 | - 'version' => '' , |
|
36 | - 'socket' => null , |
|
34 | + 'schema' => array(), |
|
35 | + 'version' => '', |
|
36 | + 'socket' => null, |
|
37 | 37 | |
38 | 38 | ########################### DOCS |
39 | 39 | // autor que gerou o script |
40 | - 'author' => "Pedro" , |
|
41 | - 'license' => "New BSD License" , |
|
42 | - 'copyright' => "ORM Generator - Pedro151" , |
|
43 | - 'link' => 'https://github.com/pedro151/orm-generator' , |
|
44 | - 'version' => '' , |
|
40 | + 'author' => "Pedro", |
|
41 | + 'license' => "New BSD License", |
|
42 | + 'copyright' => "ORM Generator - Pedro151", |
|
43 | + 'link' => 'https://github.com/pedro151/orm-generator', |
|
44 | + 'version' => '', |
|
45 | 45 | // data que foi gerado o script |
46 | - 'last_modify' => null , |
|
46 | + 'last_modify' => null, |
|
47 | 47 | |
48 | 48 | ########################## Ambiente/Arquivos |
49 | 49 | |
50 | 50 | // Nome do framework para o adapter |
51 | - 'framework' => null , |
|
51 | + 'framework' => null, |
|
52 | 52 | // namespace das classes |
53 | - 'namespace' => "" , |
|
53 | + 'namespace' => "", |
|
54 | 54 | // caminho onde os arquivos devem ser criados |
55 | - 'path' => 'models' , |
|
55 | + 'path' => 'models', |
|
56 | 56 | // flag para gerar pasta com o nome do driver do banco de dados |
57 | - 'folder-database' => 0 , |
|
57 | + 'folder-database' => 0, |
|
58 | 58 | // string com o nome da pastar personalizada |
59 | - 'folder-name' => '' , |
|
59 | + 'folder-name' => '', |
|
60 | 60 | |
61 | 61 | ############################## Comandos adicionais |
62 | 62 | //flag para mostrar o status da execução ao termino do processo |
63 | - 'status' => false , |
|
63 | + 'status' => false, |
|
64 | 64 | // flags para criar todas as tabelas ou nao |
65 | - 'tables' => array () , |
|
65 | + 'tables' => array(), |
|
66 | 66 | //Lista de tabelas a serem ignoradas |
67 | - 'ignoreTable' => array () , |
|
67 | + 'ignoreTable' => array(), |
|
68 | 68 | ); |
69 | 69 | |
70 | 70 | /** |
71 | 71 | * @var string[] um array com todos os campos obrigatorios |
72 | 72 | */ |
73 | - protected $attRequered = array ( |
|
74 | - 'driver' => true , |
|
75 | - 'database' => true , |
|
76 | - 'host' => true , |
|
77 | - 'username' => true , |
|
73 | + protected $attRequered = array( |
|
74 | + 'driver' => true, |
|
75 | + 'database' => true, |
|
76 | + 'host' => true, |
|
77 | + 'username' => true, |
|
78 | 78 | 'path' => true |
79 | 79 | ); |
80 | 80 | |
81 | - protected $arrFunc = array (); |
|
81 | + protected $arrFunc = array(); |
|
82 | 82 | |
83 | - private $framworkFiles = array (); |
|
83 | + private $framworkFiles = array(); |
|
84 | 84 | |
85 | - public $reservedWord = array (); |
|
85 | + public $reservedWord = array(); |
|
86 | 86 | |
87 | - private static $dataTypesDefault = array ( |
|
88 | - 'int' => 'int' , |
|
89 | - 'float' => 'float' , |
|
90 | - 'string' => 'string' , |
|
91 | - 'text' => 'string' , |
|
92 | - 'date' => 'date' , |
|
93 | - 'datetime' => 'date' , |
|
87 | + private static $dataTypesDefault = array( |
|
88 | + 'int' => 'int', |
|
89 | + 'float' => 'float', |
|
90 | + 'string' => 'string', |
|
91 | + 'text' => 'string', |
|
92 | + 'date' => 'date', |
|
93 | + 'datetime' => 'date', |
|
94 | 94 | 'boolean' => 'boolean' |
95 | 95 | ); |
96 | 96 | |
97 | - protected $dataTypes = array (); |
|
97 | + protected $dataTypes = array(); |
|
98 | 98 | |
99 | 99 | const SEPARETOR = ""; |
100 | 100 | |
@@ -103,9 +103,9 @@ discard block |
||
103 | 103 | * |
104 | 104 | * @return bool |
105 | 105 | */ |
106 | - protected function checkConfig () |
|
106 | + protected function checkConfig() |
|
107 | 107 | { |
108 | - if ( array_diff_key ( $this->attRequered , array_filter ( $this->arrConfig ) ) ) |
|
108 | + if (array_diff_key($this->attRequered, array_filter($this->arrConfig))) |
|
109 | 109 | { |
110 | 110 | return false; |
111 | 111 | } |
@@ -118,33 +118,33 @@ discard block |
||
118 | 118 | * |
119 | 119 | * @return array |
120 | 120 | */ |
121 | - abstract protected function getParams (); |
|
121 | + abstract protected function getParams(); |
|
122 | 122 | |
123 | 123 | /** |
124 | 124 | * Popula as config do generater com as configuraçoes do framework |
125 | 125 | * |
126 | 126 | * @return mixed |
127 | 127 | */ |
128 | - abstract protected function parseFrameworkConfig (); |
|
128 | + abstract protected function parseFrameworkConfig(); |
|
129 | 129 | |
130 | 130 | /** |
131 | 131 | * Cria Instancias dos arquivos que devem ser gerados |
132 | 132 | * |
133 | 133 | * @return \Classes\AdapterMakerFile\AbstractAdapter[] |
134 | 134 | */ |
135 | - abstract public function getMakeFileInstances (); |
|
135 | + abstract public function getMakeFileInstances(); |
|
136 | 136 | |
137 | - abstract protected function init (); |
|
137 | + abstract protected function init(); |
|
138 | 138 | |
139 | 139 | /** |
140 | 140 | * retorna a base do Namespace |
141 | 141 | * |
142 | 142 | * @return array |
143 | 143 | */ |
144 | - protected function getBaseNamespace () |
|
144 | + protected function getBaseNamespace() |
|
145 | 145 | { |
146 | - return array ( |
|
147 | - $this->arrConfig[ 'namespace' ] , |
|
146 | + return array( |
|
147 | + $this->arrConfig['namespace'], |
|
148 | 148 | 'Model' |
149 | 149 | ); |
150 | 150 | } |
@@ -155,54 +155,54 @@ discard block |
||
155 | 155 | * @return mixed |
156 | 156 | */ |
157 | 157 | |
158 | - public function createClassNamespace ( $table ) |
|
158 | + public function createClassNamespace($table) |
|
159 | 159 | { |
160 | - $arrNames = $this->getBaseNamespace (); |
|
160 | + $arrNames = $this->getBaseNamespace(); |
|
161 | 161 | |
162 | - if ( isset( $this->arrConfig[ 'folder-database' ] ) |
|
163 | - && $this->arrConfig[ 'folder-database' ] |
|
162 | + if (isset($this->arrConfig['folder-database']) |
|
163 | + && $this->arrConfig['folder-database'] |
|
164 | 164 | ) |
165 | 165 | { |
166 | - $arrNames[] = AbstractMaker::getClassName ( $this->arrConfig[ 'driver' ] ); |
|
166 | + $arrNames[] = AbstractMaker::getClassName($this->arrConfig['driver']); |
|
167 | 167 | } |
168 | 168 | |
169 | - if ( isset( $this->arrConfig[ 'folder-name' ] ) |
|
170 | - && $this->arrConfig[ 'folder-name' ] |
|
169 | + if (isset($this->arrConfig['folder-name']) |
|
170 | + && $this->arrConfig['folder-name'] |
|
171 | 171 | ) |
172 | 172 | { |
173 | - $arrNames[] = AbstractMaker::getClassName ( $this->arrConfig[ 'folder-name' ] ); |
|
173 | + $arrNames[] = AbstractMaker::getClassName($this->arrConfig['folder-name']); |
|
174 | 174 | } |
175 | 175 | |
176 | - if ( $table->hasSchema () ) |
|
176 | + if ($table->hasSchema()) |
|
177 | 177 | { |
178 | - $arrNames[] = $this->replaceReservedWord ( AbstractMaker::getClassName ( $table->getSchema () ) ); |
|
178 | + $arrNames[] = $this->replaceReservedWord(AbstractMaker::getClassName($table->getSchema())); |
|
179 | 179 | } else |
180 | 180 | { |
181 | - $arrNames[] = $this->replaceReservedWord ( AbstractMaker::getClassName ( $table->getDatabase () ) ); |
|
181 | + $arrNames[] = $this->replaceReservedWord(AbstractMaker::getClassName($table->getDatabase())); |
|
182 | 182 | } |
183 | 183 | |
184 | - return implode ( static::SEPARETOR , array_filter ( $arrNames ) ); |
|
184 | + return implode(static::SEPARETOR, array_filter($arrNames)); |
|
185 | 185 | } |
186 | 186 | |
187 | - public function __construct ( $array ) |
|
187 | + public function __construct($array) |
|
188 | 188 | { |
189 | 189 | $this->dataTypes = $this->dataTypes + self::$dataTypesDefault; |
190 | - $array += array ( |
|
191 | - 'version' => Config::$version , |
|
192 | - 'author' => ucfirst ( get_current_user () ) , |
|
193 | - 'last_modify' => date ( "d-m-Y H:i:s." ) |
|
190 | + $array += array( |
|
191 | + 'version' => Config::$version, |
|
192 | + 'author' => ucfirst(get_current_user()), |
|
193 | + 'last_modify' => date("d-m-Y H:i:s.") |
|
194 | 194 | ); |
195 | 195 | |
196 | - $this->setFrameworkFiles ( $array ); |
|
197 | - $this->parseFrameworkConfig (); |
|
198 | - $this->setParams ( $this->getParams () ); |
|
199 | - $this->setParams ( $array ); |
|
200 | - $this->init (); |
|
201 | - $this->validTableNames (); |
|
202 | - if ( ! $this->isValid () ) |
|
196 | + $this->setFrameworkFiles($array); |
|
197 | + $this->parseFrameworkConfig(); |
|
198 | + $this->setParams($this->getParams()); |
|
199 | + $this->setParams($array); |
|
200 | + $this->init(); |
|
201 | + $this->validTableNames(); |
|
202 | + if ( ! $this->isValid()) |
|
203 | 203 | { |
204 | - $var = array_diff_key ( $this->attRequered , array_filter ( $this->arrConfig ) ); |
|
205 | - throw new Exception( $var ); |
|
204 | + $var = array_diff_key($this->attRequered, array_filter($this->arrConfig)); |
|
205 | + throw new Exception($var); |
|
206 | 206 | } |
207 | 207 | } |
208 | 208 | |
@@ -211,43 +211,43 @@ discard block |
||
211 | 211 | * |
212 | 212 | * @param $array |
213 | 213 | */ |
214 | - public function setFrameworkFiles ( $array ) |
|
214 | + public function setFrameworkFiles($array) |
|
215 | 215 | { |
216 | - $this->framworkFiles[ 'library' ] = isset( $array[ 'framework-path-library' ] ) |
|
217 | - ? $array[ 'framework-path-library' ] : null; |
|
216 | + $this->framworkFiles['library'] = isset($array['framework-path-library']) |
|
217 | + ? $array['framework-path-library'] : null; |
|
218 | 218 | |
219 | - $this->framworkFiles[ 'ini' ] = isset( $array[ 'framework-ini' ] ) |
|
220 | - ? $array[ 'framework-ini' ] : null; |
|
219 | + $this->framworkFiles['ini'] = isset($array['framework-ini']) |
|
220 | + ? $array['framework-ini'] : null; |
|
221 | 221 | |
222 | - $this->framworkFiles[ 'environment' ] = isset( $array[ 'environment' ] ) |
|
223 | - ? $array[ 'environment' ] : 'production'; |
|
222 | + $this->framworkFiles['environment'] = isset($array['environment']) |
|
223 | + ? $array['environment'] : 'production'; |
|
224 | 224 | |
225 | 225 | } |
226 | 226 | |
227 | - protected function isValidFrameworkFiles () |
|
227 | + protected function isValidFrameworkFiles() |
|
228 | 228 | { |
229 | - if ( ! is_file ( $this->framworkFiles[ 'ini' ] ) ) |
|
229 | + if ( ! is_file($this->framworkFiles['ini'])) |
|
230 | 230 | { |
231 | 231 | return false; |
232 | 232 | } |
233 | 233 | |
234 | - if ( ! is_dir ( $this->framworkFiles[ 'library' ] ) ) |
|
234 | + if ( ! is_dir($this->framworkFiles['library'])) |
|
235 | 235 | { |
236 | 236 | return false; |
237 | 237 | } |
238 | 238 | |
239 | - if ( ! isset ( $this->framworkFiles[ 'environment' ] ) |
|
240 | - or empty( $this->framworkFiles[ 'environment' ] ) |
|
239 | + if ( ! isset ($this->framworkFiles['environment']) |
|
240 | + or empty($this->framworkFiles['environment']) |
|
241 | 241 | ) |
242 | 242 | { |
243 | 243 | return false; |
244 | 244 | } |
245 | - set_include_path ( |
|
246 | - implode ( |
|
247 | - PATH_SEPARATOR , |
|
248 | - array ( |
|
249 | - realpath ( $this->framworkFiles[ 'library' ] ) , |
|
250 | - get_include_path () , |
|
245 | + set_include_path( |
|
246 | + implode( |
|
247 | + PATH_SEPARATOR, |
|
248 | + array( |
|
249 | + realpath($this->framworkFiles['library']), |
|
250 | + get_include_path(), |
|
251 | 251 | ) |
252 | 252 | ) |
253 | 253 | ); |
@@ -255,112 +255,112 @@ discard block |
||
255 | 255 | return true; |
256 | 256 | } |
257 | 257 | |
258 | - protected function getFrameworkIni () |
|
258 | + protected function getFrameworkIni() |
|
259 | 259 | { |
260 | - return $this->framworkFiles[ 'ini' ]; |
|
260 | + return $this->framworkFiles['ini']; |
|
261 | 261 | } |
262 | 262 | |
263 | - protected function getEnvironment () |
|
263 | + protected function getEnvironment() |
|
264 | 264 | { |
265 | - return $this->framworkFiles[ 'environment' ]; |
|
265 | + return $this->framworkFiles['environment']; |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
269 | 269 | * Popula as variaveis de acordo com o arquivo de configuração do seu framework |
270 | 270 | */ |
271 | - protected function isValid () |
|
271 | + protected function isValid() |
|
272 | 272 | { |
273 | - return $this->checkConfig (); |
|
273 | + return $this->checkConfig(); |
|
274 | 274 | } |
275 | 275 | |
276 | - private function setParams ( $array ) |
|
276 | + private function setParams($array) |
|
277 | 277 | { |
278 | - if ( count ( $array ) > 0 ) |
|
278 | + if (count($array) > 0) |
|
279 | 279 | { |
280 | - $this->arrConfig = array_filter ( $array ) + $this->arrConfig; |
|
280 | + $this->arrConfig = array_filter($array) + $this->arrConfig; |
|
281 | 281 | } |
282 | 282 | } |
283 | 283 | |
284 | 284 | /** |
285 | 285 | * @return string |
286 | 286 | */ |
287 | - public function getDatabase () |
|
287 | + public function getDatabase() |
|
288 | 288 | { |
289 | - return $this->arrConfig[ 'database' ]; |
|
289 | + return $this->arrConfig['database']; |
|
290 | 290 | } |
291 | 291 | |
292 | 292 | /** |
293 | 293 | * @return bool |
294 | 294 | */ |
295 | - public function hasSchemas () |
|
295 | + public function hasSchemas() |
|
296 | 296 | { |
297 | - return ! empty ( $this->arrConfig[ 'schema' ] ); |
|
297 | + return ! empty ($this->arrConfig['schema']); |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | /** |
301 | 301 | * @return string[] |
302 | 302 | */ |
303 | - public function getSchemas () |
|
303 | + public function getSchemas() |
|
304 | 304 | { |
305 | - if ( is_string ( $this->arrConfig[ 'schema' ] ) ) |
|
305 | + if (is_string($this->arrConfig['schema'])) |
|
306 | 306 | { |
307 | - return array ( $this->arrConfig[ 'schema' ] ); |
|
307 | + return array($this->arrConfig['schema']); |
|
308 | 308 | } |
309 | 309 | |
310 | - return $this->arrConfig[ 'schema' ]; |
|
310 | + return $this->arrConfig['schema']; |
|
311 | 311 | } |
312 | 312 | |
313 | - public function setSchema ( $schema ) |
|
313 | + public function setSchema($schema) |
|
314 | 314 | { |
315 | - $this->arrConfig[ 'schema' ] = $schema; |
|
315 | + $this->arrConfig['schema'] = $schema; |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | /** |
319 | 319 | * @return string |
320 | 320 | */ |
321 | - public function getHost () |
|
321 | + public function getHost() |
|
322 | 322 | { |
323 | - return $this->arrConfig[ 'host' ]; |
|
323 | + return $this->arrConfig['host']; |
|
324 | 324 | } |
325 | 325 | |
326 | 326 | /** |
327 | 327 | * @return int |
328 | 328 | */ |
329 | - public function getPort () |
|
329 | + public function getPort() |
|
330 | 330 | { |
331 | - return $this->arrConfig[ 'port' ]; |
|
331 | + return $this->arrConfig['port']; |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | /** |
335 | 335 | * @return boolean |
336 | 336 | */ |
337 | - public function hasPort () |
|
337 | + public function hasPort() |
|
338 | 338 | { |
339 | - return ! empty( $this->arrConfig[ 'port' ] ); |
|
339 | + return ! empty($this->arrConfig['port']); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | /** |
343 | 343 | * @return string |
344 | 344 | */ |
345 | - public function getSocket () |
|
345 | + public function getSocket() |
|
346 | 346 | { |
347 | - return $this->arrConfig[ 'socket' ]; |
|
347 | + return $this->arrConfig['socket']; |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | /** |
351 | 351 | * @return string |
352 | 352 | */ |
353 | - public function getUser () |
|
353 | + public function getUser() |
|
354 | 354 | { |
355 | - return $this->arrConfig[ 'username' ]; |
|
355 | + return $this->arrConfig['username']; |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | /** |
359 | 359 | * @return string |
360 | 360 | */ |
361 | - public function getPassword () |
|
361 | + public function getPassword() |
|
362 | 362 | { |
363 | - return $this->arrConfig[ 'password' ]; |
|
363 | + return $this->arrConfig['password']; |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | /** |
@@ -368,11 +368,11 @@ discard block |
||
368 | 368 | * |
369 | 369 | * @return string |
370 | 370 | */ |
371 | - public function replaceReservedWord ( $palavra ) |
|
371 | + public function replaceReservedWord($palavra) |
|
372 | 372 | { |
373 | - if ( isset( $this->reservedWord[ strtolower ( $palavra ) ] ) ) |
|
373 | + if (isset($this->reservedWord[strtolower($palavra)])) |
|
374 | 374 | { |
375 | - return $this->reservedWord[ strtolower ( $palavra ) ]; |
|
375 | + return $this->reservedWord[strtolower($palavra)]; |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | return $palavra; |
@@ -381,15 +381,15 @@ discard block |
||
381 | 381 | /** |
382 | 382 | * @return bool |
383 | 383 | */ |
384 | - public function isStatusEnabled () |
|
384 | + public function isStatusEnabled() |
|
385 | 385 | { |
386 | - return (bool) $this->arrConfig[ 'status' ]; |
|
386 | + return (bool) $this->arrConfig['status']; |
|
387 | 387 | } |
388 | 388 | |
389 | - public function validTableNames () |
|
389 | + public function validTableNames() |
|
390 | 390 | { |
391 | - $matches = preg_grep ( '*\.*' , $this->getTablesName () ); |
|
392 | - if ( count ( $matches ) ) |
|
391 | + $matches = preg_grep('*\.*', $this->getTablesName()); |
|
392 | + if (count($matches)) |
|
393 | 393 | { |
394 | 394 | die("error: Table name must not contain the schema\n"); |
395 | 395 | } |
@@ -398,28 +398,28 @@ discard block |
||
398 | 398 | /** |
399 | 399 | * @return bool |
400 | 400 | */ |
401 | - public function hasTablesName (){ |
|
402 | - return ! empty( $this->arrConfig[ 'tables' ] ); |
|
401 | + public function hasTablesName() { |
|
402 | + return ! empty($this->arrConfig['tables']); |
|
403 | 403 | } |
404 | 404 | |
405 | 405 | /** |
406 | 406 | * @return string[] |
407 | 407 | */ |
408 | - public function getTablesName () |
|
408 | + public function getTablesName() |
|
409 | 409 | { |
410 | - if ( is_string ( $this->arrConfig[ 'tables' ] ) ) |
|
410 | + if (is_string($this->arrConfig['tables'])) |
|
411 | 411 | { |
412 | - return array ( $this->arrConfig[ 'tables' ] ); |
|
412 | + return array($this->arrConfig['tables']); |
|
413 | 413 | } |
414 | 414 | |
415 | - return $this->arrConfig[ 'tables' ]; |
|
415 | + return $this->arrConfig['tables']; |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | /** |
419 | 419 | * @return string |
420 | 420 | */ |
421 | - public function getListTablesName(){ |
|
422 | - $str = implode("','", $this->getTablesName() ); |
|
421 | + public function getListTablesName() { |
|
422 | + $str = implode("','", $this->getTablesName()); |
|
423 | 423 | return "'$str'"; |
424 | 424 | } |
425 | 425 | |
@@ -428,25 +428,25 @@ discard block |
||
428 | 428 | * |
429 | 429 | * @return string |
430 | 430 | */ |
431 | - public function __get ( $str ) |
|
431 | + public function __get($str) |
|
432 | 432 | { |
433 | - $arr = array ( |
|
434 | - 'namespace' , |
|
435 | - 'framework' , |
|
436 | - 'author' , |
|
437 | - 'license' , |
|
438 | - 'version' , |
|
439 | - 'copyright' , |
|
440 | - 'link' , |
|
441 | - 'last_modify' , |
|
442 | - 'path' , |
|
443 | - 'folder-database' , |
|
433 | + $arr = array( |
|
434 | + 'namespace', |
|
435 | + 'framework', |
|
436 | + 'author', |
|
437 | + 'license', |
|
438 | + 'version', |
|
439 | + 'copyright', |
|
440 | + 'link', |
|
441 | + 'last_modify', |
|
442 | + 'path', |
|
443 | + 'folder-database', |
|
444 | 444 | 'folder-name' |
445 | 445 | ); |
446 | 446 | |
447 | - if ( in_array ( $str , $arr ) ) |
|
447 | + if (in_array($str, $arr)) |
|
448 | 448 | { |
449 | - return $this->arrConfig[ strtolower ( $str ) ]; |
|
449 | + return $this->arrConfig[strtolower($str)]; |
|
450 | 450 | } |
451 | 451 | |
452 | 452 | return; |
@@ -457,9 +457,9 @@ discard block |
||
457 | 457 | * |
458 | 458 | * @return string |
459 | 459 | */ |
460 | - public static function convertTypeToPHP ( $type ) |
|
460 | + public static function convertTypeToPHP($type) |
|
461 | 461 | { |
462 | - return self::$dataTypesDefault[ $type ]; |
|
462 | + return self::$dataTypesDefault[$type]; |
|
463 | 463 | } |
464 | 464 | |
465 | 465 | /** |
@@ -467,8 +467,8 @@ discard block |
||
467 | 467 | * |
468 | 468 | * @return string |
469 | 469 | */ |
470 | - public function convertTypeToTypeFramework ( $type ) |
|
470 | + public function convertTypeToTypeFramework($type) |
|
471 | 471 | { |
472 | - return $this->dataTypes[ $type ]; |
|
472 | + return $this->dataTypes[$type]; |
|
473 | 473 | } |
474 | 474 | } |
@@ -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; |
@@ -3,22 +3,22 @@ |
||
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"?> |
|
15 | - * @version <?=$this->config->version."\n"?> |
|
12 | + * @copyright <?=$this->config->copyright . "\n"?> |
|
13 | + * @license <?=$this->config->license . "\n"?> |
|
14 | + * @link <?=$this->config->link . "\n"?> |
|
15 | + * @version <?=$this->config->version . "\n"?> |
|
16 | 16 | */ |
17 | 17 | |
18 | 18 | |
19 | 19 | namespace <?=$objTables->getNamespace()?>; |
20 | 20 | |
21 | -class <?=$this->getClassName ( $objTables->getName () )?> extends \<?=$objTables->getNamespace()?>\Entity\<?=$this->getClassName ( $objTables->getName () ). "\n"?> |
|
21 | +class <?=$this->getClassName($objTables->getName())?> extends \<?=$objTables->getNamespace()?>\Entity\<?=$this->getClassName($objTables->getName()) . "\n"?> |
|
22 | 22 | { |
23 | 23 | /* @TODO Codifique aqui */ |
24 | 24 | } |
@@ -3,28 +3,28 @@ |
||
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()?>\Peer |
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"?> |
|
15 | - * @version <?=$this->config->version."\n"?> |
|
12 | + * @copyright <?=$this->config->copyright . "\n"?> |
|
13 | + * @license <?=$this->config->license . "\n"?> |
|
14 | + * @link <?=$this->config->link . "\n"?> |
|
15 | + * @version <?=$this->config->version . "\n"?> |
|
16 | 16 | */ |
17 | 17 | |
18 | 18 | namespace <?=$objTables->getNamespace()?>\Peer; |
19 | 19 | |
20 | -class <?=\Classes\Maker\AbstractMaker::getClassName ( $objTables->getName () )?> extends \<?=$this->config->namespace?$this->config->namespace."\\":""?>Models\<?=$objMakeFile->getParentClass() . "\n"?> |
|
20 | +class <?=\Classes\Maker\AbstractMaker::getClassName($objTables->getName())?> extends \<?=$this->config->namespace ? $this->config->namespace . "\\" : ""?>Models\<?=$objMakeFile->getParentClass() . "\n"?> |
|
21 | 21 | { |
22 | 22 | /** |
23 | 23 | * Name of the object for static instance |
24 | 24 | * |
25 | 25 | * @var string $className |
26 | 26 | */ |
27 | - protected static $className = '<?=$objTables->getNamespace()?>\<?=$this->getClassName ( $objTables->getName () )?>'; |
|
27 | + protected static $className = '<?=$objTables->getNamespace()?>\<?=$this->getClassName($objTables->getName())?>'; |
|
28 | 28 | |
29 | 29 | /* @TODO Codifique aqui */ |
30 | 30 | } |
31 | 31 | \ No newline at end of file |