@@ -3,42 +3,42 @@ discard block |
||
3 | 3 | /** |
4 | 4 | * Mvc Model |
5 | 5 | * |
6 | - * <?=$this->config->last_modify."\n"?> |
|
6 | + * <?=$this->config->last_modify . "\n"?> |
|
7 | 7 | * |
8 | 8 | * @package <?=$objTables->getNamespace()?>\Entity |
9 | 9 | * @subpackage Model |
10 | - * @author <?=$this->config->author."\n"?> |
|
10 | + * @author <?=$this->config->author . "\n"?> |
|
11 | 11 | * |
12 | - * @copyright <?=$this->config->copyright."\n"?> |
|
13 | - * @license <?=$this->config->license."\n"?> |
|
14 | - * @link <?=$this->config->link."\n"?> |
|
12 | + * @copyright <?=$this->config->copyright . "\n"?> |
|
13 | + * @license <?=$this->config->license . "\n"?> |
|
14 | + * @link <?=$this->config->link . "\n"?> |
|
15 | 15 | */ |
16 | 16 | |
17 | 17 | namespace <?=$objTables->getNamespace()?>\Entity; |
18 | 18 | |
19 | 19 | use Phalcon\Validation; |
20 | 20 | |
21 | -abstract class <?=\Classes\Maker\AbstractMaker::getClassName ( $objTables->getName () )?> extends \Phalcon\Mvc\Model |
|
21 | +abstract class <?=\Classes\Maker\AbstractMaker::getClassName($objTables->getName())?> extends \Phalcon\Mvc\Model |
|
22 | 22 | { |
23 | 23 | |
24 | 24 | <?php foreach ($objTables->getColumns() as $column): ?> |
25 | 25 | /** |
26 | - * column <?=$column->getName()."\n"?> |
|
26 | + * column <?=$column->getName() . "\n"?> |
|
27 | 27 | * |
28 | -<?php if($column->isPrimaryKey()):?> |
|
28 | +<?php if ($column->isPrimaryKey()):?> |
|
29 | 29 | * @Primary |
30 | 30 | <?php endif ?> |
31 | -<?php if($column->hasSequence()):?> |
|
31 | +<?php if ($column->hasSequence()):?> |
|
32 | 32 | * @Identity |
33 | 33 | <?php endif ?> |
34 | - * @Column(type="<?=$column->getType()?>", nullable=<?=$column->isNullable () ? "true" : "false"?><?php |
|
35 | -if ( $column->getMaxLength () ): ?> |
|
36 | -, length=<?=$column->getMaxLength ()?> |
|
34 | + * @Column(type="<?=$column->getType()?>", nullable=<?=$column->isNullable() ? "true" : "false"?><?php |
|
35 | +if ($column->getMaxLength()): ?> |
|
36 | +, length=<?=$column->getMaxLength()?> |
|
37 | 37 | <?php endif ?>) |
38 | 38 | */ |
39 | 39 | protected $<?=$column->getName()?>; |
40 | 40 | |
41 | -<?php endforeach;?> |
|
41 | +<?php endforeach; ?> |
|
42 | 42 | /** |
43 | 43 | * Validations and business logic |
44 | 44 | * |
@@ -49,14 +49,14 @@ discard block |
||
49 | 49 | $validator = new Validation(); |
50 | 50 | |
51 | 51 | <?php foreach ($objTables->getColumns() as $column): ?> |
52 | -<?php if(strtolower($column->getName()) == 'email'):?> |
|
52 | +<?php if (strtolower($column->getName()) == 'email'):?> |
|
53 | 53 | $validator->add( |
54 | 54 | 'email', |
55 | 55 | new \Phalcon\Validation\Validator\Email() |
56 | 56 | ); |
57 | 57 | |
58 | 58 | <?php endif ?> |
59 | -<?php endforeach;?> |
|
59 | +<?php endforeach; ?> |
|
60 | 60 | return $this->validate($validator); |
61 | 61 | } |
62 | 62 | |
@@ -65,11 +65,11 @@ discard block |
||
65 | 65 | */ |
66 | 66 | public function initialize() |
67 | 67 | { |
68 | - <?=$mapDependents."\n"?> |
|
69 | - <?=$mapParents."\n"?> |
|
68 | + <?=$mapDependents . "\n"?> |
|
69 | + <?=$mapParents . "\n"?> |
|
70 | 70 | } |
71 | 71 | |
72 | -<?php if($objTables->hasSchema()): ?> |
|
72 | +<?php if ($objTables->hasSchema()): ?> |
|
73 | 73 | /** |
74 | 74 | * Returns schema name where table mapped is located |
75 | 75 | * |
@@ -91,11 +91,11 @@ discard block |
||
91 | 91 | return '<?=$objTables->getName()?>'; |
92 | 92 | } |
93 | 93 | |
94 | -<?php if( $objTables->hasSequences() ) : ?> |
|
94 | +<?php if ($objTables->hasSequences()) : ?> |
|
95 | 95 | public function getSequenceName() |
96 | 96 | { |
97 | -<?php if ( 1 == count($objTables->getSequences() ) ) : ?> |
|
98 | - <?php $seqs = $objTables->getSequences();reset($seqs);$seq = current($seqs);?> |
|
97 | +<?php if (1 == count($objTables->getSequences())) : ?> |
|
98 | + <?php $seqs = $objTables->getSequences(); reset($seqs); $seq = current($seqs); ?> |
|
99 | 99 | return "<?=$seq->getSequence() ?>"; |
100 | 100 | <?php endif ?> |
101 | 101 | } |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * Allows to query a set of records that match the specified conditions |
106 | 106 | * |
107 | 107 | * @param mixed $parameters |
108 | - * @return \<?=$objTables->getNamespace()?>\<?=\Classes\Maker\AbstractMaker::getClassName ( $objTables->getName () )?>[] |
|
108 | + * @return \<?=$objTables->getNamespace()?>\<?=\Classes\Maker\AbstractMaker::getClassName($objTables->getName())?>[] |
|
109 | 109 | */ |
110 | 110 | public static function find($parameters = null) |
111 | 111 | { |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | * Allows to query the first record that match the specified conditions |
117 | 117 | * |
118 | 118 | * @param mixed $parameters |
119 | - * @return \<?=$objTables->getNamespace()?>\<?=\Classes\Maker\AbstractMaker::getClassName ( $objTables->getName () )."\n"?> |
|
119 | + * @return \<?=$objTables->getNamespace()?>\<?=\Classes\Maker\AbstractMaker::getClassName($objTables->getName()) . "\n"?> |
|
120 | 120 | */ |
121 | 121 | public static function findFirst($parameters = null) |
122 | 122 | { |
@@ -125,17 +125,17 @@ discard block |
||
125 | 125 | |
126 | 126 | |
127 | 127 | <?php foreach ($objTables->getColumns() as $column): ?> |
128 | - public function set<?=$this->getClassName ( $column->getName () )?>( $<?=$column->getName()?> ) |
|
128 | + public function set<?=$this->getClassName($column->getName())?>( $<?=$column->getName()?> ) |
|
129 | 129 | { |
130 | 130 | $this-><?=$column->getName()?> = $<?=$column->getName()?>; |
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
134 | - * @return <?=$column->getType ()."\n" ?> |
|
134 | + * @return <?=$column->getType() . "\n" ?> |
|
135 | 135 | **/ |
136 | - public function get<?=$this->getClassName ( $column->getName () )?>() |
|
136 | + public function get<?=$this->getClassName($column->getName())?>() |
|
137 | 137 | { |
138 | - return (<?=$column->getType () ?>) $this-><?=$column->getName()?>; |
|
138 | + return (<?=$column->getType() ?>) $this-><?=$column->getName()?>; |
|
139 | 139 | } |
140 | -<?php endforeach;?> |
|
140 | +<?php endforeach; ?> |
|
141 | 141 | } |
142 | 142 | \ No newline at end of file |
@@ -135,7 +135,7 @@ |
||
135 | 135 | $configIni = isset( $argv[ 'config-ini' ] ) |
136 | 136 | ? $argv[ 'config-ini' ] |
137 | 137 | : $this->_basePath |
138 | - . $this->configIniDefault; |
|
138 | + . $this->configIniDefault; |
|
139 | 139 | |
140 | 140 | $configTemp = $this->loadIniFile ( realpath ( $configIni ) ); |
141 | 141 | $configCurrent = self::parseConfigEnv ( $configTemp, $argv ); |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | /** |
53 | 53 | * @var array |
54 | 54 | */ |
55 | - private $argv = array (); |
|
55 | + private $argv = array(); |
|
56 | 56 | |
57 | 57 | /** |
58 | 58 | * @var \Classes\AdapterConfig\AbstractAdapter |
@@ -64,22 +64,22 @@ discard block |
||
64 | 64 | */ |
65 | 65 | private $adapterDriver; |
66 | 66 | |
67 | - private $frameworkList = array ( |
|
67 | + private $frameworkList = array( |
|
68 | 68 | 'none', |
69 | 69 | 'zf1', |
70 | 70 | 'phalcon' |
71 | 71 | ); |
72 | 72 | |
73 | - public function __construct ( $argv, $basePath ) |
|
73 | + public function __construct($argv, $basePath) |
|
74 | 74 | { |
75 | - if ( array_key_exists ( 'help', $argv ) ) { |
|
76 | - die ( $this->getUsage () ); |
|
75 | + if (array_key_exists('help', $argv)) { |
|
76 | + die ($this->getUsage()); |
|
77 | 77 | } |
78 | - if ( array_key_exists ( 'status', $argv ) ) { |
|
79 | - $argv[ 'status' ] = true; |
|
78 | + if (array_key_exists('status', $argv)) { |
|
79 | + $argv['status'] = true; |
|
80 | 80 | } |
81 | 81 | |
82 | - $this->argv = $this->parseConfig ( $basePath, $argv ); |
|
82 | + $this->argv = $this->parseConfig($basePath, $argv); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | * |
88 | 88 | * @return string |
89 | 89 | */ |
90 | - public function getUsage () |
|
90 | + public function getUsage() |
|
91 | 91 | { |
92 | - $version = $this->getVersion (); |
|
92 | + $version = $this->getVersion(); |
|
93 | 93 | |
94 | 94 | return <<<EOF |
95 | 95 | parameters: |
@@ -112,7 +112,7 @@ discard block |
||
112 | 112 | EOF; |
113 | 113 | } |
114 | 114 | |
115 | - public function getVersion () |
|
115 | + public function getVersion() |
|
116 | 116 | { |
117 | 117 | $version = static::$version; |
118 | 118 | |
@@ -128,28 +128,28 @@ discard block |
||
128 | 128 | * @return array |
129 | 129 | * @throws \Exception |
130 | 130 | */ |
131 | - private function parseConfig ( $basePath, $argv ) |
|
131 | + private function parseConfig($basePath, $argv) |
|
132 | 132 | { |
133 | - $this->_basePath = dirname ( $basePath ); |
|
133 | + $this->_basePath = dirname($basePath); |
|
134 | 134 | |
135 | - $configIni = isset( $argv[ 'config-ini' ] ) |
|
136 | - ? $argv[ 'config-ini' ] |
|
135 | + $configIni = isset($argv['config-ini']) |
|
136 | + ? $argv['config-ini'] |
|
137 | 137 | : $this->_basePath |
138 | 138 | . $this->configIniDefault; |
139 | 139 | |
140 | - $configTemp = $this->loadIniFile ( realpath ( $configIni ) ); |
|
141 | - $configCurrent = self::parseConfigEnv ( $configTemp, $argv ); |
|
140 | + $configTemp = $this->loadIniFile(realpath($configIni)); |
|
141 | + $configCurrent = self::parseConfigEnv($configTemp, $argv); |
|
142 | 142 | |
143 | - if ( !isset( $configCurrent[ 'framework' ] ) ) { |
|
144 | - throw new \Exception( "configure which framework you want to use! \n" ); |
|
143 | + if ( ! isset($configCurrent['framework'])) { |
|
144 | + throw new \Exception("configure which framework you want to use! \n"); |
|
145 | 145 | } |
146 | 146 | |
147 | - if ( !in_array ( $configCurrent[ 'framework' ], $this->frameworkList ) ) { |
|
148 | - $frameworks = implode ( "\n\t", $this->frameworkList ); |
|
149 | - throw new \Exception( "list of frameworks: \n\t\033[1;33m" . $frameworks . "\n\033[0m" ); |
|
147 | + if ( ! in_array($configCurrent['framework'], $this->frameworkList)) { |
|
148 | + $frameworks = implode("\n\t", $this->frameworkList); |
|
149 | + throw new \Exception("list of frameworks: \n\t\033[1;33m" . $frameworks . "\n\033[0m"); |
|
150 | 150 | } |
151 | 151 | |
152 | - return $argv + array_filter ( $configCurrent ); |
|
152 | + return $argv + array_filter($configCurrent); |
|
153 | 153 | } |
154 | 154 | |
155 | 155 | /** |
@@ -159,20 +159,20 @@ discard block |
||
159 | 159 | * |
160 | 160 | * @return string |
161 | 161 | */ |
162 | - private static function parseConfigEnv ( $configTemp, $argv ) |
|
162 | + private static function parseConfigEnv($configTemp, $argv) |
|
163 | 163 | { |
164 | - $thisSection = isset( $configTemp[ key ( $configTemp ) ][ 'config-env' ] ) ? $configTemp[ key ( |
|
164 | + $thisSection = isset($configTemp[key($configTemp)]['config-env']) ? $configTemp[key( |
|
165 | 165 | $configTemp |
166 | - ) ][ 'config-env' ] : null; |
|
166 | + )]['config-env'] : null; |
|
167 | 167 | |
168 | - $thisSection = isset( $argv[ 'config-env' ] ) ? $argv[ 'config-env' ] : $thisSection; |
|
168 | + $thisSection = isset($argv['config-env']) ? $argv['config-env'] : $thisSection; |
|
169 | 169 | |
170 | - if ( isset( $configTemp[ $thisSection ][ 'extends' ] ) ) { |
|
170 | + if (isset($configTemp[$thisSection]['extends'])) { |
|
171 | 171 | #faz marge da config principal com a config extendida |
172 | - return $configTemp[ $thisSection ] + $configTemp[ $configTemp[ $thisSection ][ 'extends' ] ]; |
|
172 | + return $configTemp[$thisSection] + $configTemp[$configTemp[$thisSection]['extends']]; |
|
173 | 173 | } |
174 | 174 | |
175 | - return $configTemp[ key ( $configTemp ) ]; |
|
175 | + return $configTemp[key($configTemp)]; |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | /** |
@@ -186,29 +186,29 @@ discard block |
||
186 | 186 | * @throws \Exception |
187 | 187 | * @return array |
188 | 188 | */ |
189 | - protected function loadIniFile ( $filename ) |
|
189 | + protected function loadIniFile($filename) |
|
190 | 190 | { |
191 | - if ( !is_file ( $filename ) ) { |
|
192 | - throw new \Exception( "configuration file does not exist! \n" ); |
|
191 | + if ( ! is_file($filename)) { |
|
192 | + throw new \Exception("configuration file does not exist! \n"); |
|
193 | 193 | } |
194 | 194 | |
195 | - $loaded = parse_ini_file ( $filename, true ); |
|
196 | - $iniArray = array (); |
|
197 | - foreach ( $loaded as $key => $data ) { |
|
198 | - $pieces = explode ( $this->sectionSeparator, $key ); |
|
199 | - $thisSection = trim ( $pieces[ 0 ] ); |
|
200 | - switch ( count ( $pieces ) ) { |
|
195 | + $loaded = parse_ini_file($filename, true); |
|
196 | + $iniArray = array(); |
|
197 | + foreach ($loaded as $key => $data) { |
|
198 | + $pieces = explode($this->sectionSeparator, $key); |
|
199 | + $thisSection = trim($pieces[0]); |
|
200 | + switch (count($pieces)) { |
|
201 | 201 | case 1: |
202 | - $iniArray[ $thisSection ] = $data; |
|
202 | + $iniArray[$thisSection] = $data; |
|
203 | 203 | break; |
204 | 204 | |
205 | 205 | case 2: |
206 | - $extendedSection = trim ( $pieces[ 1 ] ); |
|
207 | - $iniArray[ $thisSection ] = array_merge ( array ( 'extends' => $extendedSection ), $data ); |
|
206 | + $extendedSection = trim($pieces[1]); |
|
207 | + $iniArray[$thisSection] = array_merge(array('extends' => $extendedSection), $data); |
|
208 | 208 | break; |
209 | 209 | |
210 | 210 | default: |
211 | - throw new \Exception( "Section '$thisSection' may not extend multiple sections in $filename" ); |
|
211 | + throw new \Exception("Section '$thisSection' may not extend multiple sections in $filename"); |
|
212 | 212 | } |
213 | 213 | } |
214 | 214 | |
@@ -221,15 +221,15 @@ discard block |
||
221 | 221 | * @return \Classes\AdapterConfig\AbstractAdapter |
222 | 222 | * |
223 | 223 | */ |
224 | - private function factoryConfig () |
|
224 | + private function factoryConfig() |
|
225 | 225 | { |
226 | - switch ( strtolower ( $this->argv[ 'framework' ] ) ) { |
|
226 | + switch (strtolower($this->argv['framework'])) { |
|
227 | 227 | case 'zf1': |
228 | - return new ZendFrameworkOne( $this->argv ); |
|
228 | + return new ZendFrameworkOne($this->argv); |
|
229 | 229 | case 'phalcon': |
230 | - return new Phalcon( $this->argv ); |
|
230 | + return new Phalcon($this->argv); |
|
231 | 231 | default: |
232 | - return new None( $this->argv ); |
|
232 | + return new None($this->argv); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | } |
@@ -241,31 +241,31 @@ discard block |
||
241 | 241 | * |
242 | 242 | * @return AdaptersDriver\AbsractAdapter |
243 | 243 | */ |
244 | - private function factoryDriver ( AdapterConfig\AbstractAdapter $config ) |
|
244 | + private function factoryDriver(AdapterConfig\AbstractAdapter $config) |
|
245 | 245 | { |
246 | - switch ( $this->argv[ 'driver' ] ) { |
|
246 | + switch ($this->argv['driver']) { |
|
247 | 247 | case 'pgsql': |
248 | 248 | case 'pdo_pgsql': |
249 | - return new Pgsql( $config ); |
|
249 | + return new Pgsql($config); |
|
250 | 250 | case 'mysql': |
251 | 251 | case 'pdo_mysql': |
252 | - return new Mysql( $config ); |
|
252 | + return new Mysql($config); |
|
253 | 253 | case 'mssql': |
254 | - return new Mssql( $config ); |
|
254 | + return new Mssql($config); |
|
255 | 255 | case 'dblib': |
256 | - return new Dblib( $config ); |
|
256 | + return new Dblib($config); |
|
257 | 257 | case 'sqlsrv': |
258 | - return new Sqlsrv( $config ); |
|
258 | + return new Sqlsrv($config); |
|
259 | 259 | } |
260 | 260 | } |
261 | 261 | |
262 | 262 | /** |
263 | 263 | * @return AdapterConfig\AbstractAdapter |
264 | 264 | */ |
265 | - public function getAdapterConfig () |
|
265 | + public function getAdapterConfig() |
|
266 | 266 | { |
267 | - if ( !$this->adapterConfig instanceof AbstractAdapter ) { |
|
268 | - $this->adapterConfig = $this->factoryConfig (); |
|
267 | + if ( ! $this->adapterConfig instanceof AbstractAdapter) { |
|
268 | + $this->adapterConfig = $this->factoryConfig(); |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | return $this->adapterConfig; |
@@ -274,10 +274,10 @@ discard block |
||
274 | 274 | /** |
275 | 275 | * @return AdaptersDriver\AbsractAdapter |
276 | 276 | */ |
277 | - public function getAdapterDriver ( AdapterConfig\AbstractAdapter $config ) |
|
277 | + public function getAdapterDriver(AdapterConfig\AbstractAdapter $config) |
|
278 | 278 | { |
279 | - if ( !$this->adapterDriver ) { |
|
280 | - $this->adapterDriver = $this->factoryDriver ( $config ); |
|
279 | + if ( ! $this->adapterDriver) { |
|
280 | + $this->adapterDriver = $this->factoryDriver($config); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | return $this->adapterDriver; |
@@ -20,11 +20,11 @@ discard block |
||
20 | 20 | * @var string |
21 | 21 | */ |
22 | 22 | protected $framework = "phalcon"; |
23 | - public $reservedWord = array ( 'public' => 'Main' ); |
|
23 | + public $reservedWord = array('public' => 'Main'); |
|
24 | 24 | |
25 | 25 | const SEPARETOR = "\\"; |
26 | 26 | |
27 | - protected function init () |
|
27 | + protected function init() |
|
28 | 28 | { |
29 | 29 | } |
30 | 30 | |
@@ -33,12 +33,12 @@ discard block |
||
33 | 33 | * |
34 | 34 | * @return array |
35 | 35 | */ |
36 | - protected function getParams () |
|
36 | + protected function getParams() |
|
37 | 37 | { |
38 | 38 | |
39 | 39 | } |
40 | 40 | |
41 | - protected function parseFrameworkConfig () |
|
41 | + protected function parseFrameworkConfig() |
|
42 | 42 | { |
43 | 43 | // TODO: Implement parseFrameworkConfig() method. |
44 | 44 | } |
@@ -46,10 +46,10 @@ discard block |
||
46 | 46 | /** |
47 | 47 | * @inheritdoc |
48 | 48 | */ |
49 | - protected function getBaseNamespace () |
|
49 | + protected function getBaseNamespace() |
|
50 | 50 | { |
51 | - return array ( |
|
52 | - $this->arrConfig[ 'namespace' ], |
|
51 | + return array( |
|
52 | + $this->arrConfig['namespace'], |
|
53 | 53 | 'Models' |
54 | 54 | ); |
55 | 55 | } |
@@ -59,11 +59,11 @@ discard block |
||
59 | 59 | * |
60 | 60 | * @return \Classes\AdapterMakerFile\AbstractAdapter[] |
61 | 61 | */ |
62 | - public function getMakeFileInstances () |
|
62 | + public function getMakeFileInstances() |
|
63 | 63 | { |
64 | - return array ( |
|
65 | - Entity::getInstance (), |
|
66 | - Model::getInstance () |
|
64 | + return array( |
|
65 | + Entity::getInstance(), |
|
66 | + Model::getInstance() |
|
67 | 67 | ); |
68 | 68 | } |
69 | 69 |