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


PHP Zend_CodeGenerator_Php_File::fromReflectedFileName方法代码示例

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


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

示例1: create

    /**
     * create()
     *
     * @return Zend_Tool_Project_Context_Zf_ActionMethod
     */
    public function create()
    {
        $file = $this->_testApplicationControllerPath;
        if (!file_exists($file)) {
            // require_once 'Zend/Tool/Project/Context/Exception.php';
            throw new Zend_Tool_Project_Context_Exception('Could not create action within test controller ' . $file . ' with action name ' . $this->_forActionName);
        }
        $actionParam = $this->getForActionName();
        $controllerParam = $this->_resource->getParentResource()->getForControllerName();
        //$moduleParam = null;//
        /* @var $controllerDirectoryResource Zend_Tool_Project_Profile_Resource */
        $controllerDirectoryResource = $this->_resource->getParentResource()->getParentResource();
        if ($controllerDirectoryResource->getParentResource()->getName() == 'TestApplicationModuleDirectory') {
            $moduleParam = $controllerDirectoryResource->getParentResource()->getForModuleName();
        } else {
            $moduleParam = 'default';
        }
        if ($actionParam == 'index' && $controllerParam == 'Index' && $moduleParam == 'default') {
            $assert = '$this->assertQueryContentContains("div#welcome h3", "This is your project\'s main page");';
        } else {
            $assert = <<<EOS
\$this->assertQueryContentContains(
    'div#view-content p',
    'View script for controller <b>' . \$params['controller'] . '</b> and script/action name <b>' . \$params['action'] . '</b>'
    );
EOS;
        }
        $codeGenFile = Zend_CodeGenerator_Php_File::fromReflectedFileName($file, true, true);
        $codeGenFile->getClass()->setMethod(array('name' => 'test' . ucfirst($actionParam) . 'Action', 'body' => <<<EOS
\$params = array('action' => '{$actionParam}', 'controller' => '{$controllerParam}', 'module' => '{$moduleParam}');
\$urlParams = \$this->urlizeOptions(\$params);
\$url = \$this->url(\$urlParams);
\$this->dispatch(\$url);

// assertions
\$this->assertModule(\$urlParams['module']);
\$this->assertController(\$urlParams['controller']);
\$this->assertAction(\$urlParams['action']);
{$assert}

EOS
));
        file_put_contents($file, $codeGenFile->generate());
        return $this;
    }
开发者ID:jkimdon,项目名称:cohomeals,代码行数:50,代码来源:TestApplicationActionMethod.php

示例2: testNewMethodKeepTwoDocBlock

    /**
     * @group ZF-11703
     */
    public function testNewMethodKeepTwoDocBlock()
    {
        $codeGenFile = Zend_CodeGenerator_Php_File::fromReflectedFileName(dirname(__FILE__) . '/_files/zf-11703_1.php', true, true);
        $target = <<<EOS
<?php
/**
 * For manipulating files.
 */


/**
 * Class Foo1
 */
class Foo1
{

    public function bar()
    {
        // action body
    }

    public function bar2()
    {
        // action body
    }


}


EOS;
        $codeGenFile->getClass()->setMethod(array('name' => 'bar2', 'body' => '// action body'));
        $this->assertEquals($target, $codeGenFile->generate());
    }
开发者ID:crodriguezn,项目名称:crossfit-milagro,代码行数:37,代码来源:FileTest.php

示例3: getCodeGenerator

 /**
  * getCodeGenerator()
  *
  * @return Zend_CodeGenerator_Php_Class
  */
 public function getCodeGenerator()
 {
     $codeGenFile = Zend_CodeGenerator_Php_File::fromReflectedFileName($this->getPath());
     $codeGenFileClasses = $codeGenFile->getClasses();
     $class = array_shift($codeGenFileClasses);
     return $class;
 }
开发者ID:andrelsguerra,项目名称:pequiambiental,代码行数:12,代码来源:ControllerFile.php

示例4: hasActionMethod

 /**
  * hasActionMethod()
  *
  * @param string $controllerPath
  * @param string $actionName
  * @return bool
  */
 public static function hasActionMethod($controllerPath, $actionName)
 {
     if (!file_exists($controllerPath)) {
         return false;
     }
     $controllerCodeGenFile = Zend_CodeGenerator_Php_File::fromReflectedFileName($controllerPath, true, true);
     return $controllerCodeGenFile->getClass()->hasMethod($actionName . 'Action');
 }
开发者ID:netvlies,项目名称:zf,代码行数:15,代码来源:ActionMethod.php

示例5: addAction

 /**
  * addAction()
  *
  * @param string $actionName
  */
 public function addAction($actionName)
 {
     //require_once $this->getPath();
     //$codeGenFile = Zend_CodeGenerator_Php_File::fromReflection(new Zend_Reflection_File($this->getPath()));
     $codeGenFile = Zend_CodeGenerator_Php_File::fromReflectedFileName($this->getPath());
     $codeGenFileClasses = $codeGenFile->getClasses();
     $class = array_shift($codeGenFileClasses);
     $class->setMethod(array('name' => $actionName . 'Action', 'body' => '        // action body here'));
     file_put_contents($this->getPath(), $codeGenFile->generate());
 }
开发者ID:VUW-SIM-FIS,项目名称:emiemi,代码行数:15,代码来源:ControllerFile.php


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