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


PHP Zend_CodeGenerator_Php_File::registerFileCodeGenerator方法代码示例

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


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

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

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

示例3: getContents

    /**
     * getContents()
     *
     * @return string
     */
    public function getContents()
    {
        $filter = new Zend_Filter_Word_DashToCamelCase();
        $className = $this->_moduleName ? $filter->filter(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' => 'Zend_Controller_Action', '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' => 'Zend_Controller_Action', 'methods' => array(new Zend_CodeGenerator_Php_Method(array('name' => 'errorAction', 'body' => <<<EOS
\$errors = \$this->_getParam('error_handler');

if (!\$errors || !\$errors instanceof ArrayObject) {
    \$this->view->message = 'You have reached the error page';
    return;
}

switch (\$errors->type) {
    case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ROUTE:
    case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
    case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:
        // 404 error -- controller or action not found
        \$this->getResponse()->setHttpResponseCode(404);
        \$priority = Zend_Log::NOTICE;
        \$this->view->message = 'Page not found';
        break;
    default:
        // application error
        \$this->getResponse()->setHttpResponseCode(500);
        \$priority = Zend_Log::CRIT;
        \$this->view->message = 'Application error';
        break;
}

// Log exception, if logger available
if (\$log = \$this->getLog()) {
    \$log->log(\$this->view->message, \$priority, \$errors->exception);
    \$log->log('Request Parameters', \$priority, \$errors->request->getParams());
}

// conditionally display exceptions
if (\$this->getInvokeArg('displayExceptions') == true) {
    \$this->view->exception = \$errors->exception;
}

\$this->view->request   = \$errors->request;
EOS
)), new Zend_CodeGenerator_Php_Method(array('name' => 'getLog', 'body' => <<<EOS
\$bootstrap = \$this->getInvokeArg('bootstrap');
if (!\$bootstrap->hasResource('Log')) {
    return false;
}
\$log = \$bootstrap->getResource('Log');
return \$log;
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:andrelsguerra,项目名称:pequiambiental,代码行数:65,代码来源:ControllerFile.php

示例4: getContents

    /**
     * getContents()
     *
     * @return string
     */
    public function getContents()
    {
        $filter = new Zend_Filter_Word_DashToCamelCase();
        $className = $filter->filter($this->_controllerName) . 'Controller';
        $codeGenFile = new Zend_CodeGenerator_Php_File(array('fileName' => $this->getPath(), 'classes' => array(new Zend_CodeGenerator_Php_Class(array('name' => $className, 'extendedClass' => 'Zend_Controller_Action', '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' => 'Zend_Controller_Action', 'methods' => array(new Zend_CodeGenerator_Php_Method(array('name' => 'errorAction', 'body' => <<<EOS
\$errors = \$this->_getParam('error_handler');

switch (\$errors->type) { 
    case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_CONTROLLER:
    case Zend_Controller_Plugin_ErrorHandler::EXCEPTION_NO_ACTION:

        // 404 error -- controller or action not found
        \$this->getResponse()->setHttpResponseCode(404);
        \$this->view->message = 'Page not found';
        break;
    default:
        // application error 
        \$this->getResponse()->setHttpResponseCode(500);
        \$this->view->message = 'Application error';
        break;
}

\$this->view->exception = \$errors->exception;
\$this->view->request   = \$errors->request;
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:mtday,项目名称:timesheet-system,代码行数:39,代码来源:ControllerFile.php


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