/** * Creates contets for this form * * @see Zend_Tool_Project_Context_Filesystem_File::getContents() */ public function getContents() { $className = ucfirst($this->_formName); $moduleName = ucfirst($this->_moduleName); $codeGenFile = new Zend_CodeGenerator_Php_File(array('fileName' => $this->getPath(), 'classes' => array(new Zend_CodeGenerator_Php_Class(array('name' => $className, 'extendedClass' => 'App_' . $moduleName . '_Form', 'methods' => array(new Zend_CodeGenerator_Php_Method(array('name' => 'init', 'body' => 'parent::init();', 'visibility' => Zend_CodeGenerator_Php_Method::VISIBILITY_PUBLIC)))))))); return $codeGenFile->generate(); }
/** * getContents() * * @return string */ public function getContents() { $filter = new Zend_Filter_Word_DashToCamelCase(); $className = $filter->filter($this->_forControllerName) . 'ControllerTest'; $codeGenFile = new Zend_CodeGenerator_Php_File(array('requiredFiles' => array('PHPUnit/Framework/TestCase.php'), 'classes' => array(new Zend_CodeGenerator_Php_Class(array('name' => $className, 'extendedClass' => 'PHPUnit_Framework_TestCase', 'methods' => array(new Zend_CodeGenerator_Php_Method(array('name' => 'setUp', 'body' => ' /* Setup Routine */')), new Zend_CodeGenerator_Php_Method(array('name' => 'tearDown', 'body' => ' /* Tear Down Routine */')))))))); return $codeGenFile->generate(); }
/** * Creates contets for this model * * @see Zend_Tool_Project_Context_Filesystem_File::getContents() */ public function getContents() { $className = ucfirst($this->_modelName); $tableName = $this->camelCaseToUnderscore($this->_modelName); $codeGenFile = new Zend_CodeGenerator_Php_File(array('fileName' => $this->getPath(), 'classes' => array(new Zend_CodeGenerator_Php_Class(array('name' => $className, 'extendedClass' => 'App_Model', 'properties' => array(new Zend_CodeGenerator_Php_Property(array('name' => '_primary', 'visibility' => Zend_CodeGenerator_Php_Property::VISIBILITY_PROTECTED, 'defaultValue' => 'id')), new Zend_CodeGenerator_Php_Property(array('name' => '_name', 'visibility' => Zend_CodeGenerator_Php_Property::VISIBILITY_PROTECTED, 'defaultValue' => $tableName)), new Zend_CodeGenerator_Php_Property(array('name' => '_rowClass', 'visibility' => Zend_CodeGenerator_Php_Property::VISIBILITY_PROTECTED, 'defaultValue' => 'App_Table_' . $className)))))))); return $codeGenFile->generate(); }
public function scaffold() { $form = $this->_getForm(); $file = new Zend_CodeGenerator_Php_File(); $file->setClass($form); return $file->generate(); }
/** * getContents() * * @return string */ public function getContents() { $codeGenerator = new Zend_CodeGenerator_Php_File(array('body' => <<<EOS // Define path to application directory defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application')); // Define application environment defined('APPLICATION_ENV') || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production')); // Ensure library/ is on include_path set_include_path(implode(PATH_SEPARATOR, array( realpath(APPLICATION_PATH . '/../library'), get_include_path(), ))); /** Zend_Application */ require_once 'Zend/Application.php'; // Create application, bootstrap, and run \$application = new Zend_Application( APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini' ); \$application->bootstrap() ->run(); EOS )); return $codeGenerator->generate(); }
/** * Generates the content of the model file * * @return string */ public function getContents() { $className = $this->getFullClassName($this->_modelName, 'Model'); $properties = count($this->_fields) ? $this->getProperties($this->_fields) : array(); $methods = count($this->_fields) ? $this->getMethods($this->_fields, $this->_modelName) : array(); $codeGenFile = new Zend_CodeGenerator_Php_File(array('fileName' => $this->getPath(), 'classes' => array(new Zend_CodeGenerator_Php_Class(array('name' => $className, 'properties' => $properties, 'methods' => $methods))))); return $codeGenFile->generate(); }
public function testFromReflection() { $tempFile = tempnam(sys_get_temp_dir(), 'UnitFile'); $codeGenFile = new Zend_CodeGenerator_Php_File(array('class' => array('name' => 'SampleClass'))); file_put_contents($tempFile, $codeGenFile->generate()); require_once $tempFile; $codeGenFileFromDisk = Zend_CodeGenerator_Php_File::fromReflection(new Zend_Reflection_File($tempFile)); unlink($tempFile); $this->assertEquals(get_class($codeGenFileFromDisk), 'Zend_CodeGenerator_Php_File'); $this->assertEquals(count($codeGenFileFromDisk->getClasses()), 1); }
/** * Generate class * @return string generated source code */ public function generate() { $table = new ModelGenerator_Table_Table($this->_options['tableName']); $className = $this->_getNamer()->formatClassName($this->_config->classname); $baseModelClassName = $this->_getNamer()->formatClassName($this->_config->base->classname); $templates = array('tags' => array()); foreach ($this->_options['docblock'] as $tag => $value) { $templates['tags'][] = array('name' => $tag, 'description' => $value); } $mapperTable = new Zend_CodeGenerator_Php_Class(array('name' => $className, 'docblock' => new Zend_CodeGenerator_Php_Docblock(array('shortDescription' => $className . PHP_EOL . 'Put your custom methods in this file.', 'tags' => array_merge($templates['tags']))), 'extendedClass' => $baseModelClassName)); $mapperTableFile = new Zend_CodeGenerator_Php_File(array('classes' => array($mapperTable))); return $mapperTableFile->generate(); }
public function getContents() { // Configuring after instantiation $methodUp = new Zend_CodeGenerator_Php_Method(); $methodUp->setName('up')->setBody('// upgrade'); // Configuring after instantiation $methodDown = new Zend_CodeGenerator_Php_Method(); $methodDown->setName('down')->setBody('// degrade'); $class = new Zend_CodeGenerator_Php_Class(); $class->setName('Migration_' . $this->getMigrationName())->setExtendedClass('Core_Migration_Abstract')->setMethod($methodUp)->setMethod($methodDown); $file = new Zend_CodeGenerator_Php_File(); $file->setClass($class)->setFilename($this->getPath()); return $file->generate(); }
/** * Generate class * @return string generated source code */ public function generate() { $table = new ModelGenerator_Table_Table($this->_options['tableName']); $className = $this->_getNamer()->formatClassName($this->_config->baseMapper->classname); $templates = array('tags' => array()); foreach ($this->_options['docblock'] as $tag => $value) { $templates['tags'][] = array('name' => $tag, 'description' => $value); } $methods = array(); $tableReferences = array(); foreach ($table->getUniqueKeys() as $key) { $methods[] = new Zend_CodeGenerator_Php_Method(array('name' => 'findBy' . $this->_getNamer()->formatMethodName($key), 'docblock' => new Zend_CodeGenerator_Php_Docblock(array('tags' => array(new Zend_CodeGenerator_Php_Docblock_Tag_Param(array('paramName' => $key, 'dataType' => 'mixed')), array('name' => 'return', 'description' => $this->_getNamer()->formatClassName($this->_config->classname))))), 'parameters' => array(array('name' => $key)), 'body' => 'return $this->findOne(array(\'' . $key . ' = ?\' => $' . $key . '));')); } $modelTableBase = new Zend_CodeGenerator_Php_Class(array('name' => $className, 'docblock' => new Zend_CodeGenerator_Php_Docblock(array('shortDescription' => $className . PHP_EOL . '*DO NOT* edit this file.', 'tags' => array_merge($templates['tags']))), 'extendedClass' => 'Zend_Db_Table_Abstract', 'properties' => array(array('name' => '_name', 'visiblity' => 'protected', 'defaultValue' => $table->getName()), array('name' => '_primary', 'visiblity' => 'protected', 'defaultValue' => $table->getPrimary()), array('name' => '_dependantTables', 'visiblity' => 'protected', 'defaultValue' => $table->getDependantTables())), 'methods' => $methods)); $modelTableBaseFile = new Zend_CodeGenerator_Php_File(array('classes' => array($modelTableBase))); return $modelTableBaseFile->generate(); }
/** * getContents() * * @return string */ public function getContents() { $codeGenerator = new Zend_CodeGenerator_Php_File(array('body' => <<<EOS // Define path to application directory defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application')); // Define application environment defined('APPLICATION_ENV') || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'testing')); // Ensure library/ is on include_path set_include_path(implode(PATH_SEPARATOR, array( realpath(APPLICATION_PATH . '/../library'), get_include_path(), ))); Zend_Loader_Autoloader::getInstance(); EOS )); return $codeGenerator->generate(); }
public function indexAction() { $this->_helper->layout()->title = 'PHP Persistent Class Generator'; $form = new Form_ClassGenerator_Class(); if ($this->_request->isPost()) { $formData = $this->_request->getPost(); if ($form->isValid($formData)) { $formToClass = Model_ClassGenerator_FormToClass::createInstance($formData); $class = $formToClass->toClass(); $file = new Zend_CodeGenerator_Php_File(); if ($formData['class'][Model_ClassGenerator_FormToClass::$withPersistenceKey]) { $persistence = Model_ClassGenerator_Persistence::createInstance($class); $persistentClass = $persistence->createPersistence(); $file->setClass($persistentClass); } else { $file->setClass($class); } $this->view->resultCode = htmlentities($file->generate()); } else { $form->populate($formData); } } $this->view->form = $form; }
/** * Generate class * @return string generated source code */ public function generate() { $table = new ModelGenerator_Table_Table($this->_options['tableName']); $className = $this->_getNamer()->formatClassName($this->_config->base->classname); $templates = array('tags' => array()); foreach ($this->_options['docblock'] as $tag => $value) { $templates['tags'][] = array('name' => $tag, 'description' => $value); } //////////////////////////////////////////// // create model base //////////////////////////////////////////// $methods = array(); $properties = array(); $tmp = array(); foreach ($table->getProperties() as $property) { $tmp[] = array('name' => 'property', 'description' => $property['type'] . ' $' . $property['name'] . ' ' . $property['desc']); switch ($property['type']) { case 'string': $property['defaultValue'] = ''; break; case 'int': case 'float': case 'double': $property['defaultValue'] = null; break; default: $property['defaultValue'] = ''; break; } $properties[] = new Zend_CodeGenerator_Php_Property(array('name' => '_' . $property['name'], 'docblock' => new Zend_CodeGenerator_Php_Docblock(array('tags' => array(array('name' => 'var', 'description' => $property['type'])))), 'defaultValue' => $property['defaultValue'], 'visibility' => 'private')); // getters and setters if (false !== strpos($property['desc'], 'enum')) { $types = rtrim(str_replace(array('enum('), '', $property['desc']), ')'); $types = explode(',', $types); $typesImploded = implode(', ', $types); $enumBody = 'in_array($' . $property['name'] . ', array(' . $typesImploded . ')) ? $' . $property['name'] . ' : ' . $types[0]; $body = '$' . $property['name'] . ' = (' . $property['type'] . ') $' . $property['name'] . ';' . PHP_EOL . '$this->_' . $property['name'] . ' = ' . $enumBody . ';' . PHP_EOL . 'return $this;'; } else { $body = '$this->_' . $property['name'] . ' = (' . $property['type'] . ') $' . $property['name'] . ';' . PHP_EOL . 'return $this;'; } $methods[] = new Zend_CodeGenerator_Php_Method(array('name' => 'set' . $this->_getNamer()->formatMethodName($property['name']), 'docblock' => new Zend_CodeGenerator_Php_Docblock(array('shortDescription' => 'Set ' . $property['name'] . ' (' . $property['desc'] . ')', 'tags' => array(new Zend_CodeGenerator_Php_Docblock_Tag_Param(array('paramName' => $property['name'], 'dataType' => $property['type'])), array('name' => 'return', 'description' => $className)))), 'parameters' => array(array('name' => $property['name'])), 'body' => $body)); $methods[] = new Zend_CodeGenerator_Php_Method(array('name' => 'get' . $this->_getNamer()->formatMethodName($property['name']), 'docblock' => new Zend_CodeGenerator_Php_Docblock(array('shortDescription' => 'Get ' . $property['name'] . ' (' . $property['desc'] . ')', 'tags' => array(array('name' => 'return', 'description' => $property['type'])))), 'parameters' => array(), 'body' => 'return $this->_' . $property['name'] . ';')); } $toArrayBody[] = '$data = array('; foreach ($table->getProperties() as $property) { $toArrayBody[] = "\t" . '\'' . $property['name'] . '\' => $this->_' . $property['name'] . ','; } $toArrayBody[] = ');'; $toArrayBody[] = ''; $toArrayBody[] = 'return $data;'; $methods[] = new Zend_CodeGenerator_Php_Method(array('name' => 'toArray', 'docblock' => new Zend_CodeGenerator_Php_Docblock(array('shortDescription' => 'Convert entity properties to array and return it', 'tags' => array(array('name' => 'return', 'description' => 'array')))), 'parameters' => array(), 'body' => implode(PHP_EOL, $toArrayBody))); $modelBase = new Zend_CodeGenerator_Php_Class(array('name' => $className, 'docblock' => new Zend_CodeGenerator_Php_Docblock(array('shortDescription' => $className . PHP_EOL . '*DO NOT* edit this file.', 'tags' => array_merge($tmp, $templates['tags']))), 'methods' => $methods, 'properties' => $properties)); $modelBaseFile = new Zend_CodeGenerator_Php_File(array('classes' => array($modelBase))); return $modelBaseFile->generate(); }
/** * getContents() * * @return array */ public function getContents() { $codeGenFile = new Zend_CodeGenerator_Php_File(array('classes' => array(new Zend_CodeGenerator_Php_Class(array('name' => 'Bootstrap', 'extendedClass' => 'Zend_Application_Bootstrap_Bootstrap'))))); return $codeGenFile->generate(); }
/** * getContents() * * @return string */ public function getContents() { $filter = new Zend_Filter_Word_DashToCamelCase(); $className = $filter->filter($this->_forControllerName) . 'ControllerTest'; /* @var $controllerDirectoryResource Zend_Tool_Project_Profile_Resource */ $controllerDirectoryResource = $this->_resource->getParentResource(); if ($controllerDirectoryResource->getParentResource()->getName() == 'TestApplicationModuleDirectory') { $className = $filter->filter(ucfirst($controllerDirectoryResource->getParentResource()->getForModuleName())) . '_' . $className; } $codeGenFile = new Zend_CodeGenerator_Php_File(array('classes' => array(new Zend_CodeGenerator_Php_Class(array('name' => $className, 'extendedClass' => 'Zend_Test_PHPUnit_ControllerTestCase', 'methods' => array(new Zend_CodeGenerator_Php_Method(array('name' => 'setUp', 'body' => <<<EOS \$this->bootstrap = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini'); parent::setUp(); EOS )))))))); return $codeGenFile->generate(); }
} else { $index_template_replacements = array("OBJECT_NICENAME" => $name, "THEME_GLOBAL_PATH_VAR_NAME" => "theme_global_path", "CREATE_NEW_URL" => "/" . $module_name . "/" . strtolower($name) . "/edit", "ROWSET_VAR" => strtolower($name), "THE_ID" => $identity_col, "INDEX_URL" => $index_url); } $index_template = Bolts_Common::replaceWithArray($index_template, $index_template_replacements); file_put_contents($theme_dir . "/index.tpl", $index_template); // add delete method $delete_method = new Zend_CodeGenerator_Php_Method(); $delete_method_body = file_get_contents($basepath . "/modules/bolts/extras/crudify_templates/deleteAction.txt"); $delete_action_replacements = array("TABLE_OBJECT_VAR" => $table_object_var, "TABLE_CLASSNAME" => $object_name, "ROW_OBJECT_VAR" => $row_object_var, "THE_ID" => $identity_col, "OBJECT_NICENAME" => $name, "ROWSET_VAR" => strtolower($name), "DELETE_URL" => $delete_url, "INDEX_URL" => $index_url); $delete_method_body = Bolts_Common::replaceWithArray($delete_method_body, $delete_action_replacements); $delete_method->setName('deleteAction')->setBody($delete_method_body); $controller_class->setMethod($delete_method); // load delete template $delete_template = file_get_contents($basepath . "/modules/bolts/extras/crudify_templates/delete.tpl"); if ($is_admin) { $delete_template_replacements = array("OBJECT_NICENAME" => $name, "THEME_GLOBAL_PATH_VAR_NAME" => "admin_theme_global_path", "CREATE_NEW_URL" => "/" . $module_name . "/" . strtolower($name) . "admin/edit", "ROWSET_VAR" => strtolower($name), "THE_ID" => $identity_col, "DELETE_URL" => $delete_url, "INDEX_URL" => $index_url); } else { $delete_template_replacements = array("OBJECT_NICENAME" => $name, "THEME_GLOBAL_PATH_VAR_NAME" => "theme_global_path", "CREATE_NEW_URL" => "/" . $module_name . "/" . strtolower($name) . "/edit", "ROWSET_VAR" => strtolower($name), "THE_ID" => $identity_col, "DELETE_URL" => $delete_url, "INDEX_URL" => $index_url); } $delete_template = Bolts_Common::replaceWithArray($delete_template, $delete_template_replacements); file_put_contents($theme_dir . "/delete.tpl", $delete_template); $controller_file = new Zend_CodeGenerator_Php_File(); $controller_file->setClass($controller_class); } // Render the generated files file_put_contents($basepath . "/modules/" . $module_name . "/models/" . $object_name . ".php", $model_file->generate()); if ($is_admin) { file_put_contents($basepath . "/modules/" . $module_name . "/controllers/" . $name . "adminController.php", $controller_file->generate()); } else { file_put_contents($basepath . "/modules/" . $module_name . "/controllers/" . $name . "Controller.php", $controller_file->generate()); }
/** * getContents() * * @return string */ public function getContents() { $filter = new Zend_Filter_Word_DashToCamelCase(); $className = $filter->filter($this->_projectProviderName) . 'Provider'; $class = new Zend_CodeGenerator_Php_Class(array('name' => $className, 'extendedClass' => 'Zend_Tool_Project_Provider_Abstract')); $methods = array(); foreach ($this->_actionNames as $actionName) { $methods[] = new Zend_CodeGenerator_Php_Method(array('name' => $actionName, 'body' => ' /** @todo Implementation */')); } if ($methods) { $class->setMethods($methods); } $codeGenFile = new Zend_CodeGenerator_Php_File(array('requiredFiles' => array('Zend/Tool/Project/Provider/Abstract.php', 'Zend/Tool/Project/Provider/Exception.php'), 'classes' => array($class))); return $codeGenFile->generate(); }
function gen($module, $controllerClassName, $label, $extendController, $defaultModel) { ini_set('display_errors', 1); // $xml = App_Model_Config::getConfigFilePath($package) ;// APPLICATION_PATH . '/configs/' . $package . '-model-config.xml'; // $configFileName = basename($xml); // $data = $config = new Zend_Config_Xml($xml, 'production'); // $classList = $data->classes; // $project = $data->project; //$createPackageFolder = true; //$destinationFolder = $data->destinationDirectory; if ('application' == $project) { $createPackageFolder = false; $destinationFolder = APPLICATION_PATH . "/" . $destinationFolder; } elseif ('global' == $project) { $createPackageFolder = true; $destinationFolder = GLOBAL_PROJECT_PATH . "/" . $destinationFolder; } else { $createPackageFolder = true; $destinationFolder = realpath(APPLICATION_PATH . "/../library"); } $class = new Zend_CodeGenerator_Php_Class(); // $class->setAbstract(true); $docblock = new Zend_CodeGenerator_Php_Docblock(array('shortDescription' => $modelName, 'longDescription' => 'This is a class generated with Zend_CodeGenerator.', 'tags' => array(array('name' => 'uses', 'description' => $extendController), array('name' => 'package', 'description' => $package), array('name' => 'subpackage', 'description' => 'Model'), array('name' => 'version', 'description' => '$Rev:$'), array('name' => 'update', 'description' => date('d/m/Y')), array('name' => 'license', 'description' => 'licensed By Patiwat Wisedsukol patiwat.wi@gmail.com')))); //$docblock2 = new Zend_CodeGenerator_Php_Docblock(); $class->setDocblock($docblock); $moduleClassName = ucfirst(preg_replace("/\\-(.)/e", "strtoupper('\\1')", $module)); $className = "{$moduleClassName}_{$controllerClassName}Controller"; $class->setName($className); if ($extendController != '') { $class->setExtendedClass($extendController); } if (trim($defaultModel) != '') { //protected $_model = 'Hrm_Model_Personal'; $Prop[] = array('name' => "_model", 'visibility' => 'protected', 'defaultValue' => $defaultModel); $class->setProperties($Prop); } $structure = APPLICATION_PATH . "/modules/" . $module . "/controllers/" . $controllerClassName . "Controller.php"; $tmp = explode("", $destinationFolder); // foreach (){ // } $controllerClassName2 = strtolower(preg_replace('/(?<=\\w)(?=[A-Z])/', "-\$1", $controllerClassName)); $structureView = APPLICATION_PATH . "/modules/" . $module . "/views/scripts/" . $controllerClassName2; if (file_exists($structure)) { print "The file {$structure} exists<br/>"; } else { print "The file {$structure} does not exist<br/>"; echo "<br/>"; $file = new Zend_CodeGenerator_Php_File(); $file->setClass($class); //mkdir($structure, 0777, true); file_put_contents($structure, $this->filecontentfix($file->generate())); mkdir($structureView, 0, true); $objFopen = fopen($structureView . "/index.phtml", "w"); fwrite($objFopen, "Index View"); fclose($objFopen); echo "create [ ", $structure, " ] complete <br/>"; } }
/** * * @param string $pAction * @return string */ public function create_action($pAction = NULL, $pParams = NULL) { $action = $pAction ? $pAction : $this->get_action(); if ($pParams && array_key_exists('view_body', $pParams)) { $view_body = $pParams['view_body']; unset($pParams['view_body']); } else { $view_body = ''; if ($pParams && is_array($pParams) && count($pParams)) { foreach ($pParams as $param) { if (is_array($param)) { list($name, $alias, $default) = $param; $default = trim($default); } elseif (!trim($param)) { continue; } else { $name = $alias = trim($param); $default = NULL; } $name = trim($name); if (!$name) { continue; } ob_start(); ?> $this-><?php echo $name; ?> ; <?php $view_body .= ob_get_clean(); } } } $file = $this->controller_reflection(); $c = $file->getClass($this->controller_class_name()); $aname = "{$action}Action"; $class = Zend_CodeGenerator_Php_Class::fromReflection($c); if (!$class->hasMethod($aname)) { $body = ''; $reflect = ''; if ($pParams && is_array($pParams) && count($pParams)) { ob_start(); foreach ($pParams as $param) { if (!trim($param)) { continue; } elseif (is_array($param)) { list($name, $alias, $default) = $param; $default = trim($default); } else { $name = $alias = trim($param); $default = NULL; } $name = trim($name); if (!$name) { continue; } printf('$%s = $this->_getParam("%s", %s); ', $name, $alias, is_null($default) ? ' NULL ' : "'{$default}'"); ob_start(); printf('$this->view->%s = $%s;', $name, $name); ?> <?php $reflect .= ob_get_clean(); ?> <?php } $body = ob_get_clean() . "\n" . $reflect; } $old = $this->backup_controller(); $method = new Zend_CodeGenerator_Php_Method(); $method->setName($aname)->setBody($body); $class->setMethod($method); $file = new Zend_CodeGenerator_Php_File(); $file->setClass($class); $new_file = preg_replace('~[\\r\\n][\\s]*[\\r\\n]~', "\r", $file->generate()); file_put_contents($this->controller_path(), $new_file); $view_path = $this->view_path($action); if (!file_exists($view_path)) { $dir = dirname($view_path); if (!is_dir($dir)) { mkdir($dir, 0775, TRUE); } file_put_contents($view_path, "<?\n\$this->placeholder('page_title')->set('');\n{$view_body}\n"); } $exec = "diff {$this->_backup_path} {$this->controller_path()} "; $diff = shell_exec($exec); return array('old' => $old, 'new' => $new_file, 'diff' => $diff, 'backup_path' => $this->_backup_path, 'controller_path' => $this->controller_path()); } }
public function getContents() { $className = $this->getFullClassName($this->_dbTableName, 'Model_DbTable'); $codeGenFile = new Zend_CodeGenerator_Php_File(array('fileName' => $this->getPath(), 'classes' => array(new Zend_CodeGenerator_Php_Class(array('name' => $className, 'extendedClass' => 'Zend_Db_Table_Abstract', 'properties' => array(new Zend_CodeGenerator_Php_Property(array('name' => '_name', 'visibility' => Zend_CodeGenerator_Php_Property::VISIBILITY_PROTECTED, 'defaultValue' => $this->_actualTableName)))))))); return $codeGenFile->generate(); }
/** * Creates contets for this table * * @see Zend_Tool_Project_Context_Filesystem_File::getContents() */ public function getContents() { $className = ucfirst($this->_tableName); $codeGenFile = new Zend_CodeGenerator_Php_File(array('fileName' => $this->getPath(), 'classes' => array(new Zend_CodeGenerator_Php_Class(array('name' => 'App_Table_' . $className, 'extendedClass' => 'App_Table'))))); return $codeGenFile->generate(); }
public function getContents() { $codeGenFile = new Zend_CodeGenerator_Php_File(array('fileName' => $this->getPath(), 'classes' => array($this->getModelClass()))); return $codeGenFile->generate(); }
function gen($package) { ini_set('display_errors', 1); $xml = App_Model_Config::getConfigFilePath($package); // APPLICATION_PATH . '/configs/' . $package . '-model-config.xml'; $configFileName = basename($xml); $data = $config = new Zend_Config_Xml($xml, 'production'); $classList = $data->classes; $project = $data->project; $createPackageFolder = true; $destinationFolder = $data->destinationDirectory; if ('application' == $project) { $createPackageFolder = false; $destinationFolder = APPLICATION_PATH . "/" . $destinationFolder; } elseif ('global' == $project) { $createPackageFolder = true; $destinationFolder = GLOBAL_PROJECT_PATH . "/" . $destinationFolder; } else { $createPackageFolder = true; $destinationFolder = realpath(APPLICATION_PATH . "/../library"); } // die($destinationFolder); $bodyConstruct = ''; foreach ($classList as $modelName => $attr) { $class = new Zend_CodeGenerator_Php_Class(); //$class->isAbstract(); $class->setAbstract(true); $class2 = new Zend_CodeGenerator_Php_Class(); $docblock = new Zend_CodeGenerator_Php_Docblock(array('shortDescription' => $modelName, 'longDescription' => 'This is a class generated with Zend_CodeGenerator.', 'tags' => array(array('name' => 'uses', 'description' => $package . '_Model_Abstract'), array('name' => 'package', 'description' => $package), array('name' => 'subpackage', 'description' => 'Model'), array('name' => 'version', 'description' => '$Rev:$'), array('name' => 'update', 'description' => date('d/m/Y')), array('name' => 'license', 'description' => 'licensed By Patiwat Wisedsukol patiwat.wi@gmail.com')))); //$docblock2 = new Zend_CodeGenerator_Php_Docblock(); echo "create ", $modelName, "<br/>"; $class->setName($modelName . "_Abstract"); $class2->setName($modelName); if ('' == trim($attr->extendedClass)) { $class->setExtendedClass($package . '_Model_Abstract'); } else { $class->setExtendedClass($attr->extendedClass); } $class2->setExtendedClass($modelName . '_Abstract'); $Prop = array(); $Methods = array(); $PropertyData = array(); $columsToPropsList = array(); $propsToColumsList = array(); foreach ($attr->prop as $prop) { $name = $prop->name; $Prop[] = array('name' => "_" . $name, 'visibility' => 'protected', 'defaultValue' => null); $pdata = array(); $PropertyData[$name] = $this->process_data_array($prop); $columsToPropsList[$prop->column] = $prop->name; $propsToColumsList[$prop->name] = $prop->column; $Methods[] = $name; } // print_r($PropertyData); // exit(); $PropertyDataString = $this->gen_array($PropertyData); //$p = new Zend_CodeGenerator_Php_Property_DefaultValue(array('value'=>$PropertyDataString ,'type'=>Zend_CodeGenerator_Php_Property_DefaultValue::TYPE_ARRAY)); $Prop[] = array('name' => "propertyData", 'visibility' => 'public', 'defaultValue' => $PropertyDataString); if (isset($attr->config)) { $configDataString = $this->gen_array($attr->config->toArray()); } else { $configDataString = null; } $Prop[] = array('name' => "CONFIG_FILE_NAME", 'visibility' => 'public', 'const' => true, 'defaultValue' => $configFileName); $Prop[] = array('name' => "COLUMS_TO_PROPS_LIST", 'visibility' => 'public', 'defaultValue' => $this->gen_array($columsToPropsList)); $Prop[] = array('name' => "PROPS_TO_COLUMS_LIST", 'visibility' => 'public', 'defaultValue' => $this->gen_array($propsToColumsList)); $Prop[] = array('name' => "configData", 'visibility' => 'public', 'defaultValue' => $configDataString); $configSQLString = isset($attr->config->sql) ? (string) $attr->config->sql : ''; $Prop[] = array('name' => "_baseSQL", 'visibility' => 'public', 'defaultValue' => $configSQLString); $class->setDocblock($docblock); $class->setProperties($Prop); /* $Property = new Zend_CodeGenerator_Php_Property(); $pv = new Zend_CodeGenerator_Php_Property_DefaultValue($PropertyDataString); $pv->setType(Zend_CodeGenerator_Php_Property_DefaultValue::TYPE_ARRAY); $Property->setDefaultValue($pv); $Property->setName('_propertyData'); $class->setProperty($Property); */ $method = new Zend_CodeGenerator_Php_Method(); $method->setName('__construct'); $method->setBody("parent::__construct ( \$options, '{$modelName}');"); $method->setParameters(array(array('name' => 'options', 'type' => 'array', 'defaultValue' => null))); $class->setMethod($method); foreach ($Methods as $name) { $method = new Zend_CodeGenerator_Php_Method(); $method->setName('set' . strtoupper(substr($name, 0, 1)) . substr($name, 1, strlen($name))); $method->setBody(" \n \n\t\t \$this->_{$name} = \${$name}; \n\n\t\treturn \$this; \n "); $method->setParameter(array('name' => $name)); $docblock = new Zend_CodeGenerator_Php_Docblock(array('shortDescription' => "Set the {$name} property", 'tags' => array(array('name' => 'param', 'description' => "\${$name} the \${$name} to set"), array('name' => 'return', 'description' => $modelName)))); $method->setDocblock($docblock); $class->setMethod($method); } foreach ($Methods as $name) { $method = new Zend_CodeGenerator_Php_Method(); $method->setName('get' . strtoupper(substr($name, 0, 1)) . substr($name, 1, strlen($name))); $method->setBody(" \n \n\t\treturn \$this->_{$name}; \n\n\t\t\n\t\t"); $docblock = new Zend_CodeGenerator_Php_Docblock(array('shortDescription' => "get the {$name} property", 'tags' => array(array('name' => 'return', 'description' => "the {$name}")))); $method->setDocblock($docblock); $class->setMethod($method); } $method = new Zend_CodeGenerator_Php_Method(); $method->setParameter(array('name' => 'id')); $method->setStatic(true); $method->setName('getObjectByID'); $method->setBody("\n \n \n \$obj = new {$modelName}();\n\t\t \n \$obj->find(\$id);\n\t\t \n return \$obj;\n\t\t "); $docblock = new Zend_CodeGenerator_Php_Docblock(array('shortDescription' => "get Singleton {$modelName}", 'tags' => array(array('name' => 'return', 'description' => "{$modelName}")))); $method->setDocblock($docblock); $class->setMethod($method); ////////////Gen Method Form Config///////////////// $tostringCreated = false; if (isset($attr->method->name)) { $this->addMethod($attr->method, $class); } else { if (is_array($attr->method)) { foreach ($attr->method as $methodConfig) { $this->addMethod($methodConfig, $class); } } } //ถ้ายังไม่มี __tostrint จะ เพิ่มให้ แต่จะ return ค่าว่าง if (false == $this->_isTostringCreated()) { $method = new Zend_CodeGenerator_Php_Method(); $method->setName('__toString'); $method->setBody("\n\n\t\t \n return '';\n\t\t "); $class->setMethod($method); } ///////////////////////END GEN METHOD/////////////////////////////// $file = new Zend_CodeGenerator_Php_File(); $file->setClass($class); $package = ucfirst(strtolower($package)); // Acc/Model/ if (false == $createPackageFolder) { $modelPath = str_replace(ucfirst(strtolower($package)) . "_Model_", "", $modelName); } else { $modelPath = $modelName; } $modelPath = str_replace("_", "/", $modelPath); //$structure = dirname ( __FILE__ )."/{$modelName}"; echo $destinationFolder . "/" . $modelPath; $structure = realpath($destinationFolder) . "/" . $modelPath; //"D:\workspaces\privatework\jiranan\private\library/"."/{$modelName}"; if (!is_dir($structure)) { mkdir($structure, 0777, true); } $filecontent = $this->filecontentfix($file->generate()); file_put_contents($structure . "/Abstract.php", $filecontent); echo "create [ ", $structure, "/Abstract.php ] complete <br/>"; // $structure2 = dirname ( __FILE__ )."/".$modelName.".php"; $structure2 = realpath($destinationFolder) . "/{$modelPath}.php"; //"D:\workspaces\privatework\jiranan\private\library/".$modelName.".php"; // echo file_exists ($structure2 ==true)? 'true' : 'false'; echo "<br/>"; if (file_exists($structure2)) { print "The file {$structure2} exists<br/>"; } else { print "The file {$structure2} does not exist<br/>"; echo "<br/>"; $file2 = new Zend_CodeGenerator_Php_File(); $file2->setClass($class2); //mkdir($structure, 0777, true); file_put_contents($structure2, $this->filecontentfix($file2->generate())); echo "create [ ", $structure2, " ] complete <br/>"; } echo "===================================================<br/>"; } // Render the generated file //echo $file; }
public function getContents() { $className = $this->getFullClassName($this->_modelName, 'Model'); $codeGenFile = new Zend_CodeGenerator_Php_File(array('fileName' => $this->getPath(), 'classes' => array(new Zend_CodeGenerator_Php_Class(array('name' => $className))))); return $codeGenFile->generate(); }
/** * @return string */ public function getContents() { $classMapperName = $this->getFullClassName($this->_modelName, 'Model_Mapper'); $className = $this->getFullClassName($this->_modelName, 'Model'); $classDbTableName = $this->getFullClassName($this->_modelName, 'Model_DbTable'); $codeGenFile = new Zend_CodeGenerator_Php_File(array('fileName' => $this->getPath(), 'classes' => array(new Zend_CodeGenerator_Php_Class(array('name' => $classMapperName, 'properties' => array(array('name' => '_dbTable', 'visibility' => 'protected')), 'methods' => array(new Zend_CodeGenerator_Php_Method(array('name' => 'setDbTable', 'parameters' => array(array('name' => 'dbTable')), 'body' => 'if (is_string($dbTable))' . "\n\t" . '$dbTable = new $dbTable();' . "\n\n" . 'if (!$dbTable instanceof Zend_Db_Table_Abstract)' . "\n\t" . 'throw new Exception(\'Invalid table data gateway provided\');' . "\n\n" . '$this->_dbTable = $dbTable;' . "\n\n" . 'return $this;', 'docblock' => new Zend_CodeGenerator_Php_Docblock(array('tags' => array(array('name' => 'param', 'description' => '$dbTable'), array('name' => 'return', 'description' => '$this'), array('name' => 'throws', 'description' => 'Exception')))))), new Zend_CodeGenerator_Php_Method(array('name' => 'getDbTable', 'body' => 'if (null === $this->_dbTable)' . "\n\t" . '$this->setDbTable(\'' . $classDbTableName . '\');' . "\n\n" . 'return $this->_dbTable;', 'docblock' => new Zend_CodeGenerator_Php_Docblock(array('tags' => array(array('name' => 'return', 'description' => $classDbTableName)))))), new Zend_CodeGenerator_Php_Method(array('name' => 'save', 'parameters' => array(array('name' => strtolower($this->_modelName), 'type' => $className)), 'body' => '$data = $this->_getDbData($' . strtolower($this->_modelName) . ');' . "\n\n" . 'if (null == ($id = $' . strtolower($this->_modelName) . '->getId())) {' . "\n\t" . 'unset($data[$this->_getDbPrimary()]);' . "\n\t" . '$this->getDbTable()->insert($data);' . "\n" . '} else {' . "\n\t" . '$this->getDbTable()->update($data, array($this->_getDbPrimary(). \' = ?\' => $id));' . "\n" . '}' . "\n\n" . 'return $this;', 'docblock' => new Zend_CodeGenerator_Php_Docblock(array('tags' => array(array('name' => 'param', 'description' => $className . ' $' . strtolower($this->_modelName)), array('name' => 'return', 'description' => '$this')))))), new Zend_CodeGenerator_Php_Method(array('name' => 'find', 'parameters' => array(array('name' => 'id'), array('name' => strtolower($this->_modelName), 'type' => $className)), 'body' => '$result = $this->getDbTable()->find($id);' . "\n\n" . 'if (0 == count($result)) {' . "\n\t" . 'return null;' . "\n" . '}' . "\n\n" . '$row = $result->current();' . "\n" . '$entry = $this->_setDbData($row, $' . strtolower($this->_modelName) . ');' . "\n\n" . 'return $entry;', 'docblock' => new Zend_CodeGenerator_Php_Docblock(array('tags' => array(array('name' => 'param', 'description' => '$id'), array('name' => 'param', 'description' => $className . ' $' . strtolower($this->_modelName)), array('name' => 'return', 'description' => $className . '|null')))))), new Zend_CodeGenerator_Php_Method(array('name' => 'fetchAll', 'parameters' => array(array('name' => 'select', 'defaultValue' => null)), 'body' => '$resultSet = $this->getDbTable()->fetchAll($select);' . "\n\n" . '$entries = array();' . "\n" . 'foreach ($resultSet as $row) {' . "\n\t" . '$entry = new ' . $className . '();' . "\n\t" . '$entry = $this->_setDbData($row, $entry);' . "\n\t" . '$entries[] = $entry;' . "\n" . '}' . "\n\n" . 'return $entries;', 'docblock' => new Zend_CodeGenerator_Php_Docblock(array('tags' => array(array('name' => 'param', 'description' => 'null $select'), array('name' => 'return', 'description' => 'array')))))), new Zend_CodeGenerator_Php_Method(array('name' => '_getDbPrimary', 'visibility' => 'protected', 'body' => '$primaryKey = $this->getDbTable()->info(\'primary\');' . "\n\n" . 'return $primaryKey[1];', 'docblock' => new Zend_CodeGenerator_Php_Docblock(array('tags' => array(array('name' => 'return', 'description' => 'mixed')))))), new Zend_CodeGenerator_Php_Method(array('name' => '_getDbData', 'parameters' => array(array('name' => strtolower($this->_modelName), 'type' => $className)), 'visibility' => 'protected', 'body' => '$info = $this->getDbTable()->info();' . "\n" . '$properties = $info[\'cols\'];' . "\n\n" . '$data = array();' . "\n" . 'foreach ($properties as $property) {' . "\n\t" . '$name = $this->_normaliseName($property);' . "\n\n\t" . 'if($property != $this->_getDbPrimary())' . "\n\t\t" . '$data[$property] = $' . strtolower($this->_modelName) . '->__get($name);' . "\n" . '}' . "\n\n" . 'return $data;', 'docblock' => new Zend_CodeGenerator_Php_Docblock(array('tags' => array(array('name' => 'param', 'description' => $className . ' $' . strtolower($this->_modelName)), array('name' => 'return', 'description' => 'array')))))), new Zend_CodeGenerator_Php_Method(array('name' => '_setDbData', 'parameters' => array(array('name' => 'row'), array('name' => 'entry', 'type' => $className)), 'visibility' => 'protected', 'body' => '$info = $this->getDbTable()->info();' . "\n" . '$properties = $info[\'cols\'];' . "\n\n" . 'foreach ($properties as $property) {' . "\n\t" . '$entry->__set($this->_normaliseName($property), $row->$property);' . "\n" . '}' . "\n\n" . 'return $entry;', 'docblock' => new Zend_CodeGenerator_Php_Docblock(array('tags' => array(array('name' => 'param', 'description' => 'Zend_Db_Table_Rowset $row'), array('name' => 'param', 'description' => $className . ' $entry'), array('name' => 'return', 'description' => $className)))))), new Zend_CodeGenerator_Php_Method(array('name' => '_normaliseName', 'parameters' => array(array('name' => 'property')), 'visibility' => 'protected', 'body' => '$name = preg_split(\'~_~\', $property);' . "\n" . '$normaliseName = implode(array_map(\'ucwords\', $name));' . "\n\n" . 'return $normaliseName;', 'docblock' => new Zend_CodeGenerator_Php_Docblock(array('tags' => array(array('name' => 'param', 'description' => '$property string'), array('name' => 'return', 'description' => 'string')))))))))))); return $codeGenFile->generate(); }
/** * Create (or modify) given class * * @param string $className * @param Zend_CodeGenerator_Php_Class $class * * @return Zend_CodeGenerator_Php_Class */ public static function create($className, Zend_CodeGenerator_Php_Class $class = null) { // If no class data is given and the class already exists there's no point in "creating" it if ($class == null and XDT_CLI_Helper::classExists($className)) { return self::get($className); } // Only create class if the file is available or we have class data $filePath = self::getClassPath($className); $fileContents = file_exists($filePath) ? file_get_contents($filePath) : false; if (empty($fileContents) or $class != null) { // Load blank CodeGenerator file $file = new Zend_CodeGenerator_Php_File(); // Create CodeGenerato Class if it wasn't provided as a parm if ($class == null) { $class = new Zend_CodeGenerator_Php_Class(); $class->setName($className); } // Append class to file $file->setClass($class); // Write to file XDT_CLI_Helper::writeToFile($filePath, $file->generate(), true); XDT_CLI_Abstract::getInstance()->printMessage("File: " . $filePath); } else { XDT_CLI_Abstract::getInstance()->bail("File already exists: " . $filePath); } return self::get($className); }
/** * */ public function create_form() { $data = Zend_Db_Table::getDefaultAdapter()->describeTable($this->get_table()); ob_start(); ?> $ini_path = preg_replace('~php$~', 'ini', __FILE__); $config = new Zend_Config_Ini($ini_path, 'fields'); parent::__construct($config); if ($pDomain): $this->set_domain($pDomain); $this->domain_to_fields(); endif; <?php $body = ob_get_clean(); $construct = new Zend_CodeGenerator_Php_Method(array('name' => '__construct', 'body' => $body, 'visibility' => 'public', 'parameters' => array(new Zend_CodeGenerator_Php_Parameter(array('name' => 'pDomain', 'defaultValue' => 0))))); $body = ''; foreach (array_keys($data) as $field) { $body .= '$this->dtf("' . $field . '");' . "\n"; } $body = 'return array("' . join('","', array_keys($data)) . '");'; $domain_fields = new Zend_CodeGenerator_Php_Method(array('name' => 'domain_fields', 'body' => $body, 'visibility' => 'public')); $get_domain_class = new Zend_CodeGenerator_Php_Method(array('name' => 'get_domain_class', 'body' => 'return "' . $this->domain_class() . '";', 'visibility' => 'protected')); $file = new Zend_CodeGenerator_Php_File(array('classes' => array(new Zend_CodeGenerator_Php_Class(array('name' => $this->form_class(), 'extendedClass' => 'Zupal_Form_Abstract', 'methods' => array($construct, $domain_fields, $get_domain_class)))))); $this->set_form_code($file->generate()); file_put_contents($this->get_form_path(), $this->get_form_code()); }
public function getContents() { $className = $this->getFullClassName($this->_formName, 'Form'); $codeGenFile = new Zend_CodeGenerator_Php_File(array('fileName' => $this->getPath(), 'classes' => array(new Zend_CodeGenerator_Php_Class(array('name' => $className, 'extendedClass' => 'Zend_Form', 'methods' => array(new Zend_CodeGenerator_Php_Method(array('name' => 'init', 'body' => '/* Form Elements & Other Definitions Here ... */')))))))); return $codeGenFile->generate(); }
/** * Generate the action * * This is a gigantic method used to generate the actual Action code. It * uses the properties, description, name, and routes passed to it. * * This method uses the Zend_CodeGenerator_Php_* family to identify and create the * new files. * * @param string $name The name of the action * @param array $properties An array of properties related to an action * @param string $description A description for an action. Default false. * @param string $route The custom route for that action. Default false. * * @return string A generated file. */ private function generateAction($name, $properties, $description = false, $route = false) { $docblock = new Zend_CodeGenerator_Php_Docblock(array('shortDescription' => 'Required parameters', 'tags' => array(new Zend_CodeGenerator_Php_Docblock_Tag(array('name' => 'var', 'datatype' => 'array', 'description' => 'An array of required parameters.'))))); $class = new Zend_CodeGenerator_Php_Class(); $class->setName('Action_' . $name); $class->setExtendedClass('Frapi_Action'); $class->setImplementedInterfaces(array('Frapi_Action_Interface')); $tags = array(array('name' => 'link', 'description' => 'http://getfrapi.com'), array('name' => 'author', 'description' => 'Frapi <*****@*****.**>')); if ($route !== false) { $tags[] = array('name' => 'link', 'description' => $route); } $classDocblock = new Zend_CodeGenerator_Php_Docblock(array('shortDescription' => 'Action ' . $name . ' ', 'longDescription' => $description !== false ? $description : 'A class generated by Frapi', 'tags' => $tags)); $class->setDocblock($classDocblock); $class->setProperties(array(array('name' => 'requiredParams', 'visibility' => 'protected', 'defaultValue' => $properties, 'docblock' => $docblock), array('name' => 'data', 'visibility' => 'private', 'defaultValue' => array(), 'docblock' => new Zend_CodeGenerator_Php_Docblock(array('shortDescription' => 'The data container to use in toArray()', 'tags' => array(new Zend_CodeGenerator_Php_Docblock_Tag(array('name' => 'var', 'datatype' => 'array', 'description' => 'A container of data to fill and return in toArray()')))))))); $methods = array(); $docblock = new Zend_CodeGenerator_Php_Docblock(array('shortDescription' => 'To Array', 'longDescription' => "This method returns the value found in the database \n" . 'into an associative array.', 'tags' => array(new Zend_CodeGenerator_Php_Docblock_Tag_Return(array('datatype' => 'array'))))); $toArrayBody = ' ' . "\n"; if (!empty($properties)) { foreach ($properties as $p) { $toArrayBody .= '$this->data[\'' . $p . '\'] = ' . '$this->getParam(\'' . $p . '\', self::TYPE_OUTPUT);' . "\n"; } } $toArrayBody .= 'return $this->data;'; $methods[] = new Zend_CodeGenerator_Php_Method(array('name' => 'toArray', 'body' => $toArrayBody, 'docblock' => $docblock)); $executeActionBody = ''; if (!empty($properties)) { $executeActionBody = ' $valid = $this->hasRequiredParameters($this->requiredParams); if ($valid instanceof Frapi_Error) { return $valid; }'; } $executeActionBody .= "\n\n" . 'return $this->toArray();'; $docblockArray = array('shortDescription' => '', 'longDescription' => '', 'tags' => array(new Zend_CodeGenerator_Php_Docblock_Tag_Return(array('datatype' => 'array')))); $docblock = new Zend_CodeGenerator_Php_Docblock(array()); $docblockArray['shortDescription'] = 'Default Call Method'; $docblockArray['longDescription'] = 'This method is called when no specific ' . 'request handler has been found'; $methods[] = new Zend_CodeGenerator_Php_Method(array('name' => 'executeAction', 'body' => $executeActionBody, 'docblock' => $docblockArray)); $docblockArray['shortDescription'] = 'Get Request Handler'; $docblockArray['longDescription'] = 'This method is called when a request is a GET'; $methods[] = new Zend_CodeGenerator_Php_Method(array('name' => 'executeGet', 'body' => $executeActionBody, 'docblock' => $docblockArray)); $docblockArray['shortDescription'] = 'Post Request Handler'; $docblockArray['longDescription'] = 'This method is called when a request is a POST'; $methods[] = new Zend_CodeGenerator_Php_Method(array('name' => 'executePost', 'body' => $executeActionBody, 'docblock' => $docblockArray)); $docblockArray['shortDescription'] = 'Put Request Handler'; $docblockArray['longDescription'] = 'This method is called when a request is a PUT'; $methods[] = new Zend_CodeGenerator_Php_Method(array('name' => 'executePut', 'body' => $executeActionBody, 'docblock' => $docblockArray)); $docblockArray['shortDescription'] = 'Delete Request Handler'; $docblockArray['longDescription'] = 'This method is called when a request is a DELETE'; $methods[] = new Zend_CodeGenerator_Php_Method(array('name' => 'executeDelete', 'body' => $executeActionBody, 'docblock' => $docblockArray)); $docblockArray['shortDescription'] = 'Head Request Handler'; $docblockArray['longDescription'] = 'This method is called when a request is a HEAD'; $methods[] = new Zend_CodeGenerator_Php_Method(array('name' => 'executeHead', 'body' => $executeActionBody, 'docblock' => $docblockArray)); $class->setMethods($methods); $file = new Zend_CodeGenerator_Php_File(); $file->setClass($class); return $file->generate(); }
public function getContents() { $className = 'Myth_' . ucfirst(strtolower($this->_mythName)); $codeGenFile = new Zend_CodeGenerator_Php_File(array('fileName' => $this->getPath(), 'classes' => array(new Zend_CodeGenerator_Php_Class(array('name' => $className, 'methods' => array(new Zend_CodeGenerator_Php_Method(array('name' => '__construct', 'body' => '/* Myth Here ... */')))))))); return $codeGenFile->generate(); }