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


PHP Zend_CodeGenerator_Php_File类代码示例

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


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

示例1: 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

示例2: 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

示例3: 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

示例4: 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

示例5: 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

示例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: 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

示例8: registerFileCodeGenerator

 public static function registerFileCodeGenerator(Zend_CodeGenerator_Php_File $fileCodeGenerator, $fileName = null)
 {
     if ($fileName == null) {
         $fileName = $fileCodeGenerator->getFilename();
     }
     if ($fileName == '') {
         throw new Zend_CodeGenerator_Php_Exception('FileName does not exist.');
     }
     // cannot use realpath since the file might not exist, but we do need to have the index
     // in the same DIRECTORY_SEPARATOR that realpath would use:
     $fileName = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $fileName);
     self::$_fileCodeGenerators[$fileName] = $fileCodeGenerator;
 }
开发者ID:NerdGZ,项目名称:icingaweb2,代码行数:13,代码来源:File.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()
 {
     $profile = $this->_resource->getProfile();
     $vendor = $profile->getAttribute('vendor');
     $name = $profile->getAttribute('name');
     $className = sprintf($this->getClassPath(), $vendor, $name, ucfirst($this->_className));
     $codeGenFile = new Zend_CodeGenerator_Php_File(array('fileName' => $this->getPath(), 'classes' => array(new Zend_CodeGenerator_Php_Class(array('name' => $className, 'extendedClass' => $this->getExtends(), 'methods' => array())))));
     // store the generator into the registry so that the addAction command can use the same object later
     Zend_CodeGenerator_Php_File::registerFileCodeGenerator($codeGenFile);
     // REQUIRES filename to be set
     return $codeGenFile->generate();
 }
开发者ID:CEMD-CN,项目名称:MageTool,代码行数:17,代码来源:AbstractFile.php

示例12: 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

示例13: getContents

    /**
     * getContents()
     *
     * @return string
     */
    public function getContents()
    {
        $filter = new Zend_Filter_Word_DashToCamelCase();
        $moduleName = ucfirst($this->_moduleName);
        $className = ucfirst($this->_controllerName) . 'Controller';
        $codeGenFile = new Zend_CodeGenerator_Php_File(array('fileName' => $this->getPath(), 'classes' => array(new Zend_CodeGenerator_Php_Class(array('name' => $className, 'extendedClass' => 'App_' . $moduleName . '_Controller', 'methods' => array(new Zend_CodeGenerator_Php_Method(array('name' => 'init', 'body' => '/* Initialize action controller here */'))))))));
        if ($className == 'ErrorController') {
            $codeGenFile = new Zend_CodeGenerator_Php_File(array('fileName' => $this->getPath(), 'classes' => array(new Zend_CodeGenerator_Php_Class(array('name' => $className, 'extendedClass' => 'App_' . $moduleName . '_Controller', 'properties' => array(new Zend_CodeGenerator_Php_Property(array('name' => '_dispatch404s', 'visibility' => Zend_CodeGenerator_Php_Property::VISIBILITY_PROTECTED, 'defaultValue' => array(Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE, Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER, Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION)))), 'methods' => array(new Zend_CodeGenerator_Php_Method(array('name' => 'init', 'body' => <<<EOS
parent::init();
        
\$this->_helper->layout()->setLayout('layout');
EOS
)), new Zend_CodeGenerator_Php_Method(array('name' => 'errorAction', 'body' => <<<EOS
\$errorInfo = \$this->_getParam('error_handler');

if (in_array(\$errorInfo->type, \$this->_dispatch404s)) {
\t\$this->_dispatch404();
\treturn;
}
        
\$this->getResponse()->setRawHeader('HTTP/1.1 500 Internal Server Error');
        
\$this->title = 'Internal Server Error';
        
\$this->view->exception = \$errorInfo->exception;
EOS
)), new Zend_CodeGenerator_Php_Method(array('name' => 'flagflippersAction', 'body' => <<<EOS
if (Zend_Registry::get('IS_DEVELOPMENT')) {
\t\$this->title = 'Flag and Flipper not found';
            
\t\$this->view->originalController = \$this->_getParam('originalController');
\t\$this->view->originalAction = \$this->_getParam('originalAction');
} else {
\t\$this->_dispatch404();
}
EOS
)), new Zend_CodeGenerator_Php_Method(array('name' => 'forbiddenAction', 'body' => '$this->title = \'Forbidden\';')), new Zend_CodeGenerator_Php_Method(array('name' => '_dispatch404', 'visibility' => Zend_CodeGenerator_Php_Method::VISIBILITY_PROTECTED, 'body' => <<<EOS
\$this->title = 'Page not found';
\$this->getResponse()->setRawHeader('HTTP/1.1 404 Not Found');
        
\$this->render('error-404');
EOS
))))))));
        }
        // store the generator into the registry so that the addAction command can use the same object later
        Zend_CodeGenerator_Php_File::registerFileCodeGenerator($codeGenFile);
        // REQUIRES filename to be set
        return $codeGenFile->generate();
    }
开发者ID:omusico,项目名称:logica,代码行数:54,代码来源:ZfsControllerFile.php

示例14: 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

示例15: getContents

 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();
 }
开发者ID:bizanto,项目名称:Hooked,代码行数:6,代码来源:DbTableFile.php


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