/** * Creates a new model * * @return bool */ protected function _createComponent() { $this->_model = ucfirst(Steelcode_String_Helper::dashedToCamel($this->_name)); $model = "{$this->_model}.php"; $this->_path = "{$this->_location}/application/models/{$model}"; $this->_filePointer = fopen($this->_path, "w"); if ($this->_filePointer === null) { $this->_setErrorText("Error! Could not create model:\n\t- {$this->_path}"); return false; } $this->_writeContent(); $this->_setMessageText("Done! Successfully created new model\n\t- {$this->_name}"); return true; }
/** * Creates a new configuration class * * @return bool */ protected function _createComponent() { $this->_config = ucfirst(Steelcode_String_Helper::dashedToCamel($this->_name)); $config = "{$this->_config}.php"; $this->_path = "{$this->_location}/application/configs/{$config}"; $this->_filePointer = fopen($this->_path, "w"); if ($this->_filePointer === null) { $this->_setErrorText("* Error! Could not create configuration:\n\t- {$this->_path}"); return false; } fwrite($this->_filePointer, "<?php\n"); fwrite($this->_filePointer, "/**\n * Class Config_{$this->_config}\n */\n"); $text = "class Config_{$this->_config} " . '{' . "\n\n}\n"; fwrite($this->_filePointer, $text); $this->_setMessageText("Done! Successfully created new configuration class:\n\t- Config_{$this->_config}"); return true; }
/** * Create the controller in the domain */ private function _createController() { $controller = ucfirst(Steelcode_String_Helper::dashedToCamel($this->_name)); $this->_controller = "{$controller}Controller.php"; $this->_path = "{$this->_location}/application/controllers/{$this->_domain}/{$this->_controller}"; $this->_filePointer = fopen($this->_path, "w"); if ($this->_filePointer === null) { throw new Steelcode_Project_Exception("* Error! Could not create controller:\n\t- {$this->_path}"); } fwrite($this->_filePointer, "<?php\n"); $text = "/**\n * Class Controller_{$controller}\n */\n"; fwrite($this->_filePointer, $text); $text = "class Controller_{$controller} extends Steelcode_Domain_Controller { \n\n"; $text .= "\t/**\n\t * Initialize\n\t */\n"; $text .= "\tpublic function init() {\n\n\t}\n\n"; $text .= "\t/**\n\t * Controller action\n\t */\n"; $text .= "\tpublic function controllerAction() {\n\n\t}\n}\n"; fwrite($this->_filePointer, $text); }
/** * Sets the controller name * Finds the controller class name and file name * * @param string $controller */ public function setController($controller) { $class = ucfirst(Steelcode_String_Helper::dashedToCamel($controller)); $this->_controller['name'] = $controller; $this->_controller['class'] = "Controller_{$class}"; $this->_controller['file'] = "{$class}Controller.php"; }