本文整理汇总了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;
}
示例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());
}
示例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;
}
示例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');
}
示例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());
}