Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions scripts/Builder/Components/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public function build(){
$className = Utils::camelize($name);
$controllerPath = $path."public/".$controllersDir.$className."Controller.php";
$code = "<?php\n\nclass ".$className."Controller extends ".$baseClass." {\n\n\tpublic function indexAction(){\n\n\t}\n\n}\n\n";
$code = str_replace("\t", " ", $code);
if(!file_exists($controllerPath) || $this->_options['force']==true){
file_put_contents($controllerPath, $code);
} else {
Expand Down
15 changes: 8 additions & 7 deletions scripts/Builder/Components/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,14 +244,14 @@ public function build(){
if($useSettersGetters){
$attributes[] = "\t/**\n\t * @var $type\n\t */\n\tprotected \${$field['Field']};\n";
$setterName = Utils::camelize($field['Field']);
$setters[] = "\t/**\n\t * Method to set the value of field {$field['Field']}\n\t * @param $type \${$field['Field']}\n\t */\n\tpublic function set$setterName(\${$field['Field']}){\n\t\t\$this->{$field['Field']} = \${$field['Field']};\n\t}\n";
$setters[] = "\t/**\n\t * Method to set the value of field {$field['Field']}\n\n\t * @param $type \${$field['Field']}\n\t */\n\tpublic function set$setterName(\${$field['Field']}){\n\t\t\$this->{$field['Field']} = \${$field['Field']};\n\t}\n";
if(isset($this->_typeMap[$type])){
$getters[] = "\t/**\n\t * Returns the value of field {$field['Field']}\n\t * @return $type\n\t */\n\tpublic function get$setterName(){\n\t\tif(\$this->{$field['Field']}){\n\t\t\treturn new {$this->_typeMap[$type]}(\$this->{$field['Field']});\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t}\n";
$getters[] = "\t/**\n\t * Returns the value of field {$field['Field']}\n\n\t * @return $type\n\t */\n\tpublic function get$setterName(){\n\t\tif(\$this->{$field['Field']}){\n\t\t\treturn new {$this->_typeMap[$type]}(\$this->{$field['Field']});\n\t\t} else {\n\t\t\treturn null;\n\t\t}\n\t}\n";
} else {
$getters[] = "\t/**\n\t * Returns the value of field {$field['Field']}\n\t * @return $type\n\t */\n\tpublic function get$setterName(){\n\t\treturn \$this->{$field['Field']};\n\t}\n";
$getters[] = "\t/**\n\t * Returns the value of field {$field['Field']}\n\n\t * @return $type\n\t */\n\tpublic function get$setterName(){\n\t\treturn \$this->{$field['Field']};\n\t}\n";
}
} else {
$attributes[] = "\t/**\n\t * @var $type\n\t */\n\tpublic \${$field['Field']};\n";
$attributes[] = "\t/**\n\n\t * @var $type\n\t */\n\tpublic \${$field['Field']};\n";
}
}

Expand Down Expand Up @@ -289,16 +289,17 @@ public function build(){

if($genDocMethods){
$code.="\n\t/**\n\t * @return ".$this->_options['className']."[]\n\t */\n";
$code.="\tstatic public function find(\$parameters=array()){\n";
$code.="\tpublic static function find(\$parameters=array()){\n";
$code.="\t\treturn parent::find(\$parameters);\n";
$code.="\t}\n\n";
$code.="\n\t/**\n\t * @return ".$this->_options['className']."\n\t */\n";
$code.="\tstatic public function findFirst(\$parameters=array()){\n";
$code.="\tpublic static function findFirst(\$parameters=array()){\n";
$code.="\t\treturn parent::findFirst(\$parameters);\n";
$code.="\t}\n\n";
}

$code.="}\n\n";
$code.="}\n";
$code = str_replace("\t", " ", $code);
file_put_contents($path.$modelsDir."/".$this->_options['className'].".php", $code);

}
Expand Down
8 changes: 7 additions & 1 deletion scripts/Builder/Components/Scaffold.php
Original file line number Diff line number Diff line change
Expand Up @@ -391,7 +391,7 @@ private function _makeController($path, $options){
}'.PHP_EOL.PHP_EOL;

$code .= "".'}'.PHP_EOL;

$code = str_replace("\t", " ", $code);
file_put_contents($controllerPath, $code);
}

Expand Down Expand Up @@ -429,6 +429,7 @@ private function _makeLayouts($path, $options){
}
$code.="\t".'<?php echo $this->getContent(); ?>'.PHP_EOL.
'</div>';
$code = str_replace("\t", " ", $code);
file_put_contents($viewPath, $code);

}
Expand Down Expand Up @@ -527,6 +528,7 @@ private function _makeFields($path, $options, $action){
}
$code.=PHP_EOL."\t\t".'</tr>'.PHP_EOL;
}
$code = str_replace("\t", " ", $code);
return $code;
}

Expand Down Expand Up @@ -575,6 +577,7 @@ private function _makeViewIndex($path, $options){
'</div>';

//index.phtml
$code = str_replace("\t", " ", $code);
file_put_contents($viewPath, $code);
}

Expand Down Expand Up @@ -623,6 +626,7 @@ private function _makeViewNew($path, $options){
"\t".'</form>'.PHP_EOL;

//index.phtml
$code = str_replace("\t", " ", $code);
file_put_contents($viewPath, $code);
}
}
Expand Down Expand Up @@ -672,6 +676,7 @@ private function _makeViewEdit($path, $options){
"\t".'<?php echo Phalcon_Tag::endForm() ?>'.PHP_EOL;

//index.phtml
$code = str_replace("\t", " ", $code);
file_put_contents($viewPath, $code);

}
Expand Down Expand Up @@ -763,6 +768,7 @@ private function _makeViewSearch($path, $options){
"\t\t".'</tr>'.PHP_EOL.
"\t".'<tbody>'.PHP_EOL.
'</table>';
$code = str_replace("\t", " ", $code);
file_put_contents($viewPath, $code);
}
}
Expand Down
5 changes: 5 additions & 0 deletions scripts/Model/Migration.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,10 @@ public static function generate($version, $table, $exportData=null){
case 'datetime':
$fieldDefinition[] = "'type' => Column::TYPE_DATETIME";
break;
case 'float':
$fieldDefinition[] = "'type' => Column::TYPE_DECIMAL";
$numericFields[$field['Field']] = true;
break;
case 'decimal':
$fieldDefinition[] = "'type' => Column::TYPE_DECIMAL";
$numericFields[$field['Field']] = true;
Expand Down Expand Up @@ -254,6 +258,7 @@ class ".$className." extends Phalcon_Model_Migration {\n\n".
$classData.="\n\t}";
}
$classData.="\n\n}";
$classData = str_replace("\t", " ", $classData);
return $classData;
}

Expand Down