Skip to content

Commit b2bd361

Browse files
committed
Updated Console Generators as per Connection Update PDO::ATTR_CASE => PDO::CASE_NATURAL,
1 parent 8caf5b5 commit b2bd361

File tree

5 files changed

+29
-33
lines changed

5 files changed

+29
-33
lines changed

vendor/cygnite/framework/src/Cygnite/Console/Command/GeneratorCommand.php

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525

2626
class GeneratorCommand extends Command
2727
{
28-
2928
public $applicationDir;
3029
public $controller;
3130
public $model;
@@ -36,11 +35,9 @@ class GeneratorCommand extends Command
3635
private $output;
3736
private $viewType;
3837

39-
public static function __callStatic($method, $arguments = array())
38+
public static function instance()
4039
{
41-
if ($method == 'instance') {
42-
return new self();
43-
}
40+
return new self();
4441
}
4542

4643
public function setSchema($table)
@@ -59,8 +56,8 @@ public function getPrimaryKey()
5956

6057
if (count($this->columns) > 0) {
6158
foreach ($this->columns as $key => $value) {
62-
if ($value->column_key == 'PRI' || $value->extra == 'auto_increment') {
63-
$primaryKey = $value->column_name;
59+
if ($value->COLUMN_KEY == 'PRI' || $value->EXTRA == 'auto_increment') {
60+
$primaryKey = $value->COLUMN_NAME;
6461
break;
6562
}
6663
}
@@ -93,7 +90,8 @@ protected function execute(InputInterface $input, OutputInterface $output)
9390
$this->controller = Inflector::classify($input->getArgument('name')) . 'Controller';
9491
// Model name
9592
$this->model = Inflector::classify($input->getArgument('model'));
96-
/** Check for argument database name if not given we will use default
93+
/**
94+
* Check for argument database name if not given we will use default
9795
* database connection
9896
*/
9997
$this->database = (!is_null($input->getArgument('database'))) ?
@@ -102,7 +100,6 @@ protected function execute(InputInterface $input, OutputInterface $output)
102100

103101
// By default we will generate plain php layout and view pages
104102
$this->viewType = ($input->getOption('template') == false) ? 'php' : 'twig';
105-
106103
$this->columns = $this->getColumns();
107104

108105
if (empty($this->columns)) {
@@ -163,7 +160,7 @@ private function generateModel()
163160
{
164161
$modelInstance = Model::instance($this);
165162
$modelTemplateDir =
166-
dirname(dirname(__FILE__)) . DS . 'src' . DS . ucfirst('apps') . DS . ucfirst('models') . DS;
163+
dirname(dirname(__FILE__)) . DS . 'src' . DS . 'Apps' . DS . 'Models' . DS;
167164

168165
$modelInstance->setModelTemplatePath($modelTemplateDir);
169166
$modelInstance->updateTemplate();
@@ -178,7 +175,7 @@ private function generateViews()
178175
{
179176
$viewInstance = View::instance($this);
180177
$viewInstance->setLayoutType($this->viewType);
181-
$viewTemplateDir = dirname(dirname(__FILE__)) . DS . 'src' . DS . ucfirst('apps') . DS . ucfirst('views') . DS;
178+
$viewTemplateDir = dirname(dirname(__FILE__)) . DS . 'src' . DS . 'Apps' . DS . 'Views' . DS;
182179
$viewInstance->setTableColumns($this->columns);
183180
$viewInstance->setViewTemplatePath($viewTemplateDir);
184181

vendor/cygnite/framework/src/Cygnite/Console/Command/ModelGeneratorCommand.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ private function getColumns()
6262
return $this->tableSchema->connect(
6363
$this->database,
6464
Inflector::tabilize($this->model)
65-
)->getColumns();
65+
)->{__FUNCTION__}();
6666
}
6767

6868
/**
@@ -75,8 +75,8 @@ public function getPrimaryKey()
7575

7676
if (count($this->columns) > 0) {
7777
foreach ($this->columns as $key => $value) {
78-
if ($value->column_key == 'PRI' || $value->extra == 'auto_increment') {
79-
$primaryKey = $value->column_name;
78+
if ($value->COLUMN_KEY == 'PRI' || $value->EXTRA == 'auto_increment') {
79+
$primaryKey = $value->COLUMN_NAME;
8080
break;
8181
}
8282
}
@@ -110,11 +110,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
110110
// Check for argument database name if not given we will use default
111111
// database connection
112112
$this->database = $this->getDatabase($input);
113-
114113
$this->columns = $this->getColumns();
115114

116115
if (empty($this->columns)) {
117-
throw new \Exception("Please check your model name. It seems doesn't exists in the database.");
116+
throw new \Exception("Please check your model name. It seems table doesn't exists into database.");
118117
}
119118

120119
$this->applicationDir = CYGNITE_BASE.DS.APPPATH;

vendor/cygnite/framework/src/Cygnite/Console/Generator/Controller.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,10 @@ private function buildFormOpen()
124124
private function generateFormElements($value)
125125
{
126126
$form = $label = '';
127-
$label = Inflector::underscoreToSpace($value->column_name);
127+
$label = Inflector::underscoreToSpace($value->COLUMN_NAME);
128128
$form .= "\t\t".'->addElement("label", "'.$label.'", array("class" => "col-sm-2 control-label","style" => "width:100%;"))'.PHP_EOL;
129129

130-
$form .= "\t\t".'->addElement("text", "'.$value->column_name.'", array("value" => (isset($this->model->'.$value->column_name.')) ? $this->model->'.$value->column_name.' : "", "class" => "form-control"))'.PHP_EOL;
130+
$form .= "\t\t".'->addElement("text", "'.$value->COLUMN_NAME.'", array("value" => (isset($this->model->'.$value->COLUMN_NAME.')) ? $this->model->'.$value->COLUMN_NAME.' : "", "class" => "form-control"))'.PHP_EOL;
131131
return $form;
132132
}
133133

@@ -155,7 +155,7 @@ private function generateDbCode($value)
155155
{
156156
$code = '';
157157
$code .=
158-
"\t".'$'.Inflector::tabilize($this->model).'->'.$value->column_name.' = $postArray["'.$value->column_name.'"];'.PHP_EOL;
158+
"\t\t\t\t".'$'.Inflector::tabilize($this->model).'->'.$value->COLUMN_NAME.' = $postArray["'.$value->COLUMN_NAME.'"];'.PHP_EOL;
159159

160160
return $code;
161161
}
@@ -168,7 +168,7 @@ private function generateDbCode($value)
168168
private function generateValidator($value)
169169
{
170170
$validationCode = '';
171-
$validationCode .= "\t\t->addRule('".$value->column_name."', 'required|min:5')".PHP_EOL;
171+
$validationCode .= "\t\t\t->addRule('".$value->COLUMN_NAME."', 'required|min:5')".PHP_EOL;
172172

173173
return $validationCode;
174174
}
@@ -186,7 +186,7 @@ public function updateTemplate()
186186

187187
foreach ($this->columns as $key=> $value) {
188188

189-
if ($value->column_name !== 'id') {
189+
if ($value->COLUMN_NAME !== 'id') {
190190
if ($this->isFormGenerator == false) {
191191
$codeDb .= $this->generateDbCode($value);
192192
}
@@ -199,7 +199,7 @@ public function updateTemplate()
199199

200200
$this->setForm($form);
201201
$this->setDbCode($codeDb);
202-
$this->setValidationCode($validationCode.';');
202+
$this->setValidationCode($validationCode."\t\t\t;");
203203
}
204204

205205
private function setForm($form)

vendor/cygnite/framework/src/Cygnite/Console/Generator/View.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -264,17 +264,17 @@ private function replaceTableElements($type = 'th')
264264

265265
foreach ($this->getTableColumns() as $key=> $value) {
266266

267-
if ($value->column_name !== 'id') {
267+
if ($value->COLUMN_NAME !== 'id') {
268268

269269
if ($type == 'th') {
270-
$tableHead = Inflector::underscoreToSpace($value->column_name);
270+
$tableHead = Inflector::underscoreToSpace($value->COLUMN_NAME);
271271
$column .= "\t\t\t".'<'.$type.'>'.$tableHead.'</'.$type.'>'.PHP_EOL;
272272
} else{
273273
$rowType = '';
274274
if ($this->layoutType == 'php') {
275-
$rowType = '<?php echo $row->'.$value->column_name.'; ?>';
275+
$rowType = '<?php echo $row->'.$value->COLUMN_NAME.'; ?>';
276276
} else {
277-
$rowType = '{{row.'.$value->column_name.'}}';
277+
$rowType = '{{row.'.$value->COLUMN_NAME.'}}';
278278
}
279279
$column .= "\t\t\t".'<'.$type.'>'.$rowType.'</'.$type.'>'.PHP_EOL;
280280
}
@@ -309,18 +309,18 @@ private function replaceViewTemplateContents($content)
309309
$column = '';
310310
foreach ($this->getTableColumns() as $key=> $value) {
311311

312-
if ($value->column_name !== 'id') {
312+
if ($value->COLUMN_NAME !== 'id') {
313313

314314
if ($this->layoutType == 'php') {
315-
$rowType = '<?php echo $record->'.$value->column_name.'; ?>';
315+
$rowType = '<?php echo $record->'.$value->COLUMN_NAME.'; ?>';
316316
} else {
317-
$rowType = '{{ record.'.$value->column_name.' }}';
317+
$rowType = '{{ record.'.$value->COLUMN_NAME.' }}';
318318
}
319319

320320
$column .=
321321
"\t\t\t".'<div class="form-group">
322322
<label class="col-sm-2 control-label">'.
323-
Inflector::underscoreToSpace($value->column_name).
323+
Inflector::underscoreToSpace($value->COLUMN_NAME).
324324
'</label>
325325
<div class="col-sm-10">
326326
<p class="form-control-static"><span>'.$rowType.'</span></p>

vendor/cygnite/framework/src/Cygnite/Database/Schema.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -492,10 +492,10 @@ public function addPrimaryKey($columns)
492492
{
493493
$schema = self::SELECT . " EXISTS
494494
(
495-
" . self::SELECT . " * FROM " . $this->_informationSchema . ".columns
495+
" . self::SELECT . " * FROM " . $this->_informationSchema . ".COLUMNS
496496
WHERE " . $this->_tableSchema . "= '" . $this->database . "' AND
497-
table_name ='" . $this->tableName . "' AND
498-
column_key = 'PRI'
497+
TABLE_NAME ='" . $this->tableName . "' AND
498+
COLUMN_KEY = 'PRI'
499499
500500
) AS has_primary_key;";
501501

0 commit comments

Comments
 (0)