@@ -172,6 +172,7 @@ |
||
172 | 172 | * @param $constraint_name |
173 | 173 | * @param $table_name |
174 | 174 | * @param $column_name |
175 | + * @param string $database |
|
175 | 176 | * |
176 | 177 | * @return $this |
177 | 178 | */ |
@@ -178,15 +178,15 @@ |
||
178 | 178 | public function createDependece ( $constraint_name , $table_name , $column_name ,$database, $schema = null ) |
179 | 179 | { |
180 | 180 | $objConstrantDependence = Constrant::getInstance () |
181 | - ->populate ( |
|
182 | - array ( |
|
183 | - 'constrant' => $constraint_name , |
|
184 | - 'schema' => $schema , |
|
185 | - 'table' => $table_name , |
|
186 | - 'column' => $column_name, |
|
187 | - 'database' => $database |
|
188 | - ) |
|
189 | - ); |
|
181 | + ->populate ( |
|
182 | + array ( |
|
183 | + 'constrant' => $constraint_name , |
|
184 | + 'schema' => $schema , |
|
185 | + 'table' => $table_name , |
|
186 | + 'column' => $column_name, |
|
187 | + 'database' => $database |
|
188 | + ) |
|
189 | + ); |
|
190 | 190 | |
191 | 191 | $this->addDependece ( $objConstrantDependence ); |
192 | 192 |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | * |
17 | 17 | * @author Pedro Alarcao <[email protected]> |
18 | 18 | */ |
19 | - final private function __construct () |
|
19 | + final private function __construct() |
|
20 | 20 | { |
21 | 21 | } |
22 | 22 | |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * |
26 | 26 | * @return \Classes\Db\Column |
27 | 27 | */ |
28 | - public static function getInstance () |
|
28 | + public static function getInstance() |
|
29 | 29 | { |
30 | 30 | return new Column(); |
31 | 31 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | /** |
79 | 79 | * @return string |
80 | 80 | */ |
81 | - public function getName () |
|
81 | + public function getName() |
|
82 | 82 | { |
83 | 83 | return $this->name; |
84 | 84 | } |
@@ -88,12 +88,12 @@ discard block |
||
88 | 88 | * |
89 | 89 | * @param $array |
90 | 90 | */ |
91 | - public function populate ( $array ) |
|
91 | + public function populate($array) |
|
92 | 92 | { |
93 | - $this->name = $array[ 'name' ]; |
|
94 | - $this->type = $array[ 'type' ]; |
|
95 | - $this->nullable = $array[ 'nullable' ]; |
|
96 | - $this->max_length = $array[ 'max_length' ]; |
|
93 | + $this->name = $array['name']; |
|
94 | + $this->type = $array['type']; |
|
95 | + $this->nullable = $array['nullable']; |
|
96 | + $this->max_length = $array['max_length']; |
|
97 | 97 | |
98 | 98 | return $this; |
99 | 99 | } |
@@ -101,31 +101,31 @@ discard block |
||
101 | 101 | /** |
102 | 102 | * @return boolean |
103 | 103 | */ |
104 | - public function isPrimaryKey () |
|
104 | + public function isPrimaryKey() |
|
105 | 105 | { |
106 | - return ! empty( $this->primarykey ); |
|
106 | + return ! empty($this->primarykey); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
110 | 110 | * @return boolean |
111 | 111 | */ |
112 | - public function isForeingkey () |
|
112 | + public function isForeingkey() |
|
113 | 113 | { |
114 | - return ! empty( $this->refForeingkey ); |
|
114 | + return ! empty($this->refForeingkey); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
118 | 118 | * @return boolean |
119 | 119 | */ |
120 | - public function hasDependence () |
|
120 | + public function hasDependence() |
|
121 | 121 | { |
122 | - return ! empty( $this->dependences ); |
|
122 | + return ! empty($this->dependences); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | /** |
126 | 126 | * @return string |
127 | 127 | */ |
128 | - public function getType () |
|
128 | + public function getType() |
|
129 | 129 | { |
130 | 130 | return $this->type; |
131 | 131 | } |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | /** |
134 | 134 | * @return string |
135 | 135 | */ |
136 | - public function getComment () |
|
136 | + public function getComment() |
|
137 | 137 | { |
138 | 138 | return $this->comment; |
139 | 139 | } |
@@ -141,7 +141,7 @@ discard block |
||
141 | 141 | /** |
142 | 142 | * @param string $comment |
143 | 143 | */ |
144 | - public function setComment ( $comment ) |
|
144 | + public function setComment($comment) |
|
145 | 145 | { |
146 | 146 | $this->comment = $comment; |
147 | 147 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | /** |
152 | 152 | * @param \Classes\Db\Constrant $primarykey |
153 | 153 | */ |
154 | - public function setPrimaryKey ( Constrant $primarykey ) |
|
154 | + public function setPrimaryKey(Constrant $primarykey) |
|
155 | 155 | { |
156 | 156 | $this->primarykey = $primarykey; |
157 | 157 | |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | /** |
162 | 162 | * @param \Classes\Db\Constrant $dependece |
163 | 163 | */ |
164 | - public function addDependece ( Constrant $dependece ) |
|
164 | + public function addDependece(Constrant $dependece) |
|
165 | 165 | { |
166 | 166 | $this->dependences[] = $dependece; |
167 | 167 | |
@@ -175,20 +175,20 @@ discard block |
||
175 | 175 | * |
176 | 176 | * @return $this |
177 | 177 | */ |
178 | - public function createDependece ( $constraint_name , $table_name , $column_name ,$database, $schema = null ) |
|
178 | + public function createDependece($constraint_name, $table_name, $column_name, $database, $schema = null) |
|
179 | 179 | { |
180 | - $objConstrantDependence = Constrant::getInstance () |
|
181 | - ->populate ( |
|
182 | - array ( |
|
183 | - 'constrant' => $constraint_name , |
|
184 | - 'schema' => $schema , |
|
185 | - 'table' => $table_name , |
|
180 | + $objConstrantDependence = Constrant::getInstance() |
|
181 | + ->populate( |
|
182 | + array( |
|
183 | + 'constrant' => $constraint_name, |
|
184 | + 'schema' => $schema, |
|
185 | + 'table' => $table_name, |
|
186 | 186 | 'column' => $column_name, |
187 | 187 | 'database' => $database |
188 | 188 | ) |
189 | 189 | ); |
190 | 190 | |
191 | - $this->addDependece ( $objConstrantDependence ); |
|
191 | + $this->addDependece($objConstrantDependence); |
|
192 | 192 | |
193 | 193 | return $this; |
194 | 194 | } |
@@ -196,7 +196,7 @@ discard block |
||
196 | 196 | /** |
197 | 197 | * @param \Classes\Db\Constrant $reference |
198 | 198 | */ |
199 | - public function addRefFk ( Constrant $reference ) |
|
199 | + public function addRefFk(Constrant $reference) |
|
200 | 200 | { |
201 | 201 | $this->refForeingkey = $reference; |
202 | 202 | |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | * |
209 | 209 | * @return \Classes\Db\Constrant |
210 | 210 | */ |
211 | - public function getFks () |
|
211 | + public function getFks() |
|
212 | 212 | { |
213 | 213 | return $this->refForeingkey; |
214 | 214 | } |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | * |
219 | 219 | * @return \Classes\Db\Constrant[] |
220 | 220 | */ |
221 | - public function getDependences () |
|
221 | + public function getDependences() |
|
222 | 222 | { |
223 | 223 | return $this->dependences; |
224 | 224 | } |
@@ -226,9 +226,9 @@ discard block |
||
226 | 226 | /** |
227 | 227 | * @return bool |
228 | 228 | */ |
229 | - public function hasDependences () |
|
229 | + public function hasDependences() |
|
230 | 230 | { |
231 | - return (bool) count ( $this->dependences ); |
|
231 | + return (bool) count($this->dependences); |
|
232 | 232 | } |
233 | 233 | |
234 | 234 | /** |
@@ -236,7 +236,7 @@ discard block |
||
236 | 236 | * |
237 | 237 | * @return \Classes\Db\Constrant[] |
238 | 238 | */ |
239 | - public function getPrimaryKey () |
|
239 | + public function getPrimaryKey() |
|
240 | 240 | { |
241 | 241 | return $this->primarykey; |
242 | 242 | } |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | /** |
245 | 245 | * |
246 | 246 | */ |
247 | - public function getMaxLength () |
|
247 | + public function getMaxLength() |
|
248 | 248 | { |
249 | 249 | return $this->max_length; |
250 | 250 | } |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | /** |
253 | 253 | * @return bool |
254 | 254 | */ |
255 | - public function hasSequence () |
|
255 | + public function hasSequence() |
|
256 | 256 | { |
257 | 257 | return (bool) $this->sequence; |
258 | 258 | } |
@@ -260,7 +260,7 @@ discard block |
||
260 | 260 | /** |
261 | 261 | * @return string |
262 | 262 | */ |
263 | - public function getSequence () |
|
263 | + public function getSequence() |
|
264 | 264 | { |
265 | 265 | return $this->sequence; |
266 | 266 | } |
@@ -268,7 +268,7 @@ discard block |
||
268 | 268 | /** |
269 | 269 | * @param string $sequence |
270 | 270 | */ |
271 | - public function setSequence ( $sequence ) |
|
271 | + public function setSequence($sequence) |
|
272 | 272 | { |
273 | 273 | $this->sequence = $sequence; |
274 | 274 | } |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | /** |
277 | 277 | * @return boolean |
278 | 278 | */ |
279 | - public function isNullable () |
|
279 | + public function isNullable() |
|
280 | 280 | { |
281 | 281 | return $this->nullable; |
282 | 282 | } |
@@ -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 | } |
@@ -107,32 +107,32 @@ discard block |
||
107 | 107 | if ( $table->hasColumn ( $constrant[ "column_name" ] ) ) |
108 | 108 | { |
109 | 109 | $objConstrant = Constrant::getInstance () |
110 | - ->populate ( |
|
111 | - array ( |
|
112 | - 'constrant' => $constrant[ 'constraint_name' ] , |
|
113 | - 'schema' => $constrant[ 'foreign_schema' ] , |
|
114 | - 'table' => $constrant[ 'foreign_table' ] , |
|
115 | - 'column' => $constrant[ 'foreign_column' ], |
|
116 | - 'database' => $this->database |
|
117 | - ) |
|
118 | - ); |
|
110 | + ->populate ( |
|
111 | + array ( |
|
112 | + 'constrant' => $constrant[ 'constraint_name' ] , |
|
113 | + 'schema' => $constrant[ 'foreign_schema' ] , |
|
114 | + 'table' => $constrant[ 'foreign_table' ] , |
|
115 | + 'column' => $constrant[ 'foreign_column' ], |
|
116 | + 'database' => $this->database |
|
117 | + ) |
|
118 | + ); |
|
119 | 119 | |
120 | 120 | switch ( $constrant[ 'constraint_type' ] ) |
121 | 121 | { |
122 | 122 | case "FOREIGN KEY": |
123 | 123 | $table->getColumn ( $constrant[ "column_name" ] ) |
124 | - ->addRefFk ( $objConstrant ); |
|
124 | + ->addRefFk ( $objConstrant ); |
|
125 | 125 | break; |
126 | 126 | case"PRIMARY KEY": |
127 | 127 | $table->getColumn ( $constrant[ "column_name" ] ) |
128 | - ->setPrimaryKey ( $objConstrant ) |
|
129 | - ->setSequence ( |
|
130 | - $this->getSequence ( |
|
131 | - $table_name , |
|
132 | - $constrant[ "column_name" ], |
|
133 | - $schema |
|
134 | - ) |
|
135 | - ); |
|
128 | + ->setPrimaryKey ( $objConstrant ) |
|
129 | + ->setSequence ( |
|
130 | + $this->getSequence ( |
|
131 | + $table_name , |
|
132 | + $constrant[ "column_name" ], |
|
133 | + $schema |
|
134 | + ) |
|
135 | + ); |
|
136 | 136 | break; |
137 | 137 | } |
138 | 138 | } |
@@ -152,13 +152,13 @@ discard block |
||
152 | 152 | if ( $table->hasColumn ( $constrant[ "foreign_column" ] ) ) |
153 | 153 | { |
154 | 154 | $table->getColumn ( $constrant[ "foreign_column" ] ) |
155 | - ->createDependece ( |
|
156 | - $constrant[ 'constraint_name' ] , |
|
157 | - $constrant[ 'table_name' ] , |
|
158 | - $constrant[ 'column_name' ] , |
|
159 | - $this->database, |
|
160 | - $constrant[ 'table_schema' ] |
|
161 | - ); |
|
155 | + ->createDependece ( |
|
156 | + $constrant[ 'constraint_name' ] , |
|
157 | + $constrant[ 'table_name' ] , |
|
158 | + $constrant[ 'column_name' ] , |
|
159 | + $this->database, |
|
160 | + $constrant[ 'table_schema' ] |
|
161 | + ); |
|
162 | 162 | } |
163 | 163 | } |
164 | 164 | } |
@@ -193,10 +193,10 @@ discard block |
||
193 | 193 | ); |
194 | 194 | |
195 | 195 | $this->getTable ( $key , $schema ) |
196 | - ->addColumn ( $column ) |
|
197 | - ->setNamespace ( |
|
198 | - $this->config->createClassNamespace ( $this->getTable ( $key , $schema ) ) |
|
199 | - ); |
|
196 | + ->addColumn ( $column ) |
|
197 | + ->setNamespace ( |
|
198 | + $this->config->createClassNamespace ( $this->getTable ( $key , $schema ) ) |
|
199 | + ); |
|
200 | 200 | } |
201 | 201 | } |
202 | 202 | |
@@ -256,13 +256,13 @@ discard block |
||
256 | 256 | public function createTable ( $nameTable , $schema = 0 ) |
257 | 257 | { |
258 | 258 | $this->objDbTables[ $schema ][ trim ( $nameTable ) ] = DbTable::getInstance () |
259 | - ->populate ( |
|
260 | - array ( |
|
261 | - 'table' => $nameTable , |
|
262 | - 'schema' => $schema , |
|
263 | - 'database' => $this->database |
|
264 | - ) |
|
265 | - ); |
|
259 | + ->populate ( |
|
260 | + array ( |
|
261 | + 'table' => $nameTable , |
|
262 | + 'schema' => $schema , |
|
263 | + 'database' => $this->database |
|
264 | + ) |
|
265 | + ); |
|
266 | 266 | |
267 | 267 | return $this; |
268 | 268 | } |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | /** |
60 | 60 | * @type \Classes\Db\DbTable[][] |
61 | 61 | */ |
62 | - private $objDbTables = array (); |
|
62 | + private $objDbTables = array(); |
|
63 | 63 | |
64 | 64 | /** |
65 | 65 | * @var AbstractAdapter |
@@ -74,22 +74,22 @@ discard block |
||
74 | 74 | /** |
75 | 75 | * analisa e popula as Foreing keys, Primary keys e dependencias do banco nos objetos |
76 | 76 | */ |
77 | - protected function parseConstrants () |
|
77 | + protected function parseConstrants() |
|
78 | 78 | { |
79 | - foreach ( $this->getListConstrant () as $constrant ) |
|
79 | + foreach ($this->getListConstrant() as $constrant) |
|
80 | 80 | { |
81 | 81 | |
82 | - $schema = $constrant[ 'table_schema' ]; |
|
83 | - $table_name = $constrant [ 'table_name' ]; |
|
84 | - $this->populateForeignAndPrimaryKeys ( $constrant , $table_name , $schema ); |
|
85 | - unset( $table_name , $schema ); |
|
82 | + $schema = $constrant['table_schema']; |
|
83 | + $table_name = $constrant ['table_name']; |
|
84 | + $this->populateForeignAndPrimaryKeys($constrant, $table_name, $schema); |
|
85 | + unset($table_name, $schema); |
|
86 | 86 | |
87 | - if ( $constrant[ 'constraint_type' ] == "FOREIGN KEY" ) |
|
87 | + if ($constrant['constraint_type'] == "FOREIGN KEY") |
|
88 | 88 | { |
89 | - $schema = $constrant[ 'foreign_schema' ]; |
|
90 | - $table_name = $constrant [ 'foreign_table' ]; |
|
91 | - $this->populateDependece ( $constrant , $table_name , $schema ); |
|
92 | - unset( $table_name , $schema ); |
|
89 | + $schema = $constrant['foreign_schema']; |
|
90 | + $table_name = $constrant ['foreign_table']; |
|
91 | + $this->populateDependece($constrant, $table_name, $schema); |
|
92 | + unset($table_name, $schema); |
|
93 | 93 | } |
94 | 94 | } |
95 | 95 | } |
@@ -99,37 +99,37 @@ discard block |
||
99 | 99 | * @param string $table_name |
100 | 100 | * @param int $schema |
101 | 101 | */ |
102 | - private function populateForeignAndPrimaryKeys ( $constrant , $table_name , $schema = 0 ) |
|
102 | + private function populateForeignAndPrimaryKeys($constrant, $table_name, $schema = 0) |
|
103 | 103 | { |
104 | - if ( $this->hasTable ( $table_name , $schema ) ) |
|
104 | + if ($this->hasTable($table_name, $schema)) |
|
105 | 105 | { |
106 | - $table = $this->getTable ( $table_name , $schema ); |
|
107 | - if ( $table->hasColumn ( $constrant[ "column_name" ] ) ) |
|
106 | + $table = $this->getTable($table_name, $schema); |
|
107 | + if ($table->hasColumn($constrant["column_name"])) |
|
108 | 108 | { |
109 | - $objConstrant = Constrant::getInstance () |
|
110 | - ->populate ( |
|
111 | - array ( |
|
112 | - 'constrant' => $constrant[ 'constraint_name' ] , |
|
113 | - 'schema' => $constrant[ 'foreign_schema' ] , |
|
114 | - 'table' => $constrant[ 'foreign_table' ] , |
|
115 | - 'column' => $constrant[ 'foreign_column' ], |
|
109 | + $objConstrant = Constrant::getInstance() |
|
110 | + ->populate( |
|
111 | + array( |
|
112 | + 'constrant' => $constrant['constraint_name'], |
|
113 | + 'schema' => $constrant['foreign_schema'], |
|
114 | + 'table' => $constrant['foreign_table'], |
|
115 | + 'column' => $constrant['foreign_column'], |
|
116 | 116 | 'database' => $this->database |
117 | 117 | ) |
118 | 118 | ); |
119 | 119 | |
120 | - switch ( $constrant[ 'constraint_type' ] ) |
|
120 | + switch ($constrant['constraint_type']) |
|
121 | 121 | { |
122 | 122 | case "FOREIGN KEY": |
123 | - $table->getColumn ( $constrant[ "column_name" ] ) |
|
124 | - ->addRefFk ( $objConstrant ); |
|
123 | + $table->getColumn($constrant["column_name"]) |
|
124 | + ->addRefFk($objConstrant); |
|
125 | 125 | break; |
126 | 126 | case"PRIMARY KEY": |
127 | - $table->getColumn ( $constrant[ "column_name" ] ) |
|
128 | - ->setPrimaryKey ( $objConstrant ) |
|
129 | - ->setSequence ( |
|
130 | - $this->getSequence ( |
|
131 | - $table_name , |
|
132 | - $constrant[ "column_name" ], |
|
127 | + $table->getColumn($constrant["column_name"]) |
|
128 | + ->setPrimaryKey($objConstrant) |
|
129 | + ->setSequence( |
|
130 | + $this->getSequence( |
|
131 | + $table_name, |
|
132 | + $constrant["column_name"], |
|
133 | 133 | $schema |
134 | 134 | ) |
135 | 135 | ); |
@@ -144,20 +144,20 @@ discard block |
||
144 | 144 | * @param string $table_name |
145 | 145 | * @param int $schema |
146 | 146 | */ |
147 | - private function populateDependece ( $constrant , $table_name , $schema = 0 ) |
|
147 | + private function populateDependece($constrant, $table_name, $schema = 0) |
|
148 | 148 | { |
149 | - if ( $this->hasTable ( $table_name , $schema ) ) |
|
149 | + if ($this->hasTable($table_name, $schema)) |
|
150 | 150 | { |
151 | - $table = $this->getTable ( $table_name , $schema ); |
|
152 | - if ( $table->hasColumn ( $constrant[ "foreign_column" ] ) ) |
|
151 | + $table = $this->getTable($table_name, $schema); |
|
152 | + if ($table->hasColumn($constrant["foreign_column"])) |
|
153 | 153 | { |
154 | - $table->getColumn ( $constrant[ "foreign_column" ] ) |
|
155 | - ->createDependece ( |
|
156 | - $constrant[ 'constraint_name' ] , |
|
157 | - $constrant[ 'table_name' ] , |
|
158 | - $constrant[ 'column_name' ] , |
|
154 | + $table->getColumn($constrant["foreign_column"]) |
|
155 | + ->createDependece( |
|
156 | + $constrant['constraint_name'], |
|
157 | + $constrant['table_name'], |
|
158 | + $constrant['column_name'], |
|
159 | 159 | $this->database, |
160 | - $constrant[ 'table_schema' ] |
|
160 | + $constrant['table_schema'] |
|
161 | 161 | ); |
162 | 162 | } |
163 | 163 | } |
@@ -166,36 +166,36 @@ discard block |
||
166 | 166 | /** |
167 | 167 | * cria um Array com nome das tabelas |
168 | 168 | */ |
169 | - public function parseTables () |
|
169 | + public function parseTables() |
|
170 | 170 | { |
171 | - if ( $this->hasTables () ) |
|
171 | + if ($this->hasTables()) |
|
172 | 172 | { |
173 | - return $this->getAllTables (); |
|
173 | + return $this->getAllTables(); |
|
174 | 174 | } |
175 | 175 | |
176 | - foreach ( $this->getListColumns () as $table ) |
|
176 | + foreach ($this->getListColumns() as $table) |
|
177 | 177 | { |
178 | - $schema = $table[ 'table_schema' ]; |
|
179 | - $key = $table [ 'table_name' ]; |
|
180 | - if ( ! $this->hasTable ( $key , $schema ) ) |
|
178 | + $schema = $table['table_schema']; |
|
179 | + $key = $table ['table_name']; |
|
180 | + if ( ! $this->hasTable($key, $schema)) |
|
181 | 181 | { |
182 | - $this->createTable ( $key , $schema ); |
|
182 | + $this->createTable($key, $schema); |
|
183 | 183 | } |
184 | 184 | |
185 | - $column = Column::getInstance () |
|
186 | - ->populate ( |
|
187 | - array ( |
|
188 | - 'name' => $table [ 'column_name' ] , |
|
189 | - 'type' => $this->convertTypeToPhp ( $table[ 'data_type' ] ) , |
|
190 | - 'nullable' => ( $table[ 'is_nullable' ] == 'YES' ) , |
|
191 | - 'max_length' => $table[ 'max_length' ] |
|
185 | + $column = Column::getInstance() |
|
186 | + ->populate( |
|
187 | + array( |
|
188 | + 'name' => $table ['column_name'], |
|
189 | + 'type' => $this->convertTypeToPhp($table['data_type']), |
|
190 | + 'nullable' => ($table['is_nullable'] == 'YES'), |
|
191 | + 'max_length' => $table['max_length'] |
|
192 | 192 | ) |
193 | 193 | ); |
194 | 194 | |
195 | - $this->getTable ( $key , $schema ) |
|
196 | - ->addColumn ( $column ) |
|
197 | - ->setNamespace ( |
|
198 | - $this->config->createClassNamespace ( $this->getTable ( $key , $schema ) ) |
|
195 | + $this->getTable($key, $schema) |
|
196 | + ->addColumn($column) |
|
197 | + ->setNamespace( |
|
198 | + $this->config->createClassNamespace($this->getTable($key, $schema)) |
|
199 | 199 | ); |
200 | 200 | } |
201 | 201 | } |
@@ -205,7 +205,7 @@ discard block |
||
205 | 205 | * |
206 | 206 | * @return int |
207 | 207 | */ |
208 | - abstract public function getTotalTables (); |
|
208 | + abstract public function getTotalTables(); |
|
209 | 209 | |
210 | 210 | /** |
211 | 211 | * Retorna o Nome da Sequence da tabela |
@@ -215,23 +215,23 @@ discard block |
||
215 | 215 | * |
216 | 216 | * @return string |
217 | 217 | */ |
218 | - abstract public function getSequence ( $table , $column, $schema=0 ); |
|
218 | + abstract public function getSequence($table, $column, $schema = 0); |
|
219 | 219 | |
220 | 220 | /** |
221 | 221 | * @return array |
222 | 222 | */ |
223 | - abstract public function getListConstrant (); |
|
223 | + abstract public function getListConstrant(); |
|
224 | 224 | |
225 | 225 | /** |
226 | 226 | * @param string $str |
227 | 227 | * |
228 | 228 | * @return string |
229 | 229 | */ |
230 | - protected function convertTypeToPhp ( $str ) |
|
230 | + protected function convertTypeToPhp($str) |
|
231 | 231 | { |
232 | - if ( isset( $this->dataTypes[ $str ] ) ) |
|
232 | + if (isset($this->dataTypes[$str])) |
|
233 | 233 | { |
234 | - return $this->dataTypes[ $str ]; |
|
234 | + return $this->dataTypes[$str]; |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | return 'string'; |
@@ -240,12 +240,12 @@ discard block |
||
240 | 240 | /** |
241 | 241 | * @return string |
242 | 242 | */ |
243 | - abstract public function getPDOString (); |
|
243 | + abstract public function getPDOString(); |
|
244 | 244 | |
245 | 245 | /** |
246 | 246 | * @return string |
247 | 247 | */ |
248 | - abstract public function getPDOSocketString (); |
|
248 | + abstract public function getPDOSocketString(); |
|
249 | 249 | |
250 | 250 | /** |
251 | 251 | * @param $nameTable |
@@ -253,13 +253,13 @@ discard block |
||
253 | 253 | * |
254 | 254 | * @return \Classes\Db\DbTable |
255 | 255 | */ |
256 | - public function createTable ( $nameTable , $schema = 0 ) |
|
256 | + public function createTable($nameTable, $schema = 0) |
|
257 | 257 | { |
258 | - $this->objDbTables[ $schema ][ trim ( $nameTable ) ] = DbTable::getInstance () |
|
259 | - ->populate ( |
|
260 | - array ( |
|
261 | - 'table' => $nameTable , |
|
262 | - 'schema' => $schema , |
|
258 | + $this->objDbTables[$schema][trim($nameTable)] = DbTable::getInstance() |
|
259 | + ->populate( |
|
260 | + array( |
|
261 | + 'table' => $nameTable, |
|
262 | + 'schema' => $schema, |
|
263 | 263 | 'database' => $this->database |
264 | 264 | ) |
265 | 265 | ); |
@@ -272,24 +272,24 @@ discard block |
||
272 | 272 | * |
273 | 273 | * @return \Classes\Db\DbTable[] |
274 | 274 | */ |
275 | - public function getTables ( $schema = 0 ) |
|
275 | + public function getTables($schema = 0) |
|
276 | 276 | { |
277 | - if ( ! isset( $this->objDbTables[ $schema ] ) ) |
|
277 | + if ( ! isset($this->objDbTables[$schema])) |
|
278 | 278 | { |
279 | - return array (); |
|
279 | + return array(); |
|
280 | 280 | } |
281 | 281 | |
282 | - return $this->objDbTables[ $schema ]; |
|
282 | + return $this->objDbTables[$schema]; |
|
283 | 283 | } |
284 | 284 | |
285 | - public function getAllTables () |
|
285 | + public function getAllTables() |
|
286 | 286 | { |
287 | 287 | return $this->objDbTables; |
288 | 288 | } |
289 | 289 | |
290 | - public function hasTables () |
|
290 | + public function hasTables() |
|
291 | 291 | { |
292 | - return ! empty( $this->objDbTables ); |
|
292 | + return ! empty($this->objDbTables); |
|
293 | 293 | } |
294 | 294 | |
295 | 295 | /** |
@@ -299,9 +299,9 @@ discard block |
||
299 | 299 | * |
300 | 300 | * @return \Classes\Db\DbTable |
301 | 301 | */ |
302 | - public function getTable ( $nameTable , $schema = 0 ) |
|
302 | + public function getTable($nameTable, $schema = 0) |
|
303 | 303 | { |
304 | - return $this->objDbTables[ $schema ][ trim ( $nameTable ) ]; |
|
304 | + return $this->objDbTables[$schema][trim($nameTable)]; |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | /** |
@@ -310,9 +310,9 @@ discard block |
||
310 | 310 | * |
311 | 311 | * @return bool |
312 | 312 | */ |
313 | - public function hasTable ( $nameTable , $schema = 0 ) |
|
313 | + public function hasTable($nameTable, $schema = 0) |
|
314 | 314 | { |
315 | - return isset( $this->objDbTables[ $schema ][ trim ( $nameTable ) ] ); |
|
315 | + return isset($this->objDbTables[$schema][trim($nameTable)]); |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | /** |
@@ -320,64 +320,64 @@ discard block |
||
320 | 320 | * |
321 | 321 | * @return array[] |
322 | 322 | */ |
323 | - abstract public function getListColumns (); |
|
323 | + abstract public function getListColumns(); |
|
324 | 324 | |
325 | 325 | /** |
326 | 326 | * Retorna um Array com nome das tabelas |
327 | 327 | * |
328 | 328 | * @return string[] |
329 | 329 | */ |
330 | - abstract public function getListNameTable (); |
|
330 | + abstract public function getListNameTable(); |
|
331 | 331 | |
332 | 332 | /** |
333 | 333 | * @param \Classes\AdapterConfig\AbstractAdapter $adapterConfig |
334 | 334 | */ |
335 | - public function __construct ( AbstractAdapter $adapterConfig ) |
|
335 | + public function __construct(AbstractAdapter $adapterConfig) |
|
336 | 336 | { |
337 | 337 | $this->config = $adapterConfig; |
338 | - $this->host = $adapterConfig->getHost (); |
|
339 | - $this->database = $adapterConfig->getDatabase (); |
|
340 | - $this->port = $adapterConfig->hasPort () ? $adapterConfig->getPort () |
|
338 | + $this->host = $adapterConfig->getHost(); |
|
339 | + $this->database = $adapterConfig->getDatabase(); |
|
340 | + $this->port = $adapterConfig->hasPort() ? $adapterConfig->getPort() |
|
341 | 341 | : $this->port; |
342 | - $this->username = $adapterConfig->getUser (); |
|
343 | - $this->password = $adapterConfig->getPassword (); |
|
344 | - $this->socket = $adapterConfig->getSocket (); |
|
342 | + $this->username = $adapterConfig->getUser(); |
|
343 | + $this->password = $adapterConfig->getPassword(); |
|
344 | + $this->socket = $adapterConfig->getSocket(); |
|
345 | 345 | |
346 | 346 | } |
347 | 347 | |
348 | 348 | /** |
349 | 349 | * Executa as consultas do banco de dados |
350 | 350 | */ |
351 | - public function runDatabase () |
|
351 | + public function runDatabase() |
|
352 | 352 | { |
353 | - $this->parseTables (); |
|
354 | - $this->parseConstrants (); |
|
353 | + $this->parseTables(); |
|
354 | + $this->parseConstrants(); |
|
355 | 355 | } |
356 | 356 | |
357 | 357 | /** |
358 | 358 | * |
359 | 359 | * @return \PDO |
360 | 360 | */ |
361 | - public function getPDO () |
|
361 | + public function getPDO() |
|
362 | 362 | { |
363 | - if ( is_null ( $this->_pdo ) ) |
|
363 | + if (is_null($this->_pdo)) |
|
364 | 364 | { |
365 | - if ( ! empty( $this->socket ) ) |
|
365 | + if ( ! empty($this->socket)) |
|
366 | 366 | { |
367 | - $pdoString = $this->getPDOSocketString (); |
|
367 | + $pdoString = $this->getPDOSocketString(); |
|
368 | 368 | } else |
369 | 369 | { |
370 | - $pdoString = $this->getPDOString (); |
|
370 | + $pdoString = $this->getPDOString(); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | try |
374 | 374 | { |
375 | - $this->_pdo = new \PDO ( |
|
376 | - $pdoString , $this->username , $this->password |
|
375 | + $this->_pdo = new \PDO( |
|
376 | + $pdoString, $this->username, $this->password |
|
377 | 377 | ); |
378 | - } catch ( \Exception $e ) |
|
378 | + } catch (\Exception $e) |
|
379 | 379 | { |
380 | - die ( "pdo error: " . $e->getMessage () . "\n" ); |
|
380 | + die ("pdo error: " . $e->getMessage() . "\n"); |
|
381 | 381 | } |
382 | 382 | } |
383 | 383 |
@@ -1,19 +1,19 @@ discard block |
||
1 | 1 | <?="<?php\n"?> |
2 | -<?php $className = $objTables->getNamespace(). '_Entity_' . \Classes\Maker\AbstractMaker::getClassName ( $objTables->getName () )?> |
|
2 | +<?php $className = $objTables->getNamespace() . '_Entity_' . \Classes\Maker\AbstractMaker::getClassName($objTables->getName())?> |
|
3 | 3 | |
4 | 4 | /** |
5 | 5 | * Application Entity |
6 | 6 | * |
7 | - * <?=$this->config->last_modify."\n"?> |
|
7 | + * <?=$this->config->last_modify . "\n"?> |
|
8 | 8 | * |
9 | - * @package <?=$objTables->getNamespace()."\n"?> |
|
9 | + * @package <?=$objTables->getNamespace() . "\n"?> |
|
10 | 10 | * @subpackage Entity |
11 | 11 | * |
12 | - * @author <?=$this->config->author."\n"?> |
|
12 | + * @author <?=$this->config->author . "\n"?> |
|
13 | 13 | * |
14 | - * @copyright <?=$this->config->copyright."\n"?> |
|
15 | - * @license <?=$this->config->license."\n"?> |
|
16 | - * @link <?=$this->config->link."\n"?> |
|
14 | + * @copyright <?=$this->config->copyright . "\n"?> |
|
15 | + * @license <?=$this->config->license . "\n"?> |
|
16 | + * @link <?=$this->config->link . "\n"?> |
|
17 | 17 | */ |
18 | 18 | |
19 | 19 | /** |
@@ -25,11 +25,11 @@ discard block |
||
25 | 25 | |
26 | 26 | <?php foreach ($objTables->getColumns() as $column): ?> |
27 | 27 | /** |
28 | - * Database constraint in the column <?=$column->getName()."\n"?> |
|
28 | + * Database constraint in the column <?=$column->getName() . "\n"?> |
|
29 | 29 | * |
30 | 30 | */ |
31 | 31 | const <?=strtoupper($column->getName())?> = '<?=$objTables->getName()?>.<?=$column->getName()?>'; |
32 | -<?php endforeach;?> |
|
32 | +<?php endforeach; ?> |
|
33 | 33 | |
34 | 34 | /** |
35 | 35 | * Nome da tabela DbTable do model |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | * @var string |
38 | 38 | * @access protected |
39 | 39 | */ |
40 | - protected $_tableClass = '<?=$objTables->getNamespace()?>_DbTable_<?=\Classes\Maker\AbstractMaker::getClassName ( $objTables->getName () )?>'; |
|
40 | + protected $_tableClass = '<?=$objTables->getNamespace()?>_DbTable_<?=\Classes\Maker\AbstractMaker::getClassName($objTables->getName())?>'; |
|
41 | 41 | |
42 | 42 | /** |
43 | 43 | * @see <?=$this->config->namespace?>Model_EntityAbstract::$_columnsList |
@@ -45,17 +45,17 @@ discard block |
||
45 | 45 | protected $_columnsList = array( |
46 | 46 | <?php foreach ($objTables->getColumns() as $column): ?> |
47 | 47 | self::<?=strtoupper($column->getName())?> => '<?=strtolower(\Classes\Maker\AbstractMaker::getClassName($column->getName()))?>', |
48 | -<?php endforeach;?> |
|
48 | +<?php endforeach; ?> |
|
49 | 49 | ); |
50 | 50 | |
51 | 51 | /** |
52 | 52 | * @see <?=$this->config->namespace?>Model_EntityAbstract::$_filters |
53 | 53 | */ |
54 | 54 | protected $_filters = array( |
55 | -<?php foreach ( $objTables->getColumns () as $column ): ?> |
|
55 | +<?php foreach ($objTables->getColumns() as $column): ?> |
|
56 | 56 | <?php |
57 | 57 | $filters = null; |
58 | - switch ( ucfirst ( $column->getType () ) ) |
|
58 | + switch (ucfirst($column->getType())) |
|
59 | 59 | { |
60 | 60 | case 'String': |
61 | 61 | $filters = 'StripTags", "StringTrim'; |
@@ -64,50 +64,50 @@ discard block |
||
64 | 64 | $filters = 'Digits'; |
65 | 65 | break; |
66 | 66 | default: |
67 | - $filters = ucfirst ( $column->getType () ); |
|
67 | + $filters = ucfirst($column->getType()); |
|
68 | 68 | break; |
69 | 69 | } |
70 | 70 | ?> |
71 | 71 | '<?=$column->getName()?>'=>array ( |
72 | - <?=( !empty( $filters ) ) ? "\"{$filters}\"\n" : null; ?> |
|
72 | + <?=( ! empty($filters)) ? "\"{$filters}\"\n" : null; ?> |
|
73 | 73 | ), |
74 | -<?php endforeach;?> |
|
74 | +<?php endforeach; ?> |
|
75 | 75 | ); |
76 | 76 | |
77 | 77 | /** |
78 | 78 | * @see <?=$this->config->namespace?>Model_EntityAbstract::$_validators |
79 | 79 | */ |
80 | 80 | protected $_validators= array( |
81 | -<?php foreach ( $objTables->getColumns () as $column ): ?> |
|
81 | +<?php foreach ($objTables->getColumns() as $column): ?> |
|
82 | 82 | <?php |
83 | - $validators = array (); |
|
83 | + $validators = array(); |
|
84 | 84 | |
85 | - $validators[] = $column->isNullable () ? "'allowEmpty' => true" : "'NotEmpty'"; |
|
85 | + $validators[] = $column->isNullable() ? "'allowEmpty' => true" : "'NotEmpty'"; |
|
86 | 86 | |
87 | - switch ( ucfirst ( $column->getType () ) ) |
|
87 | + switch (ucfirst($column->getType())) |
|
88 | 88 | { |
89 | 89 | case 'String': |
90 | - if ( $column->getMaxLength () ) |
|
90 | + if ($column->getMaxLength()) |
|
91 | 91 | { |
92 | - $validators[] = "array( 'StringLength', array( 'max' => " . $column->getMaxLength () . " ) )"; |
|
92 | + $validators[] = "array( 'StringLength', array( 'max' => " . $column->getMaxLength() . " ) )"; |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | break; |
96 | 96 | case 'Boolean': |
97 | 97 | break; |
98 | 98 | default: |
99 | - $name = ucfirst ( $column->getType () ); |
|
99 | + $name = ucfirst($column->getType()); |
|
100 | 100 | $validators[] = "'$name'"; |
101 | 101 | break; |
102 | 102 | } |
103 | - $validators = implode ( ", ", $validators )?> |
|
104 | - '<?= $column->getName () ?>' => array ( |
|
105 | - <?=( !empty( $validators ) ) ? "{$validators}\n" : null?> |
|
103 | + $validators = implode(", ", $validators)?> |
|
104 | + '<?= $column->getName() ?>' => array ( |
|
105 | + <?=( ! empty($validators)) ? "{$validators}\n" : null?> |
|
106 | 106 | ), |
107 | 107 | <?php endforeach; ?> |
108 | 108 | ); |
109 | 109 | |
110 | -<?php if( $objTables->hasPrimaryKey() ):?> |
|
110 | +<?php if ($objTables->hasPrimaryKey()):?> |
|
111 | 111 | /** |
112 | 112 | * Nome da Primary Key |
113 | 113 | * |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | */ |
117 | 117 | |
118 | 118 | protected $_primary = array( |
119 | - <?php foreach($objTables->getPrimarykeys() as $pks) : ?> |
|
119 | + <?php foreach ($objTables->getPrimarykeys() as $pks) : ?> |
|
120 | 120 | '<?=$pks->getName()?>', |
121 | 121 | <?php endforeach ?> |
122 | 122 | ); |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | */ |
131 | 131 | protected $_parent_<?=$parent['name']?>; |
132 | 132 | |
133 | -<?php endforeach;?> |
|
133 | +<?php endforeach; ?> |
|
134 | 134 | <?php foreach ($depends as $depend): ?> |
135 | 135 | /** |
136 | 136 | * Depends relation <?=\Classes\Maker\AbstractMaker::getClassName($depend['table']) . "\n"?> |
@@ -139,13 +139,13 @@ discard block |
||
139 | 139 | */ |
140 | 140 | protected $_depend_<?=$depend['name']?>; |
141 | 141 | |
142 | -<?php endforeach;?> |
|
142 | +<?php endforeach; ?> |
|
143 | 143 | <?php foreach ($objTables->getColumns() as $column): ?> |
144 | 144 | /** |
145 | 145 | * |
146 | - * Sets column <?=$column->getName()."\n"?> |
|
146 | + * Sets column <?=$column->getName() . "\n"?> |
|
147 | 147 | * |
148 | -<?php if ($column->getType()=='date'): ?> |
|
148 | +<?php if ($column->getType() == 'date'): ?> |
|
149 | 149 | * Stored in ISO 8601 format. |
150 | 150 | * |
151 | 151 | * @param string|Zend_Date $<?=$column->getName() . "\n"?> |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | */ |
157 | 157 | public function set<?=\Classes\Maker\AbstractMaker::getClassName($column->getName())?>($<?=$column->getName()?>) |
158 | 158 | { |
159 | -<?php switch ( $column->getType () ): |
|
159 | +<?php switch ($column->getType()): |
|
160 | 160 | case 'date': ?> |
161 | 161 | if (! empty($<?=$column->getName()?>)) |
162 | 162 | { |
@@ -195,16 +195,16 @@ discard block |
||
195 | 195 | /** |
196 | 196 | * Gets column <?=$column->getName() . "\n"?> |
197 | 197 | * |
198 | -<?php if ($column->getType()=='date'): ?> |
|
198 | +<?php if ($column->getType() == 'date'): ?> |
|
199 | 199 | * @param boolean $returnZendDate |
200 | 200 | * @return Zend_Date|null|string Zend_Date representation of this datetime if enabled, or ISO 8601 string if not |
201 | 201 | <?php else: ?> |
202 | 202 | * @return <?=$column->getType() . "\n"?> |
203 | 203 | <?php endif; ?> |
204 | 204 | */ |
205 | - public function get<?=\Classes\Maker\AbstractMaker::getClassName($column->getName())?>(<?php if ($column->getType()=='date'): ?>$returnZendDate = false <?php endif;?>) |
|
205 | + public function get<?=\Classes\Maker\AbstractMaker::getClassName($column->getName())?>(<?php if ($column->getType() == 'date'): ?>$returnZendDate = false <?php endif; ?>) |
|
206 | 206 | { |
207 | -<?php if ($column->getType()=='date'): ?> |
|
207 | +<?php if ($column->getType() == 'date'): ?> |
|
208 | 208 | if ($returnZendDate) |
209 | 209 | { |
210 | 210 | if ($this->_data['<?=$column->getName()?>'] === null) |
@@ -230,7 +230,7 @@ discard block |
||
230 | 230 | { |
231 | 231 | if ($this->_parent_<?=$parent['name']?> === null) |
232 | 232 | { |
233 | - $this->_parent_<?=$parent['name']?> = $this->findParentRow('<?=$objTables->getNamespace()?>_DbTable_<?=\Classes\Maker\AbstractMaker::getClassName ($parent['table'])?>', '<?=\Classes\Maker\AbstractMaker::getClassName($parent['name'])?>'); |
|
233 | + $this->_parent_<?=$parent['name']?> = $this->findParentRow('<?=$objTables->getNamespace()?>_DbTable_<?=\Classes\Maker\AbstractMaker::getClassName($parent['table'])?>', '<?=\Classes\Maker\AbstractMaker::getClassName($parent['name'])?>'); |
|
234 | 234 | } |
235 | 235 | |
236 | 236 | return $this->_parent_<?=$parent['name']?>; |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | { |
250 | 250 | if ($this->_depend_<?=$depend['name']?> === null) |
251 | 251 | { |
252 | - $this->_depend_<?=$depend['name']?> = $this->findDependentRowset('<?=$objTables->getNamespace()?>_DbTable_<?=\Classes\Maker\AbstractMaker::getClassName ($depend['table'])?>'); |
|
252 | + $this->_depend_<?=$depend['name']?> = $this->findDependentRowset('<?=$objTables->getNamespace()?>_DbTable_<?=\Classes\Maker\AbstractMaker::getClassName($depend['table'])?>'); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | return $this->_depend_<?=$depend['name']?>; |
@@ -3,20 +3,20 @@ discard block |
||
3 | 3 | /** |
4 | 4 | * Application Model DbTables |
5 | 5 | * |
6 | - * <?=$this->config->last_modify."\n"?> |
|
6 | + * <?=$this->config->last_modify . "\n"?> |
|
7 | 7 | * |
8 | 8 | * Tabela definida por 'tablename' |
9 | 9 | * |
10 | 10 | * @package <?=$objTables->getNamespace()?><?="\n"?> |
11 | 11 | * @subpackage DbTable |
12 | - * @author <?=$this->config->author."\n"?> |
|
12 | + * @author <?=$this->config->author . "\n"?> |
|
13 | 13 | * |
14 | - * @copyright <?=$this->config->copyright."\n"?> |
|
15 | - * @license <?=$this->config->license."\n"?> |
|
16 | - * @link <?=$this->config->link."\n"?> |
|
14 | + * @copyright <?=$this->config->copyright . "\n"?> |
|
15 | + * @license <?=$this->config->license . "\n"?> |
|
16 | + * @link <?=$this->config->link . "\n"?> |
|
17 | 17 | */ |
18 | 18 | |
19 | -class <?=$objTables->getNamespace()?>_DbTable_<?=\Classes\Maker\AbstractMaker::getClassName ( $objTables->getName () )?> extends <?=$this->config->namespace?>Model_<?=$objMakeFile->getParentClass() . "\n"?> |
|
19 | +class <?=$objTables->getNamespace()?>_DbTable_<?=\Classes\Maker\AbstractMaker::getClassName($objTables->getName())?> extends <?=$this->config->namespace?>Model_<?=$objMakeFile->getParentClass() . "\n"?> |
|
20 | 20 | { |
21 | 21 | /** |
22 | 22 | * Nome da tabela do banco de dados |
@@ -25,7 +25,7 @@ discard block |
||
25 | 25 | * @access protected |
26 | 26 | */ |
27 | 27 | protected $_name = '<?=$objTables->getName()?>'; |
28 | -<?php if($objTables->hasSchema()): ?> |
|
28 | +<?php if ($objTables->hasSchema()): ?> |
|
29 | 29 | |
30 | 30 | /** |
31 | 31 | * Schema da tabela do banco de dados |
@@ -42,9 +42,9 @@ discard block |
||
42 | 42 | * @var string |
43 | 43 | * @access protected |
44 | 44 | */ |
45 | - protected $_rowClass = '<?=$objTables->getNamespace()?>_<?=\Classes\Maker\AbstractMaker::getClassName ( $objTables->getName () )?>'; |
|
45 | + protected $_rowClass = '<?=$objTables->getNamespace()?>_<?=\Classes\Maker\AbstractMaker::getClassName($objTables->getName())?>'; |
|
46 | 46 | |
47 | -<?php if( $objTables->hasPrimaryKey() ):?> |
|
47 | +<?php if ($objTables->hasPrimaryKey()):?> |
|
48 | 48 | /** |
49 | 49 | * Nome da Primary Key |
50 | 50 | * |
@@ -52,12 +52,12 @@ discard block |
||
52 | 52 | * @access protected |
53 | 53 | */ |
54 | 54 | protected $_primary = array( |
55 | -<?php foreach($objTables->getPrimaryKeys() as $pks):?> |
|
55 | +<?php foreach ($objTables->getPrimaryKeys() as $pks):?> |
|
56 | 56 | '<?=$pks->getName()?>', |
57 | 57 | <?php endforeach; ?> |
58 | 58 | ); |
59 | 59 | <?php endif ?> |
60 | -<?php if( $objTables->hasSequences() ) : ?> |
|
60 | +<?php if ($objTables->hasSequences()) : ?> |
|
61 | 61 | |
62 | 62 | /** |
63 | 63 | * Definir a lógica para os novos valores na chave primária. |
@@ -66,9 +66,9 @@ discard block |
||
66 | 66 | * @var mixed |
67 | 67 | */ |
68 | 68 | |
69 | -<?php if ( 1 == count($objTables->getSequences() ) ) : ?> |
|
70 | -<?php if(strpos($this->config->driver, 'pgsql')): ?> |
|
71 | -<?php $seqs = $objTables->getSequences();reset($seqs);$seq = current($seqs);?> |
|
69 | +<?php if (1 == count($objTables->getSequences())) : ?> |
|
70 | +<?php if (strpos($this->config->driver, 'pgsql')): ?> |
|
71 | +<?php $seqs = $objTables->getSequences(); reset($seqs); $seq = current($seqs); ?> |
|
72 | 72 | protected $_sequence = '<?=$seq->getSequence() ?>'; |
73 | 73 | <?php else: ?> |
74 | 74 | protected $_sequence = true; |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | /** |
53 | 53 | * @var array |
54 | 54 | */ |
55 | - private $argv = array (); |
|
55 | + private $argv = array(); |
|
56 | 56 | |
57 | 57 | /** |
58 | 58 | * @var \Classes\AdapterConfig\AbstractAdapter |
@@ -64,20 +64,20 @@ discard block |
||
64 | 64 | */ |
65 | 65 | private $adapterDriver; |
66 | 66 | |
67 | - private $frameworkList = array ( |
|
67 | + private $frameworkList = array( |
|
68 | 68 | 'zf1', 'phalcon' |
69 | 69 | ); |
70 | 70 | |
71 | - public function __construct ( $argv, $basePath ) |
|
71 | + public function __construct($argv, $basePath) |
|
72 | 72 | { |
73 | - if ( array_key_exists ( 'help', $argv ) ) { |
|
74 | - die ( $this->getUsage () ); |
|
73 | + if (array_key_exists('help', $argv)) { |
|
74 | + die ($this->getUsage()); |
|
75 | 75 | } |
76 | - if ( array_key_exists ( 'status', $argv ) ) { |
|
77 | - $argv[ 'status' ] = true; |
|
76 | + if (array_key_exists('status', $argv)) { |
|
77 | + $argv['status'] = true; |
|
78 | 78 | } |
79 | 79 | |
80 | - $this->argv = $this->parseConfig ( $basePath, $argv ); |
|
80 | + $this->argv = $this->parseConfig($basePath, $argv); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -85,9 +85,9 @@ discard block |
||
85 | 85 | * |
86 | 86 | * @return string |
87 | 87 | */ |
88 | - public function getUsage () |
|
88 | + public function getUsage() |
|
89 | 89 | { |
90 | - $version = $this->getVersion (); |
|
90 | + $version = $this->getVersion(); |
|
91 | 91 | |
92 | 92 | return <<<EOF |
93 | 93 | parameters: |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | EOF; |
111 | 111 | } |
112 | 112 | |
113 | - public function getVersion () |
|
113 | + public function getVersion() |
|
114 | 114 | { |
115 | 115 | $version = static::$version; |
116 | 116 | |
@@ -126,26 +126,26 @@ discard block |
||
126 | 126 | * @return array |
127 | 127 | * @throws \Exception |
128 | 128 | */ |
129 | - private function parseConfig ( $basePath, $argv ) |
|
129 | + private function parseConfig($basePath, $argv) |
|
130 | 130 | { |
131 | - $this->_basePath = dirname ( $basePath ); |
|
131 | + $this->_basePath = dirname($basePath); |
|
132 | 132 | |
133 | - $configIni = isset( $argv[ 'config-ini' ] ) ? $argv[ 'config-ini' ] |
|
133 | + $configIni = isset($argv['config-ini']) ? $argv['config-ini'] |
|
134 | 134 | : $this->_basePath . $this->configIniDefault; |
135 | 135 | |
136 | - $configTemp = $this->loadIniFile ( realpath ( $configIni ) ); |
|
137 | - $configCurrent = self::parseConfigEnv ( $configTemp, $argv ); |
|
136 | + $configTemp = $this->loadIniFile(realpath($configIni)); |
|
137 | + $configCurrent = self::parseConfigEnv($configTemp, $argv); |
|
138 | 138 | |
139 | - if ( !isset( $configCurrent[ 'framework' ] ) ) { |
|
140 | - throw new \Exception( "configure which framework you want to use! \n" ); |
|
139 | + if ( ! isset($configCurrent['framework'])) { |
|
140 | + throw new \Exception("configure which framework you want to use! \n"); |
|
141 | 141 | } |
142 | 142 | |
143 | - if ( !in_array ( $configCurrent[ 'framework' ], $this->frameworkList ) ) { |
|
143 | + if ( ! in_array($configCurrent['framework'], $this->frameworkList)) { |
|
144 | 144 | $frameworks = implode("\n\t", $this->frameworkList); |
145 | - throw new \Exception( "list of frameworks: \n".$frameworks."\n" ); |
|
145 | + throw new \Exception("list of frameworks: \n" . $frameworks . "\n"); |
|
146 | 146 | } |
147 | 147 | |
148 | - return $argv + array_filter ( $configCurrent ); |
|
148 | + return $argv + array_filter($configCurrent); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | /** |
@@ -155,21 +155,21 @@ discard block |
||
155 | 155 | * |
156 | 156 | * @return string |
157 | 157 | */ |
158 | - private static function parseConfigEnv ( $configTemp, $argv ) |
|
158 | + private static function parseConfigEnv($configTemp, $argv) |
|
159 | 159 | { |
160 | - $thisSection = isset( $configTemp[ key ( $configTemp ) ][ 'config-env' ] ) ? |
|
161 | - $configTemp[ key ( $configTemp ) ][ 'config-env' ] : null; |
|
160 | + $thisSection = isset($configTemp[key($configTemp)]['config-env']) ? |
|
161 | + $configTemp[key($configTemp)]['config-env'] : null; |
|
162 | 162 | |
163 | - $thisSection = isset( $argv[ 'config-env' ] ) ? $argv[ 'config-env' ] |
|
163 | + $thisSection = isset($argv['config-env']) ? $argv['config-env'] |
|
164 | 164 | : $thisSection; |
165 | 165 | |
166 | - if ( isset( $configTemp[ $thisSection ][ 'extends' ] ) ) { |
|
166 | + if (isset($configTemp[$thisSection]['extends'])) { |
|
167 | 167 | #faz marge da config principal com a config extendida |
168 | - return $configTemp[ $thisSection ] |
|
169 | - + $configTemp[ $configTemp[ $thisSection ][ 'extends' ] ]; |
|
168 | + return $configTemp[$thisSection] |
|
169 | + + $configTemp[$configTemp[$thisSection]['extends']]; |
|
170 | 170 | } |
171 | 171 | |
172 | - return $configTemp[ key ( $configTemp ) ]; |
|
172 | + return $configTemp[key($configTemp)]; |
|
173 | 173 | } |
174 | 174 | |
175 | 175 | /** |
@@ -183,29 +183,29 @@ discard block |
||
183 | 183 | * @throws \Exception |
184 | 184 | * @return array |
185 | 185 | */ |
186 | - protected function loadIniFile ( $filename ) |
|
186 | + protected function loadIniFile($filename) |
|
187 | 187 | { |
188 | - if ( !is_file ( $filename ) ) { |
|
189 | - throw new \Exception( "configuration file does not exist! \n" ); |
|
188 | + if ( ! is_file($filename)) { |
|
189 | + throw new \Exception("configuration file does not exist! \n"); |
|
190 | 190 | } |
191 | 191 | |
192 | - $loaded = parse_ini_file ( $filename, true ); |
|
193 | - $iniArray = array (); |
|
194 | - foreach ( $loaded as $key => $data ) { |
|
195 | - $pieces = explode ( $this->sectionSeparator, $key ); |
|
196 | - $thisSection = trim ( $pieces[ 0 ] ); |
|
197 | - switch ( count ( $pieces ) ) { |
|
192 | + $loaded = parse_ini_file($filename, true); |
|
193 | + $iniArray = array(); |
|
194 | + foreach ($loaded as $key => $data) { |
|
195 | + $pieces = explode($this->sectionSeparator, $key); |
|
196 | + $thisSection = trim($pieces[0]); |
|
197 | + switch (count($pieces)) { |
|
198 | 198 | case 1: |
199 | - $iniArray[ $thisSection ] = $data; |
|
199 | + $iniArray[$thisSection] = $data; |
|
200 | 200 | break; |
201 | 201 | |
202 | 202 | case 2: |
203 | - $extendedSection = trim ( $pieces[ 1 ] ); |
|
204 | - $iniArray[ $thisSection ] = array_merge ( array ( 'extends' => $extendedSection ), $data ); |
|
203 | + $extendedSection = trim($pieces[1]); |
|
204 | + $iniArray[$thisSection] = array_merge(array('extends' => $extendedSection), $data); |
|
205 | 205 | break; |
206 | 206 | |
207 | 207 | default: |
208 | - throw new \Exception( "Section '$thisSection' may not extend multiple sections in $filename" ); |
|
208 | + throw new \Exception("Section '$thisSection' may not extend multiple sections in $filename"); |
|
209 | 209 | } |
210 | 210 | } |
211 | 211 | |
@@ -218,15 +218,15 @@ discard block |
||
218 | 218 | * @return \Classes\AdapterConfig\AbstractAdapter |
219 | 219 | * |
220 | 220 | */ |
221 | - private function factoryConfig () |
|
221 | + private function factoryConfig() |
|
222 | 222 | { |
223 | - switch ( strtolower ( $this->argv[ 'framework' ] ) ) { |
|
223 | + switch (strtolower($this->argv['framework'])) { |
|
224 | 224 | case 'zf1': |
225 | - return new ZendFrameworkOne( $this->argv ); |
|
225 | + return new ZendFrameworkOne($this->argv); |
|
226 | 226 | case 'phalcon': |
227 | - return new Phalcon( $this->argv ); |
|
227 | + return new Phalcon($this->argv); |
|
228 | 228 | default: |
229 | - return new None( $this->argv ); |
|
229 | + return new None($this->argv); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | } |
@@ -236,31 +236,31 @@ discard block |
||
236 | 236 | * |
237 | 237 | * @return \Classes\AdapterConfig\AbstractAdapter |
238 | 238 | */ |
239 | - private function factoryDriver () |
|
239 | + private function factoryDriver() |
|
240 | 240 | { |
241 | - switch ( $this->argv[ 'driver' ] ) { |
|
241 | + switch ($this->argv['driver']) { |
|
242 | 242 | case 'pgsql': |
243 | 243 | case 'pdo_pgsql': |
244 | - return new Pgsql( $this->getAdapterConfig () ); |
|
244 | + return new Pgsql($this->getAdapterConfig()); |
|
245 | 245 | case 'mysql': |
246 | 246 | case 'pdo_mysql': |
247 | - return new Mysql( $this->getAdapterConfig () ); |
|
247 | + return new Mysql($this->getAdapterConfig()); |
|
248 | 248 | case 'mssql': |
249 | - return new Mssql( $this->getAdapterConfig () ); |
|
249 | + return new Mssql($this->getAdapterConfig()); |
|
250 | 250 | case 'dblib': |
251 | - return new Dblib( $this->getAdapterConfig () ); |
|
251 | + return new Dblib($this->getAdapterConfig()); |
|
252 | 252 | case 'sqlsrv': |
253 | - return new Sqlsrv( $this->getAdapterConfig () ); |
|
253 | + return new Sqlsrv($this->getAdapterConfig()); |
|
254 | 254 | } |
255 | 255 | } |
256 | 256 | |
257 | 257 | /** |
258 | 258 | * @return AdapterConfig\AbstractAdapter |
259 | 259 | */ |
260 | - public function getAdapterConfig () |
|
260 | + public function getAdapterConfig() |
|
261 | 261 | { |
262 | - if ( !$this->adapterConfig instanceof AbstractAdapter ) { |
|
263 | - $this->adapterConfig = $this->factoryConfig (); |
|
262 | + if ( ! $this->adapterConfig instanceof AbstractAdapter) { |
|
263 | + $this->adapterConfig = $this->factoryConfig(); |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | return $this->adapterConfig; |
@@ -269,10 +269,10 @@ discard block |
||
269 | 269 | /** |
270 | 270 | * @return AdaptersDriver\AbsractAdapter |
271 | 271 | */ |
272 | - public function getAdapterDriver () |
|
272 | + public function getAdapterDriver() |
|
273 | 273 | { |
274 | - if ( !$this->adapterDriver ) { |
|
275 | - $this->adapterDriver = $this->factoryDriver (); |
|
274 | + if ( ! $this->adapterDriver) { |
|
275 | + $this->adapterDriver = $this->factoryDriver(); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | return $this->adapterDriver; |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | /** |
19 | 19 | * @type string[] |
20 | 20 | */ |
21 | - public $location = array (); |
|
21 | + public $location = array(); |
|
22 | 22 | |
23 | 23 | /** |
24 | 24 | * caminho de pastas Base |
@@ -37,161 +37,161 @@ discard block |
||
37 | 37 | */ |
38 | 38 | private $driver; |
39 | 39 | |
40 | - public function __construct ( Config $config ) |
|
40 | + public function __construct(Config $config) |
|
41 | 41 | { |
42 | - $this->config = $config->getAdapterConfig (); |
|
43 | - $this->driver = $config->getAdapterDriver (); |
|
44 | - $this->parseLocation ( $config->_basePath ); |
|
42 | + $this->config = $config->getAdapterConfig(); |
|
43 | + $this->driver = $config->getAdapterDriver(); |
|
44 | + $this->parseLocation($config->_basePath); |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | /** |
48 | 48 | * Analisa os caminhos das pastas base |
49 | 49 | */ |
50 | - public function parseLocation ( $basePath ) |
|
50 | + public function parseLocation($basePath) |
|
51 | 51 | { |
52 | 52 | |
53 | - $arrBase = array ( |
|
54 | - $basePath , |
|
53 | + $arrBase = array( |
|
54 | + $basePath, |
|
55 | 55 | $this->config->path |
56 | 56 | ); |
57 | 57 | |
58 | - $this->baseLocation = implode ( DIRECTORY_SEPARATOR , array_filter ( $arrBase ) ); |
|
58 | + $this->baseLocation = implode(DIRECTORY_SEPARATOR, array_filter($arrBase)); |
|
59 | 59 | |
60 | 60 | # pasta com nome do driver do banco |
61 | 61 | $driverBase = ''; |
62 | - if ( $this->config->{"folder-database"} ) |
|
62 | + if ($this->config->{"folder-database"} ) |
|
63 | 63 | { |
64 | - $classDriver = explode ( '\\' , get_class ( $this->driver ) ); |
|
65 | - $driverBase = end ( $classDriver ); |
|
64 | + $classDriver = explode('\\', get_class($this->driver)); |
|
65 | + $driverBase = end($classDriver); |
|
66 | 66 | } |
67 | 67 | $folderName = ''; |
68 | - if ( $this->config->{"folder-name"} ) |
|
68 | + if ($this->config->{"folder-name"} ) |
|
69 | 69 | { |
70 | - $folderName = $this->getClassName ( trim ( $this->config->{"folder-name"} ) ); |
|
70 | + $folderName = $this->getClassName(trim($this->config->{"folder-name"} )); |
|
71 | 71 | } |
72 | 72 | |
73 | - if ( $this->config->hasSchemas () ) |
|
73 | + if ($this->config->hasSchemas()) |
|
74 | 74 | { |
75 | 75 | |
76 | - $schemas = $this->config->getSchemas (); |
|
77 | - foreach ( $schemas as $schema ) |
|
76 | + $schemas = $this->config->getSchemas(); |
|
77 | + foreach ($schemas as $schema) |
|
78 | 78 | { |
79 | - $arrUrl = array ( |
|
79 | + $arrUrl = array( |
|
80 | 80 | $this->baseLocation, |
81 | 81 | $driverBase, |
82 | 82 | $folderName, |
83 | - $this->getClassName ( $schema ) |
|
83 | + $this->getClassName($schema) |
|
84 | 84 | ); |
85 | 85 | |
86 | - $this->location[ $schema ] = implode ( DIRECTORY_SEPARATOR , array_filter ( $arrUrl ) ); |
|
87 | - unset( $arrUrl ); |
|
86 | + $this->location[$schema] = implode(DIRECTORY_SEPARATOR, array_filter($arrUrl)); |
|
87 | + unset($arrUrl); |
|
88 | 88 | } |
89 | 89 | |
90 | 90 | |
91 | 91 | } else |
92 | 92 | { |
93 | - $baseLocation = implode ( |
|
94 | - DIRECTORY_SEPARATOR , array_filter ( array ( |
|
95 | - $this->baseLocation , |
|
96 | - $driverBase , |
|
97 | - $folderName , |
|
98 | - $this->getClassName ( $this->getConfig ()->getDatabase () ) |
|
93 | + $baseLocation = implode( |
|
94 | + DIRECTORY_SEPARATOR, array_filter(array( |
|
95 | + $this->baseLocation, |
|
96 | + $driverBase, |
|
97 | + $folderName, |
|
98 | + $this->getClassName($this->getConfig()->getDatabase()) |
|
99 | 99 | ) |
100 | 100 | ) |
101 | 101 | ); |
102 | - $this->location = array ( $baseLocation ); |
|
102 | + $this->location = array($baseLocation); |
|
103 | 103 | } |
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
107 | 107 | * @return AdapterConfig\AbstractAdapter |
108 | 108 | */ |
109 | - public function getConfig () |
|
109 | + public function getConfig() |
|
110 | 110 | { |
111 | 111 | return $this->config; |
112 | 112 | } |
113 | 113 | |
114 | 114 | /* Get current time */ |
115 | - public function startTime () |
|
115 | + public function startTime() |
|
116 | 116 | { |
117 | 117 | echo "Starting..\n"; |
118 | - $this->startTime = microtime ( true ); |
|
118 | + $this->startTime = microtime(true); |
|
119 | 119 | } |
120 | 120 | |
121 | - private function getRunTime () |
|
121 | + private function getRunTime() |
|
122 | 122 | { |
123 | - return round ( ( microtime ( true ) - $this->startTime ) , 3 ); |
|
123 | + return round((microtime(true) - $this->startTime), 3); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
127 | 127 | * Executa o Make, criando arquivos e Diretorios |
128 | 128 | */ |
129 | - public function run () |
|
129 | + public function run() |
|
130 | 130 | { |
131 | - $this->startTime (); |
|
132 | - $this->driver->runDatabase (); |
|
133 | - $max = $this->driver->getTotalTables () * count ( $this->factoryMakerFile () ); |
|
131 | + $this->startTime(); |
|
132 | + $this->driver->runDatabase(); |
|
133 | + $max = $this->driver->getTotalTables() * count($this->factoryMakerFile()); |
|
134 | 134 | $cur = 0; |
135 | 135 | |
136 | 136 | |
137 | - foreach ( $this->location as $schema => $location ) |
|
137 | + foreach ($this->location as $schema => $location) |
|
138 | 138 | { |
139 | - foreach ( $this->factoryMakerFile () as $objMakeFile ) |
|
139 | + foreach ($this->factoryMakerFile() as $objMakeFile) |
|
140 | 140 | { |
141 | - $path = $location . DIRECTORY_SEPARATOR . $objMakeFile->getPastName (); |
|
142 | - self::makeDir ( $path ); |
|
141 | + $path = $location . DIRECTORY_SEPARATOR . $objMakeFile->getPastName(); |
|
142 | + self::makeDir($path); |
|
143 | 143 | |
144 | - if ( $objMakeFile->getParentFileTpl () != '' ) |
|
144 | + if ($objMakeFile->getParentFileTpl() != '') |
|
145 | 145 | { |
146 | 146 | $fileAbstract = $this->baseLocation |
147 | 147 | . DIRECTORY_SEPARATOR |
148 | - . $objMakeFile->getParentClass () . '.php'; |
|
148 | + . $objMakeFile->getParentClass() . '.php'; |
|
149 | 149 | |
150 | - $tplAbstract = $this->getParsedTplContents ( $objMakeFile->getParentFileTpl () ); |
|
151 | - self::makeSourcer ( $fileAbstract , $tplAbstract , $objMakeFile->isOverwrite () ); |
|
152 | - unset( $fileAbstract , $tplAbstract ); |
|
150 | + $tplAbstract = $this->getParsedTplContents($objMakeFile->getParentFileTpl()); |
|
151 | + self::makeSourcer($fileAbstract, $tplAbstract, $objMakeFile->isOverwrite()); |
|
152 | + unset($fileAbstract, $tplAbstract); |
|
153 | 153 | } |
154 | 154 | |
155 | - foreach ( $this->driver->getTables ( $schema ) as $key => $objTables ) |
|
155 | + foreach ($this->driver->getTables($schema) as $key => $objTables) |
|
156 | 156 | { |
157 | - $total = ceil ( $cur / $max ) * 100; |
|
158 | - printf ( "\r Creating: %6.2f%%" , $total ); |
|
159 | - $cur ++; |
|
157 | + $total = ceil($cur / $max) * 100; |
|
158 | + printf("\r Creating: %6.2f%%", $total); |
|
159 | + $cur++; |
|
160 | 160 | |
161 | 161 | $file = $path |
162 | 162 | . DIRECTORY_SEPARATOR |
163 | - . self::getClassName ( $objTables->getName () ) |
|
163 | + . self::getClassName($objTables->getName()) |
|
164 | 164 | . '.php'; |
165 | 165 | |
166 | 166 | |
167 | - $tpl = $this->getParsedTplContents ( |
|
168 | - $objMakeFile->getFileTpl () , |
|
169 | - $objMakeFile->parseRelation ( $this , $objTables ) |
|
170 | - , $objTables , $objMakeFile |
|
167 | + $tpl = $this->getParsedTplContents( |
|
168 | + $objMakeFile->getFileTpl(), |
|
169 | + $objMakeFile->parseRelation($this, $objTables) |
|
170 | + , $objTables, $objMakeFile |
|
171 | 171 | |
172 | 172 | ); |
173 | - self::makeSourcer ( $file , $tpl , $objMakeFile->isOverwrite () ); |
|
173 | + self::makeSourcer($file, $tpl, $objMakeFile->isOverwrite()); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | } |
177 | 177 | } |
178 | 178 | |
179 | - $this->reportProcess ( $cur ); |
|
179 | + $this->reportProcess($cur); |
|
180 | 180 | echo "\n\033[1;32mSuccessfully process finished!\n\033[0m"; |
181 | 181 | } |
182 | 182 | |
183 | - private function reportProcess ( $countFiles ) |
|
183 | + private function reportProcess($countFiles) |
|
184 | 184 | { |
185 | - if ( $this->config->isStatusEnabled () ) |
|
185 | + if ($this->config->isStatusEnabled()) |
|
186 | 186 | { |
187 | - $databases = count ( $this->location ); |
|
188 | - $countDir = $this->countDiretory (); |
|
189 | - $totalTable = $this->driver->getTotalTables (); |
|
187 | + $databases = count($this->location); |
|
188 | + $countDir = $this->countDiretory(); |
|
189 | + $totalTable = $this->driver->getTotalTables(); |
|
190 | 190 | echo "\n------"; |
191 | - printf ( "\n\r-Files generated:%s" , $countFiles ); |
|
192 | - printf ( "\n\r-Diretory generated:%s" , $databases * $countDir ); |
|
193 | - printf ( "\n\r-Scanned tables:%s" , $totalTable ); |
|
194 | - printf ( "\n\r-Execution time: %ssec" , $this->getRunTime () ); |
|
191 | + printf("\n\r-Files generated:%s", $countFiles); |
|
192 | + printf("\n\r-Diretory generated:%s", $databases * $countDir); |
|
193 | + printf("\n\r-Scanned tables:%s", $totalTable); |
|
194 | + printf("\n\r-Execution time: %ssec", $this->getRunTime()); |
|
195 | 195 | echo "\n------"; |
196 | 196 | } |
197 | 197 | } |
@@ -201,9 +201,9 @@ discard block |
||
201 | 201 | * |
202 | 202 | * @return AbstractAdapter[] |
203 | 203 | */ |
204 | - public function factoryMakerFile () |
|
204 | + public function factoryMakerFile() |
|
205 | 205 | { |
206 | - return $this->config->getMakeFileInstances (); |
|
206 | + return $this->config->getMakeFileInstances(); |
|
207 | 207 | } |
208 | 208 | |
209 | 209 | /** |
@@ -211,14 +211,14 @@ discard block |
||
211 | 211 | * |
212 | 212 | * @return int |
213 | 213 | */ |
214 | - public function countDiretory () |
|
214 | + public function countDiretory() |
|
215 | 215 | { |
216 | 216 | $dir = 0; |
217 | - foreach ( $this->factoryMakerFile () as $abstractAdapter ) |
|
217 | + foreach ($this->factoryMakerFile() as $abstractAdapter) |
|
218 | 218 | { |
219 | - if ( $abstractAdapter->hasDiretory () ) |
|
219 | + if ($abstractAdapter->hasDiretory()) |
|
220 | 220 | { |
221 | - $dir ++; |
|
221 | + $dir++; |
|
222 | 222 | } |
223 | 223 | } |
224 | 224 | |
@@ -233,23 +233,23 @@ discard block |
||
233 | 233 | * |
234 | 234 | * @return String |
235 | 235 | */ |
236 | - protected function getParsedTplContents ( $tplFile , $vars = array () , \Classes\Db\DbTable $objTables = null , $objMakeFile = null ) |
|
236 | + protected function getParsedTplContents($tplFile, $vars = array(), \Classes\Db\DbTable $objTables = null, $objMakeFile = null) |
|
237 | 237 | { |
238 | 238 | |
239 | - $arrUrl = array ( |
|
240 | - __DIR__ , |
|
241 | - 'templates' , |
|
242 | - $this->config->framework , |
|
239 | + $arrUrl = array( |
|
240 | + __DIR__, |
|
241 | + 'templates', |
|
242 | + $this->config->framework, |
|
243 | 243 | $tplFile |
244 | 244 | ); |
245 | 245 | |
246 | - $filePath = implode ( DIRECTORY_SEPARATOR , filter_var_array ( $arrUrl ) ); |
|
246 | + $filePath = implode(DIRECTORY_SEPARATOR, filter_var_array($arrUrl)); |
|
247 | 247 | |
248 | - extract ( $vars ); |
|
249 | - ob_start (); |
|
248 | + extract($vars); |
|
249 | + ob_start(); |
|
250 | 250 | require $filePath; |
251 | - $data = ob_get_contents (); |
|
252 | - ob_end_clean (); |
|
251 | + $data = ob_get_contents(); |
|
252 | + ob_end_clean(); |
|
253 | 253 | |
254 | 254 | return $data; |
255 | 255 | } |
@@ -14,68 +14,68 @@ discard block |
||
14 | 14 | abstract class AbstractAdapter |
15 | 15 | { |
16 | 16 | |
17 | - protected $arrConfig = array ( |
|
17 | + protected $arrConfig = array( |
|
18 | 18 | ############################# DATABASE |
19 | 19 | //Driver do banco de dados |
20 | - 'driver' => null , |
|
20 | + 'driver' => null, |
|
21 | 21 | //Nome do banco de dados |
22 | - 'database' => null , |
|
22 | + 'database' => null, |
|
23 | 23 | //Host do banco |
24 | - 'host' => 'localhost' , |
|
24 | + 'host' => 'localhost', |
|
25 | 25 | //Port do banco |
26 | - 'port' => '' , |
|
26 | + 'port' => '', |
|
27 | 27 | //usuario do banco |
28 | - 'username' => null , |
|
28 | + 'username' => null, |
|
29 | 29 | //senha do banco |
30 | - 'password' => null , |
|
30 | + 'password' => null, |
|
31 | 31 | // lista de schemas do banco de dados |
32 | - 'schema' => array () , |
|
32 | + 'schema' => array(), |
|
33 | 33 | |
34 | - 'socket' => null , |
|
34 | + 'socket' => null, |
|
35 | 35 | |
36 | 36 | ########################### DOCS |
37 | 37 | // autor que gerou o script |
38 | - 'author' => "Pedro" , |
|
39 | - 'license' => "New BSD License" , |
|
40 | - 'copyright' => "ORM Generator - Pedro151" , |
|
41 | - 'link' => 'https://github.com/pedro151/orm-generator' , |
|
38 | + 'author' => "Pedro", |
|
39 | + 'license' => "New BSD License", |
|
40 | + 'copyright' => "ORM Generator - Pedro151", |
|
41 | + 'link' => 'https://github.com/pedro151/orm-generator', |
|
42 | 42 | // data que foi gerado o script |
43 | - 'last_modify' => null , |
|
43 | + 'last_modify' => null, |
|
44 | 44 | |
45 | 45 | ########################## Ambiente/Arquivos |
46 | 46 | |
47 | 47 | // Nome do framework para o adapter |
48 | - 'framework' => null , |
|
48 | + 'framework' => null, |
|
49 | 49 | // namespace das classes |
50 | - 'namespace' => "" , |
|
50 | + 'namespace' => "", |
|
51 | 51 | // caminho onde os arquivos devem ser criados |
52 | - 'path' => 'models' , |
|
52 | + 'path' => 'models', |
|
53 | 53 | // flag para gerar pasta com o nome do driver do banco de dados |
54 | - 'folder-database' => 0 , |
|
54 | + 'folder-database' => 0, |
|
55 | 55 | |
56 | 56 | ############################## Comandos adicionais |
57 | 57 | //flag para mostrar o status da execução ao termino do processo |
58 | - 'status' => false , |
|
58 | + 'status' => false, |
|
59 | 59 | // flags para criar todas as tabelas ou nao |
60 | - 'allTables' => true , |
|
60 | + 'allTables' => true, |
|
61 | 61 | //Lista de tabelas a serem ignoradas |
62 | - 'ignoreTable' => array () , |
|
62 | + 'ignoreTable' => array(), |
|
63 | 63 | ); |
64 | 64 | |
65 | 65 | /** |
66 | 66 | * @var string[] um array com todos os campos obrigatorios |
67 | 67 | */ |
68 | - protected $attRequered = array ( |
|
69 | - 'driver' => true , |
|
70 | - 'database' => true , |
|
71 | - 'host' => true , |
|
72 | - 'username' => true , |
|
68 | + protected $attRequered = array( |
|
69 | + 'driver' => true, |
|
70 | + 'database' => true, |
|
71 | + 'host' => true, |
|
72 | + 'username' => true, |
|
73 | 73 | 'path' => true |
74 | 74 | ); |
75 | 75 | |
76 | - protected $arrFunc = array (); |
|
76 | + protected $arrFunc = array(); |
|
77 | 77 | |
78 | - private $framworkFiles = array (); |
|
78 | + private $framworkFiles = array(); |
|
79 | 79 | |
80 | 80 | const SEPARETOR = ""; |
81 | 81 | |
@@ -84,9 +84,9 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @return bool |
86 | 86 | */ |
87 | - protected function checkConfig () |
|
87 | + protected function checkConfig() |
|
88 | 88 | { |
89 | - if ( array_diff_key ( $this->attRequered , array_filter ( $this->arrConfig ) ) ) |
|
89 | + if (array_diff_key($this->attRequered, array_filter($this->arrConfig))) |
|
90 | 90 | { |
91 | 91 | return false; |
92 | 92 | } |
@@ -99,33 +99,33 @@ discard block |
||
99 | 99 | * |
100 | 100 | * @return array |
101 | 101 | */ |
102 | - abstract protected function getParams (); |
|
102 | + abstract protected function getParams(); |
|
103 | 103 | |
104 | 104 | /** |
105 | 105 | * Popula as config do generater com as configuraçoes do framework |
106 | 106 | * |
107 | 107 | * @return mixed |
108 | 108 | */ |
109 | - abstract protected function parseFrameworkConfig (); |
|
109 | + abstract protected function parseFrameworkConfig(); |
|
110 | 110 | |
111 | 111 | /** |
112 | 112 | * Cria Instancias dos arquivos que devem ser gerados |
113 | 113 | * |
114 | 114 | * @return \Classes\AdapterMakerFile\AbstractAdapter[] |
115 | 115 | */ |
116 | - abstract public function getMakeFileInstances (); |
|
116 | + abstract public function getMakeFileInstances(); |
|
117 | 117 | |
118 | - abstract protected function init (); |
|
118 | + abstract protected function init(); |
|
119 | 119 | |
120 | 120 | /** |
121 | 121 | * retorna a base do Namespace |
122 | 122 | * |
123 | 123 | * @return array |
124 | 124 | */ |
125 | - protected function getBaseNamespace () |
|
125 | + protected function getBaseNamespace() |
|
126 | 126 | { |
127 | - return array ( |
|
128 | - $this->arrConfig[ 'namespace' ] , |
|
127 | + return array( |
|
128 | + $this->arrConfig['namespace'], |
|
129 | 129 | 'Model' |
130 | 130 | ); |
131 | 131 | } |
@@ -136,51 +136,51 @@ discard block |
||
136 | 136 | * @return mixed |
137 | 137 | */ |
138 | 138 | |
139 | - public function createClassNamespace ( $table ) |
|
139 | + public function createClassNamespace($table) |
|
140 | 140 | { |
141 | - $arrNames = $this->getBaseNamespace (); |
|
141 | + $arrNames = $this->getBaseNamespace(); |
|
142 | 142 | |
143 | - if ( isset( $this->arrConfig[ 'folder-database' ] ) |
|
144 | - && $this->arrConfig[ 'folder-database' ] |
|
143 | + if (isset($this->arrConfig['folder-database']) |
|
144 | + && $this->arrConfig['folder-database'] |
|
145 | 145 | ) |
146 | 146 | { |
147 | - $arrNames[] = AbstractMaker::getClassName ( $this->arrConfig[ 'driver' ] ); |
|
147 | + $arrNames[] = AbstractMaker::getClassName($this->arrConfig['driver']); |
|
148 | 148 | } |
149 | 149 | |
150 | - if ( isset( $this->arrConfig[ 'folder-name' ] ) |
|
151 | - && $this->arrConfig[ 'folder-name' ] |
|
150 | + if (isset($this->arrConfig['folder-name']) |
|
151 | + && $this->arrConfig['folder-name'] |
|
152 | 152 | ) |
153 | 153 | { |
154 | - $arrNames[] = AbstractMaker::getClassName ( $this->arrConfig[ 'folder-name' ] ); |
|
154 | + $arrNames[] = AbstractMaker::getClassName($this->arrConfig['folder-name']); |
|
155 | 155 | } |
156 | 156 | |
157 | - if ( $table->hasSchema () ) |
|
157 | + if ($table->hasSchema()) |
|
158 | 158 | { |
159 | - $arrNames[] = AbstractMaker::getClassName ( $table->getSchema () ); |
|
159 | + $arrNames[] = AbstractMaker::getClassName($table->getSchema()); |
|
160 | 160 | } else |
161 | 161 | { |
162 | - $arrNames[] = AbstractMaker::getClassName ( $table->getDatabase () ); |
|
162 | + $arrNames[] = AbstractMaker::getClassName($table->getDatabase()); |
|
163 | 163 | } |
164 | 164 | |
165 | - return implode ( static::SEPARETOR , array_filter ( $arrNames ) ); |
|
165 | + return implode(static::SEPARETOR, array_filter($arrNames)); |
|
166 | 166 | } |
167 | 167 | |
168 | - public function __construct ( $array ) |
|
168 | + public function __construct($array) |
|
169 | 169 | { |
170 | - $array += array ( |
|
171 | - 'author' => ucfirst ( get_current_user () ) , |
|
172 | - 'last_modify' => date ( "d-m-Y H:i:s." ) |
|
170 | + $array += array( |
|
171 | + 'author' => ucfirst(get_current_user()), |
|
172 | + 'last_modify' => date("d-m-Y H:i:s.") |
|
173 | 173 | ); |
174 | 174 | |
175 | - $this->setFrameworkFiles ( $array ); |
|
176 | - $this->parseFrameworkConfig (); |
|
177 | - $this->setParams ( $this->getParams () ); |
|
178 | - $this->setParams ( $array ); |
|
179 | - $this->init (); |
|
180 | - if ( ! $this->isValid () ) |
|
175 | + $this->setFrameworkFiles($array); |
|
176 | + $this->parseFrameworkConfig(); |
|
177 | + $this->setParams($this->getParams()); |
|
178 | + $this->setParams($array); |
|
179 | + $this->init(); |
|
180 | + if ( ! $this->isValid()) |
|
181 | 181 | { |
182 | - $var = array_diff_key ( $this->attRequered , array_filter ( $this->arrConfig ) ); |
|
183 | - throw new Exception( $var ); |
|
182 | + $var = array_diff_key($this->attRequered, array_filter($this->arrConfig)); |
|
183 | + throw new Exception($var); |
|
184 | 184 | } |
185 | 185 | } |
186 | 186 | |
@@ -189,47 +189,47 @@ discard block |
||
189 | 189 | * |
190 | 190 | * @param $array |
191 | 191 | */ |
192 | - public function setFrameworkFiles ( $array ) |
|
192 | + public function setFrameworkFiles($array) |
|
193 | 193 | { |
194 | - $this->framworkFiles[ 'library' ] = isset( $array[ 'framework-path-library' ] ) |
|
195 | - ? $array[ 'framework-path-library' ] |
|
194 | + $this->framworkFiles['library'] = isset($array['framework-path-library']) |
|
195 | + ? $array['framework-path-library'] |
|
196 | 196 | : null; |
197 | 197 | |
198 | - $this->framworkFiles[ 'ini' ] = isset( $array[ 'framework-ini' ] ) |
|
199 | - ? $array[ 'framework-ini' ] |
|
198 | + $this->framworkFiles['ini'] = isset($array['framework-ini']) |
|
199 | + ? $array['framework-ini'] |
|
200 | 200 | : null; |
201 | 201 | |
202 | - $this->framworkFiles[ 'environment' ] = isset( $array[ 'environment' ] ) |
|
203 | - ? $array[ 'environment' ] |
|
202 | + $this->framworkFiles['environment'] = isset($array['environment']) |
|
203 | + ? $array['environment'] |
|
204 | 204 | : 'production'; |
205 | 205 | |
206 | 206 | } |
207 | 207 | |
208 | - protected function isValidFrameworkFiles () |
|
208 | + protected function isValidFrameworkFiles() |
|
209 | 209 | { |
210 | - if ( ! is_file ( $this->framworkFiles[ 'ini' ] ) ) |
|
210 | + if ( ! is_file($this->framworkFiles['ini'])) |
|
211 | 211 | { |
212 | 212 | return false; |
213 | 213 | } |
214 | 214 | |
215 | - if ( ! is_dir ( $this->framworkFiles[ 'library' ] ) ) |
|
215 | + if ( ! is_dir($this->framworkFiles['library'])) |
|
216 | 216 | { |
217 | 217 | return false; |
218 | 218 | } |
219 | 219 | |
220 | 220 | |
221 | - if ( ! isset ( $this->framworkFiles[ 'environment' ] ) |
|
222 | - or empty( $this->framworkFiles[ 'environment' ] ) |
|
221 | + if ( ! isset ($this->framworkFiles['environment']) |
|
222 | + or empty($this->framworkFiles['environment']) |
|
223 | 223 | ) |
224 | 224 | { |
225 | 225 | return false; |
226 | 226 | } |
227 | - set_include_path ( |
|
228 | - implode ( |
|
229 | - PATH_SEPARATOR , |
|
230 | - array ( |
|
231 | - realpath ( $this->framworkFiles[ 'library' ] ) , |
|
232 | - get_include_path () , |
|
227 | + set_include_path( |
|
228 | + implode( |
|
229 | + PATH_SEPARATOR, |
|
230 | + array( |
|
231 | + realpath($this->framworkFiles['library']), |
|
232 | + get_include_path(), |
|
233 | 233 | ) |
234 | 234 | ) |
235 | 235 | ); |
@@ -237,120 +237,120 @@ discard block |
||
237 | 237 | return true; |
238 | 238 | } |
239 | 239 | |
240 | - protected function getFrameworkIni () |
|
240 | + protected function getFrameworkIni() |
|
241 | 241 | { |
242 | - return $this->framworkFiles[ 'ini' ]; |
|
242 | + return $this->framworkFiles['ini']; |
|
243 | 243 | } |
244 | 244 | |
245 | - protected function getEnvironment () |
|
245 | + protected function getEnvironment() |
|
246 | 246 | { |
247 | - return $this->framworkFiles[ 'environment' ]; |
|
247 | + return $this->framworkFiles['environment']; |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | /** |
251 | 251 | * Popula as variaveis de acordo com o arquivo de configuração do seu framework |
252 | 252 | */ |
253 | - protected function isValid () |
|
253 | + protected function isValid() |
|
254 | 254 | { |
255 | - return $this->checkConfig (); |
|
255 | + return $this->checkConfig(); |
|
256 | 256 | } |
257 | 257 | |
258 | - private function setParams ( $array ) |
|
258 | + private function setParams($array) |
|
259 | 259 | { |
260 | - if ( count ( $array ) > 0 ) |
|
260 | + if (count($array) > 0) |
|
261 | 261 | { |
262 | - $this->arrConfig = array_filter ( $array ) + $this->arrConfig; |
|
262 | + $this->arrConfig = array_filter($array) + $this->arrConfig; |
|
263 | 263 | } |
264 | 264 | } |
265 | 265 | |
266 | 266 | /** |
267 | 267 | * @return string |
268 | 268 | */ |
269 | - public function getDatabase () |
|
269 | + public function getDatabase() |
|
270 | 270 | { |
271 | - return $this->arrConfig[ 'database' ]; |
|
271 | + return $this->arrConfig['database']; |
|
272 | 272 | } |
273 | 273 | |
274 | 274 | /** |
275 | 275 | * @return bool |
276 | 276 | */ |
277 | - public function hasSchemas () |
|
277 | + public function hasSchemas() |
|
278 | 278 | { |
279 | - return ! empty ( $this->arrConfig[ 'schema' ] ); |
|
279 | + return ! empty ($this->arrConfig['schema']); |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | /** |
283 | 283 | * @return string[] |
284 | 284 | */ |
285 | - public function getSchemas () |
|
285 | + public function getSchemas() |
|
286 | 286 | { |
287 | - if ( is_string ( $this->arrConfig[ 'schema' ] ) ) |
|
287 | + if (is_string($this->arrConfig['schema'])) |
|
288 | 288 | { |
289 | - return array ( $this->arrConfig[ 'schema' ] ); |
|
289 | + return array($this->arrConfig['schema']); |
|
290 | 290 | } |
291 | 291 | |
292 | - return $this->arrConfig[ 'schema' ]; |
|
292 | + return $this->arrConfig['schema']; |
|
293 | 293 | } |
294 | 294 | |
295 | - public function setSchema ( $schema ) |
|
295 | + public function setSchema($schema) |
|
296 | 296 | { |
297 | - $this->arrConfig[ 'schema' ] = $schema; |
|
297 | + $this->arrConfig['schema'] = $schema; |
|
298 | 298 | } |
299 | 299 | |
300 | 300 | /** |
301 | 301 | * @return string |
302 | 302 | */ |
303 | - public function getHost () |
|
303 | + public function getHost() |
|
304 | 304 | { |
305 | - return $this->arrConfig[ 'host' ]; |
|
305 | + return $this->arrConfig['host']; |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | /** |
309 | 309 | * @return int |
310 | 310 | */ |
311 | - public function getPort () |
|
311 | + public function getPort() |
|
312 | 312 | { |
313 | - return $this->arrConfig[ 'port' ]; |
|
313 | + return $this->arrConfig['port']; |
|
314 | 314 | } |
315 | 315 | |
316 | 316 | /** |
317 | 317 | * @return boolean |
318 | 318 | */ |
319 | - public function hasPort () |
|
319 | + public function hasPort() |
|
320 | 320 | { |
321 | - return ! empty( $this->arrConfig[ 'port' ] ); |
|
321 | + return ! empty($this->arrConfig['port']); |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | /** |
325 | 325 | * @return string |
326 | 326 | */ |
327 | - public function getSocket () |
|
327 | + public function getSocket() |
|
328 | 328 | { |
329 | - return $this->arrConfig[ 'socket' ]; |
|
329 | + return $this->arrConfig['socket']; |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | /** |
333 | 333 | * @return string |
334 | 334 | */ |
335 | - public function getUser () |
|
335 | + public function getUser() |
|
336 | 336 | { |
337 | - return $this->arrConfig[ 'username' ]; |
|
337 | + return $this->arrConfig['username']; |
|
338 | 338 | } |
339 | 339 | |
340 | 340 | /** |
341 | 341 | * @return string |
342 | 342 | */ |
343 | - public function getPassword () |
|
343 | + public function getPassword() |
|
344 | 344 | { |
345 | - return $this->arrConfig[ 'password' ]; |
|
345 | + return $this->arrConfig['password']; |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | /** |
349 | 349 | * @return bool |
350 | 350 | */ |
351 | - public function isStatusEnabled () |
|
351 | + public function isStatusEnabled() |
|
352 | 352 | { |
353 | - return (bool) $this->arrConfig[ 'status' ]; |
|
353 | + return (bool) $this->arrConfig['status']; |
|
354 | 354 | } |
355 | 355 | |
356 | 356 | /** |
@@ -358,24 +358,24 @@ discard block |
||
358 | 358 | * |
359 | 359 | * @return string |
360 | 360 | */ |
361 | - public function __get ( $str ) |
|
361 | + public function __get($str) |
|
362 | 362 | { |
363 | - $arr = array ( |
|
364 | - 'namespace' , |
|
365 | - 'framework' , |
|
366 | - 'author' , |
|
367 | - 'license' , |
|
368 | - 'copyright' , |
|
369 | - 'link' , |
|
370 | - 'last_modify' , |
|
371 | - 'path' , |
|
363 | + $arr = array( |
|
364 | + 'namespace', |
|
365 | + 'framework', |
|
366 | + 'author', |
|
367 | + 'license', |
|
368 | + 'copyright', |
|
369 | + 'link', |
|
370 | + 'last_modify', |
|
371 | + 'path', |
|
372 | 372 | 'folder-database', |
373 | 373 | 'folder-name' |
374 | 374 | ); |
375 | 375 | |
376 | - if ( in_array ( $str , $arr ) ) |
|
376 | + if (in_array($str, $arr)) |
|
377 | 377 | { |
378 | - return $this->arrConfig[ strtolower ( $str ) ]; |
|
378 | + return $this->arrConfig[strtolower($str)]; |
|
379 | 379 | } |
380 | 380 | |
381 | 381 | return; |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | protected $fileTpl = "entity.php"; |
23 | 23 | protected $overwrite = true; |
24 | 24 | |
25 | - protected $validFunc = array (); |
|
25 | + protected $validFunc = array(); |
|
26 | 26 | |
27 | 27 | /** |
28 | 28 | * @param \Classes\MakerFile $makerFile |
@@ -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 | - 'parents' => $this->listParents ( $makerFile , $dbTable ) , |
|
37 | - 'depends' => $this->listDependence ( $makerFile , $dbTable ) |
|
35 | + return array( |
|
36 | + 'parents' => $this->listParents($makerFile, $dbTable), |
|
37 | + 'depends' => $this->listDependence($makerFile, $dbTable) |
|
38 | 38 | ); |
39 | 39 | } |
40 | 40 | |
@@ -44,35 +44,35 @@ 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 | - $parents = array (); |
|
50 | - foreach ( $dbTable->getForeingkeys () as $objColumn ) |
|
49 | + $parents = array(); |
|
50 | + foreach ($dbTable->getForeingkeys() as $objColumn) |
|
51 | 51 | { |
52 | - $constrant = $objColumn->getFks (); |
|
52 | + $constrant = $objColumn->getFks(); |
|
53 | 53 | $name = |
54 | 54 | 'Parent' |
55 | 55 | . ZendFrameworkOne::SEPARETOR |
56 | - . AbstractMaker::getClassName ( $constrant->getTable () ) |
|
56 | + . AbstractMaker::getClassName($constrant->getTable()) |
|
57 | 57 | . ZendFrameworkOne::SEPARETOR |
58 | 58 | . 'By' |
59 | 59 | . ZendFrameworkOne::SEPARETOR |
60 | - . $objColumn->getName (); |
|
60 | + . $objColumn->getName(); |
|
61 | 61 | |
62 | - $arrClass = array ( |
|
63 | - $makerFile->getConfig ()->createClassNamespace ( $constrant ), |
|
64 | - AbstractMaker::getClassName ( $constrant->getTable () ) |
|
62 | + $arrClass = array( |
|
63 | + $makerFile->getConfig()->createClassNamespace($constrant), |
|
64 | + AbstractMaker::getClassName($constrant->getTable()) |
|
65 | 65 | ); |
66 | - $class = implode ( ZendFrameworkOne::SEPARETOR , array_filter ( $arrClass ) ); |
|
66 | + $class = implode(ZendFrameworkOne::SEPARETOR, array_filter($arrClass)); |
|
67 | 67 | |
68 | - $parents[] = array ( |
|
69 | - 'class' => $class , |
|
70 | - 'function' => AbstractMaker::getClassName ( $name ) , |
|
71 | - 'table' => $constrant->getTable () , |
|
72 | - 'column' => $objColumn->getName () , |
|
73 | - 'name' => $constrant->getNameConstrant () , |
|
68 | + $parents[] = array( |
|
69 | + 'class' => $class, |
|
70 | + 'function' => AbstractMaker::getClassName($name), |
|
71 | + 'table' => $constrant->getTable(), |
|
72 | + 'column' => $objColumn->getName(), |
|
73 | + 'name' => $constrant->getNameConstrant(), |
|
74 | 74 | ); |
75 | - unset( $name ); |
|
75 | + unset($name); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | return $parents; |
@@ -84,40 +84,40 @@ discard block |
||
84 | 84 | * |
85 | 85 | * @return array |
86 | 86 | */ |
87 | - private function listDependence ( \Classes\MakerFile $makerFile , \Classes\Db\DbTable $dbTable ) |
|
87 | + private function listDependence(\Classes\MakerFile $makerFile, \Classes\Db\DbTable $dbTable) |
|
88 | 88 | { |
89 | - $depends = array (); |
|
90 | - foreach ( $dbTable->getDependences () as $objColumn ) |
|
89 | + $depends = array(); |
|
90 | + foreach ($dbTable->getDependences() as $objColumn) |
|
91 | 91 | { |
92 | - foreach ( $objColumn->getDependences () as $dependence ) |
|
92 | + foreach ($objColumn->getDependences() as $dependence) |
|
93 | 93 | { |
94 | 94 | $name = |
95 | 95 | 'Depend' |
96 | 96 | . ZendFrameworkOne::SEPARETOR |
97 | - . AbstractMaker::getClassName ( $dependence->getTable () ) |
|
97 | + . AbstractMaker::getClassName($dependence->getTable()) |
|
98 | 98 | . ZendFrameworkOne::SEPARETOR |
99 | 99 | . 'By' |
100 | 100 | . ZendFrameworkOne::SEPARETOR |
101 | - . $objColumn->getName (); |
|
101 | + . $objColumn->getName(); |
|
102 | 102 | |
103 | - if ( ! key_exists ( $name , $this->validFunc ) ) |
|
103 | + if ( ! key_exists($name, $this->validFunc)) |
|
104 | 104 | { |
105 | - $arrClass = array ( |
|
106 | - $makerFile->getConfig ()->createClassNamespace ( $dependence ), |
|
107 | - AbstractMaker::getClassName ( $dependence->getTable () ) |
|
105 | + $arrClass = array( |
|
106 | + $makerFile->getConfig()->createClassNamespace($dependence), |
|
107 | + AbstractMaker::getClassName($dependence->getTable()) |
|
108 | 108 | ); |
109 | - $class = implode ( ZendFrameworkOne::SEPARETOR , array_filter ( $arrClass ) ); |
|
109 | + $class = implode(ZendFrameworkOne::SEPARETOR, array_filter($arrClass)); |
|
110 | 110 | |
111 | - $this->validFunc[ $name ] = true; |
|
112 | - $depends[] = array ( |
|
111 | + $this->validFunc[$name] = true; |
|
112 | + $depends[] = array( |
|
113 | 113 | 'class' => $class, |
114 | - 'function' => AbstractMaker::getClassName ( $name ) , |
|
115 | - 'table' => $dependence->getTable () , |
|
116 | - 'column' => $dependence->getColumn () , |
|
117 | - 'name' => $dependence->getNameConstrant () |
|
114 | + 'function' => AbstractMaker::getClassName($name), |
|
115 | + 'table' => $dependence->getTable(), |
|
116 | + 'column' => $dependence->getColumn(), |
|
117 | + 'name' => $dependence->getNameConstrant() |
|
118 | 118 | ); |
119 | 119 | } |
120 | - unset( $name ); |
|
120 | + unset($name); |
|
121 | 121 | } |
122 | 122 | } |
123 | 123 |