@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | public function get() |
| 16 | 16 | { |
| 17 | - if(!isset($this->config['paths'][0])){ |
|
| 17 | + if (!isset($this->config['paths'][0])) { |
|
| 18 | 18 | exit(); |
| 19 | 19 | } |
| 20 | 20 | |
@@ -27,11 +27,11 @@ discard block |
||
| 27 | 27 | |
| 28 | 28 | $list = []; |
| 29 | 29 | |
| 30 | - foreach ($migrations as $table=>$item){ |
|
| 30 | + foreach ($migrations as $table=>$item) { |
|
| 31 | 31 | $list[] = strtolower($table); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | - if(isset($arguments['only'])){ |
|
| 34 | + if (isset($arguments['only'])) { |
|
| 35 | 35 | $dbtables = $this->getOnly($dbtables); |
| 36 | 36 | } |
| 37 | 37 | |
@@ -40,7 +40,7 @@ discard block |
||
| 40 | 40 | echo 'Toplam : '.count($dbtables).' Table'; |
| 41 | 41 | echo PHP_EOL; |
| 42 | 42 | |
| 43 | - foreach ($dbtables as $dbtablekey=>$dbtable){ |
|
| 43 | + foreach ($dbtables as $dbtablekey=>$dbtable) { |
|
| 44 | 44 | |
| 45 | 45 | $dbtablekey = $dbtablekey+1; |
| 46 | 46 | |
@@ -49,42 +49,42 @@ discard block |
||
| 49 | 49 | $dbtable = ucfirst($dbtable); |
| 50 | 50 | $makeDirectory = $directory.''.DIRECTORY_SEPARATOR.''.$dbtable; |
| 51 | 51 | |
| 52 | - if(!file_exists($makeDirectory)){ |
|
| 53 | - files()->makeDirectory($makeDirectory,0755,true); |
|
| 54 | - $exist=false; |
|
| 52 | + if (!file_exists($makeDirectory)) { |
|
| 53 | + files()->makeDirectory($makeDirectory, 0755, true); |
|
| 54 | + $exist = false; |
|
| 55 | 55 | } |
| 56 | - else{ |
|
| 57 | - $exist=true; |
|
| 56 | + else { |
|
| 57 | + $exist = true; |
|
| 58 | 58 | } |
| 59 | 59 | |
| 60 | 60 | $migrationName = time().'_'.$dbtable.''; |
| 61 | 61 | |
| 62 | - if($exist===false){ |
|
| 62 | + if ($exist===false) { |
|
| 63 | 63 | |
| 64 | - $content = $this->getContentFile($this->getStubPath().''.DIRECTORY_SEPARATOR.'pullCreate.stub',[ |
|
| 64 | + $content = $this->getContentFile($this->getStubPath().''.DIRECTORY_SEPARATOR.'pullCreate.stub', [ |
|
| 65 | 65 | 'className' => $dbtable, |
| 66 | 66 | 'informations' => $informations |
| 67 | 67 | ]); |
| 68 | 68 | |
| 69 | - $contentResult = files()->put($makeDirectory.''.DIRECTORY_SEPARATOR.''.$migrationName.'.php',$content); |
|
| 69 | + $contentResult = files()->put($makeDirectory.''.DIRECTORY_SEPARATOR.''.$migrationName.'.php', $content); |
|
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - if(substr($dbtable,-1)=='s'){ |
|
| 73 | - app()->command('model create','model:'.strtolower(substr($dbtable,0,-1)).' table:'.$dbtable); |
|
| 72 | + if (substr($dbtable, -1)=='s') { |
|
| 73 | + app()->command('model create', 'model:'.strtolower(substr($dbtable, 0, -1)).' table:'.$dbtable); |
|
| 74 | 74 | } |
| 75 | - else{ |
|
| 76 | - app()->command('model create','model:'.strtolower($dbtable).' table:'.$dbtable); |
|
| 75 | + else { |
|
| 76 | + app()->command('model create', 'model:'.strtolower($dbtable).' table:'.$dbtable); |
|
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - if(isset($contentResult) && $contentResult!==false){ |
|
| 79 | + if (isset($contentResult) && $contentResult!==false) { |
|
| 80 | 80 | |
| 81 | 81 | $this->schema->getConnection()->generateEntity($dbtable); |
| 82 | 82 | echo $dbtablekey.'- '.$migrationName.' ---> Ok'; |
| 83 | 83 | } |
| 84 | - elseif($exist){ |
|
| 84 | + elseif ($exist) { |
|
| 85 | 85 | echo $dbtablekey.'- '.$migrationName.' ---> (Already Exist)'; |
| 86 | 86 | } |
| 87 | - else{ |
|
| 87 | + else { |
|
| 88 | 88 | echo $dbtablekey.'- '.$migrationName.' ---> Fail'; |
| 89 | 89 | } |
| 90 | 90 | |
@@ -112,46 +112,46 @@ discard block |
||
| 112 | 112 | |
| 113 | 113 | $list = []; |
| 114 | 114 | |
| 115 | - foreach ($columns as $key=>$data){ |
|
| 115 | + foreach ($columns as $key=>$data) { |
|
| 116 | 116 | |
| 117 | - $data['Type'] = rtrim(str_replace('unsigned','',$data['Type'])); |
|
| 117 | + $data['Type'] = rtrim(str_replace('unsigned', '', $data['Type'])); |
|
| 118 | 118 | |
| 119 | 119 | $field = $data['Field']; |
| 120 | 120 | $list[] = '$wizard->name(\''.$field.'\')'; |
| 121 | 121 | $list[] = '->'.$this->getColumnTransformers($data['Type']).''; |
| 122 | 122 | |
| 123 | 123 | //default block |
| 124 | - if(!is_null($data['Default'])){ |
|
| 124 | + if (!is_null($data['Default'])) { |
|
| 125 | 125 | $default = $data['Default']; |
| 126 | - $list[] = '->default(\''.$default.'\')'; |
|
| 126 | + $list[] = '->default(\''.$default.'\')'; |
|
| 127 | 127 | } |
| 128 | 128 | |
| 129 | - $getIndex = $this->getIndexInformation($indexes,$data['Field']); |
|
| 129 | + $getIndex = $this->getIndexInformation($indexes, $data['Field']); |
|
| 130 | 130 | |
| 131 | 131 | //unique block |
| 132 | - if($getIndex['Non_unique']=='0' && $getIndex['Key_name']!=='PRIMARY'){ |
|
| 132 | + if ($getIndex['Non_unique']=='0' && $getIndex['Key_name']!=='PRIMARY') { |
|
| 133 | 133 | $indexName = $getIndex['Key_name']; |
| 134 | - $list[] = '->unique(\''.$indexName.'\')'; |
|
| 134 | + $list[] = '->unique(\''.$indexName.'\')'; |
|
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | //index block |
| 138 | - if($getIndex['Non_unique']=='1' && $getIndex['Key_name']!=='PRIMARY'){ |
|
| 138 | + if ($getIndex['Non_unique']=='1' && $getIndex['Key_name']!=='PRIMARY') { |
|
| 139 | 139 | $columnName = $getIndex['Column_name']; |
| 140 | 140 | $indexName = $getIndex['Key_name']; |
| 141 | 141 | |
| 142 | - if(count($multipleIndexes[$indexName])==1){ |
|
| 142 | + if (count($multipleIndexes[$indexName])==1) { |
|
| 143 | 143 | $list[] = '->index(\''.$indexName.'\')'; |
| 144 | 144 | } |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | 147 | //comment block |
| 148 | - if(strlen($data['Comment'])>0){ |
|
| 148 | + if (strlen($data['Comment'])>0) { |
|
| 149 | 149 | $comment = $data['Comment']; |
| 150 | 150 | $list[] = '->comment(\''.$comment.'\')'; |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | 153 | //auto increment block |
| 154 | - if($data['Extra']=='auto_increment'){ |
|
| 154 | + if ($data['Extra']=='auto_increment') { |
|
| 155 | 155 | $list[] = '->auto_increment()'; |
| 156 | 156 | } |
| 157 | 157 | |
@@ -166,39 +166,39 @@ discard block |
||
| 166 | 166 | |
| 167 | 167 | //table indexes |
| 168 | 168 | foreach ($multipleIndexes as $indexName=>$values) { |
| 169 | - if(count($values)>1){ |
|
| 170 | - $values = '\''.implode('\',\'',$values).'\''; |
|
| 169 | + if (count($values)>1) { |
|
| 170 | + $values = '\''.implode('\',\'', $values).'\''; |
|
| 171 | 171 | $list[] = ' $wizard->table()->indexes(\''.$indexName.'\',['.$values.']); |
| 172 | 172 | '; |
| 173 | 173 | } |
| 174 | 174 | } |
| 175 | 175 | |
| 176 | - if(count($foreignKeys)){ |
|
| 176 | + if (count($foreignKeys)) { |
|
| 177 | 177 | |
| 178 | 178 | $constraintName = $foreignKeys['CONSTRAINT_NAME']; |
| 179 | 179 | $key = $foreignKeys['COLUMN_NAME']; |
| 180 | 180 | $referenceTable = $foreignKeys['REFERENCED_TABLE_NAME']; |
| 181 | 181 | $referenceColumn = $foreignKeys['REFERENCED_COLUMN_NAME']; |
| 182 | 182 | |
| 183 | - if($foreignKeys['UPDATE_RULE']=='RESTRICT' && $foreignKeys['DELETE_RULE']=='RESTRICT'){ |
|
| 183 | + if ($foreignKeys['UPDATE_RULE']=='RESTRICT' && $foreignKeys['DELETE_RULE']=='RESTRICT') { |
|
| 184 | 184 | $list[] = ' $wizard->table()->foreign()->constraint(\''.$constraintName.'\')->key(\''.$key.'\')->references(\''.$referenceTable.'\',\''.$referenceColumn.'\'); |
| 185 | 185 | '; |
| 186 | 186 | } |
| 187 | 187 | |
| 188 | - if($foreignKeys['UPDATE_RULE']!=='RESTRICT' && $foreignKeys['DELETE_RULE']=='RESTRICT'){ |
|
| 188 | + if ($foreignKeys['UPDATE_RULE']!=='RESTRICT' && $foreignKeys['DELETE_RULE']=='RESTRICT') { |
|
| 189 | 189 | $rule = $foreignKeys['UPDATE_RULE']; |
| 190 | 190 | $list[] = ' $wizard->table()->foreign()->constraint(\''.$constraintName.'\')->key(\''.$key.'\')->references(\''.$referenceTable.'\',\''.$referenceColumn.'\')->onUpdate()->'.strtolower($rule).'(); |
| 191 | 191 | '; |
| 192 | 192 | } |
| 193 | 193 | |
| 194 | - if($foreignKeys['UPDATE_RULE']=='RESTRICT' && $foreignKeys['DELETE_RULE']!=='RESTRICT'){ |
|
| 194 | + if ($foreignKeys['UPDATE_RULE']=='RESTRICT' && $foreignKeys['DELETE_RULE']!=='RESTRICT') { |
|
| 195 | 195 | $rule = $foreignKeys['DELETE_RULE']; |
| 196 | 196 | $list[] = ' $wizard->table()->foreign()->constraint(\''.$constraintName.'\')->key(\''.$key.'\')->references(\''.$referenceTable.'\',\''.$referenceColumn.'\')->onDelete()->'.strtolower($rule).'(); |
| 197 | 197 | '; |
| 198 | 198 | } |
| 199 | 199 | } |
| 200 | 200 | |
| 201 | - return implode('',$list); |
|
| 201 | + return implode('', $list); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | /** |
@@ -209,43 +209,43 @@ discard block |
||
| 209 | 209 | */ |
| 210 | 210 | private function getColumnTransformers($column) |
| 211 | 211 | { |
| 212 | - if($column=='datetime'){ |
|
| 212 | + if ($column=='datetime') { |
|
| 213 | 213 | return 'datetime()'; |
| 214 | 214 | } |
| 215 | - elseif($column=='longtext'){ |
|
| 215 | + elseif ($column=='longtext') { |
|
| 216 | 216 | return 'longtext()'; |
| 217 | 217 | } |
| 218 | - elseif($column=='date'){ |
|
| 218 | + elseif ($column=='date') { |
|
| 219 | 219 | return 'date()'; |
| 220 | 220 | } |
| 221 | - elseif($column=='text'){ |
|
| 221 | + elseif ($column=='text') { |
|
| 222 | 222 | return 'text()'; |
| 223 | 223 | } |
| 224 | - elseif($column=='timestamp'){ |
|
| 224 | + elseif ($column=='timestamp') { |
|
| 225 | 225 | return 'timestamp()'; |
| 226 | 226 | } |
| 227 | - elseif($column=='mediumint'){ |
|
| 227 | + elseif ($column=='mediumint') { |
|
| 228 | 228 | return 'mediumint()'; |
| 229 | 229 | } |
| 230 | - elseif($column=='tinyint'){ |
|
| 230 | + elseif ($column=='tinyint') { |
|
| 231 | 231 | return 'tinyint()'; |
| 232 | 232 | } |
| 233 | - elseif($column=='float'){ |
|
| 233 | + elseif ($column=='float') { |
|
| 234 | 234 | return 'float()'; |
| 235 | 235 | } |
| 236 | - elseif($column=='mediumtext'){ |
|
| 236 | + elseif ($column=='mediumtext') { |
|
| 237 | 237 | return 'mediumtext()'; |
| 238 | 238 | } |
| 239 | - elseif($column=='mediumblob'){ |
|
| 239 | + elseif ($column=='mediumblob') { |
|
| 240 | 240 | return 'mediumblob()'; |
| 241 | 241 | } |
| 242 | - elseif($column=='blob'){ |
|
| 242 | + elseif ($column=='blob') { |
|
| 243 | 243 | return 'blob()'; |
| 244 | 244 | } |
| 245 | - elseif(preg_match('@enum.*\((.*?)\)@',$column,$enum)){ |
|
| 245 | + elseif (preg_match('@enum.*\((.*?)\)@', $column, $enum)) { |
|
| 246 | 246 | return 'enum(['.$enum[1].'])'; |
| 247 | 247 | } |
| 248 | - else{ |
|
| 248 | + else { |
|
| 249 | 249 | return $column; |
| 250 | 250 | } |
| 251 | 251 | } |
@@ -257,11 +257,11 @@ discard block |
||
| 257 | 257 | * @param $field |
| 258 | 258 | * @return void|mixed |
| 259 | 259 | */ |
| 260 | - private function getIndexInformation($index,$field) |
|
| 260 | + private function getIndexInformation($index, $field) |
|
| 261 | 261 | { |
| 262 | 262 | foreach ($index as $key=>$item) { |
| 263 | 263 | |
| 264 | - if($item['Column_name'] == $field){ |
|
| 264 | + if ($item['Column_name']==$field) { |
|
| 265 | 265 | return $index[$key]; |
| 266 | 266 | } |
| 267 | 267 | } |
@@ -279,13 +279,13 @@ discard block |
||
| 279 | 279 | { |
| 280 | 280 | $arguments = $this->schema->getArguments(); |
| 281 | 281 | |
| 282 | - $only = explode(',',$arguments['only']); |
|
| 282 | + $only = explode(',', $arguments['only']); |
|
| 283 | 283 | |
| 284 | 284 | $list = []; |
| 285 | 285 | |
| 286 | - foreach($only as $table){ |
|
| 286 | + foreach ($only as $table) { |
|
| 287 | 287 | |
| 288 | - if(in_array($table,$tables) || in_array($table = strtolower($table),$tables)){ |
|
| 288 | + if (in_array($table, $tables) || in_array($table = strtolower($table), $tables)) { |
|
| 289 | 289 | $list[] = $table; |
| 290 | 290 | } |
| 291 | 291 | } |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | { |
| 305 | 305 | $list = []; |
| 306 | 306 | foreach ($index as $key=>$item) { |
| 307 | - if($item['Non_unique']==1 && $item['Key_name']!=='PRIMARY'){ |
|
| 307 | + if ($item['Non_unique']==1 && $item['Key_name']!=='PRIMARY') { |
|
| 308 | 308 | $list[$item['Key_name']][] = $item['Column_name']; |
| 309 | 309 | } |
| 310 | 310 | } |
@@ -52,8 +52,7 @@ discard block |
||
| 52 | 52 | if(!file_exists($makeDirectory)){ |
| 53 | 53 | files()->makeDirectory($makeDirectory,0755,true); |
| 54 | 54 | $exist=false; |
| 55 | - } |
|
| 56 | - else{ |
|
| 55 | + } else{ |
|
| 57 | 56 | $exist=true; |
| 58 | 57 | } |
| 59 | 58 | |
@@ -71,8 +70,7 @@ discard block |
||
| 71 | 70 | |
| 72 | 71 | if(substr($dbtable,-1)=='s'){ |
| 73 | 72 | app()->command('model create','model:'.strtolower(substr($dbtable,0,-1)).' table:'.$dbtable); |
| 74 | - } |
|
| 75 | - else{ |
|
| 73 | + } else{ |
|
| 76 | 74 | app()->command('model create','model:'.strtolower($dbtable).' table:'.$dbtable); |
| 77 | 75 | } |
| 78 | 76 | |
@@ -80,11 +78,9 @@ discard block |
||
| 80 | 78 | |
| 81 | 79 | $this->schema->getConnection()->generateEntity($dbtable); |
| 82 | 80 | echo $dbtablekey.'- '.$migrationName.' ---> Ok'; |
| 83 | - } |
|
| 84 | - elseif($exist){ |
|
| 81 | + } elseif($exist){ |
|
| 85 | 82 | echo $dbtablekey.'- '.$migrationName.' ---> (Already Exist)'; |
| 86 | - } |
|
| 87 | - else{ |
|
| 83 | + } else{ |
|
| 88 | 84 | echo $dbtablekey.'- '.$migrationName.' ---> Fail'; |
| 89 | 85 | } |
| 90 | 86 | |
@@ -211,41 +207,29 @@ discard block |
||
| 211 | 207 | { |
| 212 | 208 | if($column=='datetime'){ |
| 213 | 209 | return 'datetime()'; |
| 214 | - } |
|
| 215 | - elseif($column=='longtext'){ |
|
| 210 | + } elseif($column=='longtext'){ |
|
| 216 | 211 | return 'longtext()'; |
| 217 | - } |
|
| 218 | - elseif($column=='date'){ |
|
| 212 | + } elseif($column=='date'){ |
|
| 219 | 213 | return 'date()'; |
| 220 | - } |
|
| 221 | - elseif($column=='text'){ |
|
| 214 | + } elseif($column=='text'){ |
|
| 222 | 215 | return 'text()'; |
| 223 | - } |
|
| 224 | - elseif($column=='timestamp'){ |
|
| 216 | + } elseif($column=='timestamp'){ |
|
| 225 | 217 | return 'timestamp()'; |
| 226 | - } |
|
| 227 | - elseif($column=='mediumint'){ |
|
| 218 | + } elseif($column=='mediumint'){ |
|
| 228 | 219 | return 'mediumint()'; |
| 229 | - } |
|
| 230 | - elseif($column=='tinyint'){ |
|
| 220 | + } elseif($column=='tinyint'){ |
|
| 231 | 221 | return 'tinyint()'; |
| 232 | - } |
|
| 233 | - elseif($column=='float'){ |
|
| 222 | + } elseif($column=='float'){ |
|
| 234 | 223 | return 'float()'; |
| 235 | - } |
|
| 236 | - elseif($column=='mediumtext'){ |
|
| 224 | + } elseif($column=='mediumtext'){ |
|
| 237 | 225 | return 'mediumtext()'; |
| 238 | - } |
|
| 239 | - elseif($column=='mediumblob'){ |
|
| 226 | + } elseif($column=='mediumblob'){ |
|
| 240 | 227 | return 'mediumblob()'; |
| 241 | - } |
|
| 242 | - elseif($column=='blob'){ |
|
| 228 | + } elseif($column=='blob'){ |
|
| 243 | 229 | return 'blob()'; |
| 244 | - } |
|
| 245 | - elseif(preg_match('@enum.*\((.*?)\)@',$column,$enum)){ |
|
| 230 | + } elseif(preg_match('@enum.*\((.*?)\)@',$column,$enum)){ |
|
| 246 | 231 | return 'enum(['.$enum[1].'])'; |
| 247 | - } |
|
| 248 | - else{ |
|
| 232 | + } else{ |
|
| 249 | 233 | return $column; |
| 250 | 234 | } |
| 251 | 235 | } |
@@ -14,30 +14,30 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | public function processHandler() |
| 16 | 16 | { |
| 17 | - return $this->errorHandler(function(){ |
|
| 17 | + return $this->errorHandler(function() { |
|
| 18 | 18 | |
| 19 | 19 | $results = []; |
| 20 | 20 | |
| 21 | - foreach ($this->list as $table =>$datas){ |
|
| 21 | + foreach ($this->list as $table =>$datas) { |
|
| 22 | 22 | |
| 23 | - foreach ($datas as $data){ |
|
| 23 | + foreach ($datas as $data) { |
|
| 24 | 24 | |
| 25 | - $query = $this->queryBuilder($table,$data); |
|
| 25 | + $query = $this->queryBuilder($table, $data); |
|
| 26 | 26 | |
| 27 | 27 | $query = $query->handle(); |
| 28 | 28 | |
| 29 | 29 | |
| 30 | - if($query===false){ |
|
| 30 | + if ($query===false) { |
|
| 31 | 31 | $results[] = []; |
| 32 | 32 | } |
| 33 | - else{ |
|
| 34 | - $status =($query['result']!==false) ? true : false; |
|
| 33 | + else { |
|
| 34 | + $status = ($query['result']!==false) ? true : false; |
|
| 35 | 35 | |
| 36 | - if($status){ |
|
| 36 | + if ($status) { |
|
| 37 | 37 | $this->schema->getConnection()->generateEntity($table); |
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - $results[]= [ |
|
| 40 | + $results[] = [ |
|
| 41 | 41 | 'success'=>$status, |
| 42 | 42 | 'file'=>$data->getFile(), |
| 43 | 43 | 'table'=>$table, |
@@ -67,11 +67,11 @@ discard block |
||
| 67 | 67 | { |
| 68 | 68 | $alterBinds = $object->getAlterBinds(); |
| 69 | 69 | |
| 70 | - if(!is_null($alterBinds) && count($alterBinds)>1){ |
|
| 70 | + if (!is_null($alterBinds) && count($alterBinds)>1) { |
|
| 71 | 71 | exception()->runtime('Only one command can be applied to alter groups'); |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - if(count($object->getError())){ |
|
| 74 | + if (count($object->getError())) { |
|
| 75 | 75 | exception()->runtime(''.$object->getFile().' -> '.$object->getError()[0].''); |
| 76 | 76 | } |
| 77 | 77 | |
@@ -29,8 +29,7 @@ |
||
| 29 | 29 | |
| 30 | 30 | if($query===false){ |
| 31 | 31 | $results[] = []; |
| 32 | - } |
|
| 33 | - else{ |
|
| 32 | + } else{ |
|
| 34 | 33 | $status =($query['result']!==false) ? true : false; |
| 35 | 34 | |
| 36 | 35 | if($status){ |
@@ -15,25 +15,24 @@ discard block |
||
| 15 | 15 | {
|
| 16 | 16 | $getCommandList = app()->commandList(); |
| 17 | 17 | |
| 18 | - $this->table->setHeaders(['command','project','params','description']); |
|
| 18 | + $this->table->setHeaders(['command', 'project', 'params', 'description']); |
|
| 19 | 19 | |
| 20 | 20 | $app = $this; |
| 21 | 21 | |
| 22 | - foreach ($getCommandList as $command=>$runnable){
|
|
| 22 | + foreach ($getCommandList as $command=>$runnable) {
|
|
| 23 | 23 | |
| 24 | - $commandInstance = app()->resolve($command,['argument'=>[]]); |
|
| 24 | + $commandInstance = app()->resolve($command, ['argument'=>[]]); |
|
| 25 | 25 | |
| 26 | 26 | $className = class_basename($commandInstance); |
| 27 | 27 | |
| 28 | - ClosureDispatcher::bind($commandInstance)->call(function() use($app,$className) |
|
| 28 | + ClosureDispatcher::bind($commandInstance)->call(function() use($app, $className) |
|
| 29 | 29 | {
|
| 30 | - if(isset($this->runnableMethods)){
|
|
| 30 | + if (isset($this->runnableMethods)) {
|
|
| 31 | 31 | |
| 32 | - foreach ($this->runnableMethods as $method=>$description){
|
|
| 32 | + foreach ($this->runnableMethods as $method=>$description) {
|
|
| 33 | 33 | |
| 34 | 34 | $commandRule = (isset($this->commandRule[$method])) ? |
| 35 | - $app->methodCommandRule($this->commandRule[$method]) : |
|
| 36 | - $app->methodCommandRule($this->commandRule); |
|
| 35 | + $app->methodCommandRule($this->commandRule[$method]) : $app->methodCommandRule($this->commandRule); |
|
| 37 | 36 | |
| 38 | 37 | $projectStatus = (isset($this->projectStatus)) ? 'YES' : 'NO'; |
| 39 | 38 | |
@@ -61,18 +60,18 @@ discard block |
||
| 61 | 60 | public function methodCommandRule($commandRule) |
| 62 | 61 | {
|
| 63 | 62 | |
| 64 | - if(is_array($commandRule)){
|
|
| 63 | + if (is_array($commandRule)) {
|
|
| 65 | 64 | |
| 66 | 65 | $list = []; |
| 67 | 66 | |
| 68 | - foreach ($commandRule as $rule){
|
|
| 69 | - if(!is_array($rule)){
|
|
| 67 | + foreach ($commandRule as $rule) {
|
|
| 68 | + if (!is_array($rule)) {
|
|
| 70 | 69 | $list[] = $rule.':['.$rule.']'; |
| 71 | 70 | } |
| 72 | 71 | |
| 73 | 72 | } |
| 74 | 73 | |
| 75 | - return implode(" ",$list);
|
|
| 74 | + return implode(" ", $list);
|
|
| 76 | 75 | } |
| 77 | 76 | |
| 78 | 77 | return '['.$commandRule.']'; |
@@ -27,13 +27,13 @@ discard block |
||
| 27 | 27 | {
|
| 28 | 28 | // we check that they are in |
| 29 | 29 | // the console to run the console commands in the kernel. |
| 30 | - if(Utils::isNamespaceExists($this->consoleClassNamespace)){
|
|
| 30 | + if (Utils::isNamespaceExists($this->consoleClassNamespace)) {
|
|
| 31 | 31 | return call_user_func($callback); |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | // if the kernel console is not found |
| 35 | 35 | // then we check the existence of the specific application command and run it if it is. |
| 36 | - return (new CustomConsoleProcess($this->getConsoleArgumentsWithKey(),$this))->handle(); |
|
| 36 | + return (new CustomConsoleProcess($this->getConsoleArgumentsWithKey(), $this))->handle(); |
|
| 37 | 37 | |
| 38 | 38 | } |
| 39 | 39 | |
@@ -43,25 +43,25 @@ discard block |
||
| 43 | 43 | * @param array $args |
| 44 | 44 | * @return void|mixed |
| 45 | 45 | */ |
| 46 | - protected function consoleEventHandler($args=array()) |
|
| 46 | + protected function consoleEventHandler($args = array()) |
|
| 47 | 47 | {
|
| 48 | - if(isset($this->app['eventDispatcher'])){
|
|
| 48 | + if (isset($this->app['eventDispatcher'])) {
|
|
| 49 | 49 | |
| 50 | 50 | $listeners = event()->getListeners(); |
| 51 | 51 | |
| 52 | - if(isset($args['event']) && isset($listeners['console'])){
|
|
| 52 | + if (isset($args['event']) && isset($listeners['console'])) {
|
|
| 53 | 53 | |
| 54 | - if(strtolower($args['event'])!=='default' && isset($listeners['console'][strtolower($args['event'])])){
|
|
| 54 | + if (strtolower($args['event'])!=='default' && isset($listeners['console'][strtolower($args['event'])])) {
|
|
| 55 | 55 | |
| 56 | 56 | $event = $listeners['console'][strtolower($args['event'])]; |
| 57 | - return call_user_func_array($event,['app'=>$this->app,'args'=>$args,]); |
|
| 57 | + return call_user_func_array($event, ['app'=>$this->app, 'args'=>$args, ]); |
|
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | |
| 61 | - if(isset($listeners['console']['default'])){
|
|
| 61 | + if (isset($listeners['console']['default'])) {
|
|
| 62 | 62 | |
| 63 | 63 | $event = $listeners['console']['default']; |
| 64 | - return call_user_func_array($event,['args'=>$args,'app'=>$this->app]); |
|
| 64 | + return call_user_func_array($event, ['args'=>$args, 'app'=>$this->app]); |
|
| 65 | 65 | } |
| 66 | 66 | } |
| 67 | 67 | |
@@ -79,9 +79,9 @@ discard block |
||
| 79 | 79 | |
| 80 | 80 | //If the console executor is a custom console application; in this case we look at the kernel directory inside the application. |
| 81 | 81 | //If the console class is not available on the kernel of resta, then the system will run the command class in the application. |
| 82 | - return $this->checkConsoleNamespace(function(){
|
|
| 82 | + return $this->checkConsoleNamespace(function() {
|
|
| 83 | 83 | |
| 84 | - if($this->isRunnableKernelCommandList()){
|
|
| 84 | + if ($this->isRunnableKernelCommandList()) {
|
|
| 85 | 85 | exception()->badMethodCall('this command is not runnable');
|
| 86 | 86 | } |
| 87 | 87 | |
@@ -89,10 +89,10 @@ discard block |
||
| 89 | 89 | $consoleArguments = $this->getConsoleArgumentsWithKey(); |
| 90 | 90 | |
| 91 | 91 | // we get the instance data of the kernel command class of the system. |
| 92 | - $commander = (new $this->consoleClassNamespace($consoleArguments,$this)); |
|
| 92 | + $commander = (new $this->consoleClassNamespace($consoleArguments, $this)); |
|
| 93 | 93 | |
| 94 | 94 | // we check the command rules of each command class. |
| 95 | - $this->prepareCommander($commander,function($commander){
|
|
| 95 | + $this->prepareCommander($commander, function($commander) {
|
|
| 96 | 96 | return $commander->{$this->getConsoleClassMethod()}();
|
| 97 | 97 | }); |
| 98 | 98 | |
@@ -110,12 +110,12 @@ discard block |
||
| 110 | 110 | public function handle() |
| 111 | 111 | {
|
| 112 | 112 | //get is running console |
| 113 | - if($this->app->runningInConsole()){
|
|
| 113 | + if ($this->app->runningInConsole()) {
|
|
| 114 | 114 | |
| 115 | 115 | error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE); |
| 116 | 116 | |
| 117 | 117 | //run console process |
| 118 | - if(count($this->getArguments())){
|
|
| 118 | + if (count($this->getArguments())) {
|
|
| 119 | 119 | return $this->consoleProcess(); |
| 120 | 120 | } |
| 121 | 121 | |
@@ -131,24 +131,24 @@ discard block |
||
| 131 | 131 | * @param callable $callback |
| 132 | 132 | * @return mixed |
| 133 | 133 | */ |
| 134 | - protected function prepareCommander(ConsoleOutputterContracts $commander,callable $callback) |
|
| 134 | + protected function prepareCommander(ConsoleOutputterContracts $commander, callable $callback) |
|
| 135 | 135 | {
|
| 136 | 136 | // closure binding custom command,move custom namespace as specific |
| 137 | 137 | // call prepare commander firstly for checking command builder |
| 138 | - $closureCommand = app()->resolve(ClosureDispatcher::class,['bind'=>$commander]); |
|
| 138 | + $closureCommand = app()->resolve(ClosureDispatcher::class, ['bind'=>$commander]); |
|
| 139 | 139 | |
| 140 | 140 | //assign commander method name |
| 141 | 141 | $closureCommand->prepareBind['methodName'] = $this->getConsoleClassMethod(); |
| 142 | 142 | |
| 143 | 143 | $prepareCommander = $commander->prepareCommander($closureCommand); |
| 144 | 144 | |
| 145 | - if(!$prepareCommander['status']){
|
|
| 145 | + if (!$prepareCommander['status']) {
|
|
| 146 | 146 | echo $commander->exception($prepareCommander); |
| 147 | 147 | die(); |
| 148 | 148 | } |
| 149 | 149 | |
| 150 | 150 | //callback custom console |
| 151 | - return call_user_func_array($callback,[$commander]); |
|
| 151 | + return call_user_func_array($callback, [$commander]); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | /** |
@@ -161,8 +161,8 @@ discard block |
||
| 161 | 161 | $commandList = $this->app->commandList(); |
| 162 | 162 | |
| 163 | 163 | //is runnable kernel command conditions |
| 164 | - return !array_key_exists($this->consoleClassNamespace,$commandList) OR |
|
| 165 | - (array_key_exists($this->consoleClassNamespace,$commandList) AND |
|
| 164 | + return !array_key_exists($this->consoleClassNamespace, $commandList) OR |
|
| 165 | + (array_key_exists($this->consoleClassNamespace, $commandList) AND |
|
| 166 | 166 | !$commandList[$this->consoleClassNamespace]['isRunnable']); |
| 167 | 167 | } |
| 168 | 168 | } |
| 169 | 169 | \ No newline at end of file |