当前位置: 首页>>代码示例>>PHP>>正文


PHP Zend_CodeGenerator_Php_File::generate方法代码示例

本文整理汇总了PHP中Zend_CodeGenerator_Php_File::generate方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_CodeGenerator_Php_File::generate方法的具体用法?PHP Zend_CodeGenerator_Php_File::generate怎么用?PHP Zend_CodeGenerator_Php_File::generate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend_CodeGenerator_Php_File的用法示例。


在下文中一共展示了Zend_CodeGenerator_Php_File::generate方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getContents

 /**
  * 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();
 }
开发者ID:omusico,项目名称:logica,代码行数:12,代码来源:ZfsFormFile.php

示例2: getContents

 /**
  * 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();
 }
开发者ID:travisj,项目名称:zf,代码行数:12,代码来源:TestApplicationControllerFile.php

示例3: getContents

 /**
  * 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();
 }
开发者ID:omusico,项目名称:logica,代码行数:12,代码来源:ZfsModelFile.php

示例4: scaffold

 public function scaffold()
 {
     $form = $this->_getForm();
     $file = new Zend_CodeGenerator_Php_File();
     $file->setClass($form);
     return $file->generate();
 }
开发者ID:nuxwin,项目名称:losolib,代码行数:7,代码来源:Form.php

示例5: getContents

    /**
     * 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();
    }
开发者ID:hjr3,项目名称:zf2,代码行数:36,代码来源:PublicIndexFile.php

示例6: getContents

 /**
  * 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();
 }
开发者ID:phpspec,项目名称:phpspec-zend,代码行数:13,代码来源:ModelFile.php

示例7: testFromReflection

 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);
 }
开发者ID:crodriguezn,项目名称:crossfit-milagro,代码行数:11,代码来源:FileTest.php

示例8: 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->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();
 }
开发者ID:redpmorg,项目名称:Zend-Model-Generator,代码行数:17,代码来源:Model.php

示例9: getContents

 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();
 }
开发者ID:uglide,项目名称:zfcore-transition,代码行数:14,代码来源:MigrationFile.php

示例10: 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();
 }
开发者ID:redpmorg,项目名称:Zend-Model-Generator,代码行数:21,代码来源:BaseMapper.php

示例11: getContents

    /**
     * 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();
    }
开发者ID:NerdGZ,项目名称:icingaweb2,代码行数:28,代码来源:TestPHPUnitBootstrapFile.php

示例12: indexAction

 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;
 }
开发者ID:JPustkuchen,项目名称:phppcg,代码行数:24,代码来源:IndexController.php

示例13: 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->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();
 }
开发者ID:redpmorg,项目名称:Zend-Model-Generator,代码行数:59,代码来源:BaseModel.php

示例14: getContents

 /**
  * 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();
 }
开发者ID:c12g,项目名称:stratos-php,代码行数:10,代码来源:BootstrapFile.php

示例15: getContents

    /**
     * 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();
    }
开发者ID:NerdGZ,项目名称:icingaweb2,代码行数:21,代码来源:TestApplicationControllerFile.php


注:本文中的Zend_CodeGenerator_Php_File::generate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。