Esempio n. 1
0
 public function testFromReflection()
 {
     $tempFile = tempnam(sys_get_temp_dir(), 'UnitFile');
     $codeGenFile = new Zend_Tool_CodeGenerator_Php_File(array('class' => array('name' => 'SampleClass')));
     file_put_contents($tempFile, $codeGenFile->toString());
     require_once $tempFile;
     $codeGenFileFromDisk = Zend_Tool_CodeGenerator_Php_File::fromReflection($x = new Zend_Tool_Reflection_File($tempFile));
     unlink($tempFile);
     $this->assertEquals(get_class($codeGenFileFromDisk), 'Zend_Tool_CodeGenerator_Php_File');
     $this->assertEquals(count($codeGenFileFromDisk->getClasses()), 1);
 }
 public function getContents()
 {
     $filter = new Zend_Filter_Word_DashToCamelCase();
     $className = $filter->filter($this->_controllerName) . 'Controller';
     $codeGenFile = new Zend_Tool_CodeGenerator_Php_File(array('classes' => array(new Zend_Tool_CodeGenerator_Php_Class(array('className' => $className, 'extendedClassName' => 'Zend_Controller_Action', 'methods' => array(new Zend_Tool_CodeGenerator_Php_Method(array('name' => 'init', 'body' => '        /* Initialize action controller here */')), new Zend_Tool_CodeGenerator_Php_Method(array('name' => 'indexAction', 'body' => '        /* Default action for action controller */'))))))));
     if ($className == 'ErrorController') {
         $classes = $codeGenFile->getClasses();
         $classes[0]->addMethod(new Zend_Tool_CodeGenerator_Php_Method(array('name' => 'errorAction', 'body' => '        // some errorAction stuff here')));
     }
     return $codeGenFile->toString();
 }
 public function getContents()
 {
     $codeGenerator = new Zend_Tool_CodeGenerator_Php_File(array('body' => 'include \'../bootstrap.php\';'));
     return $codeGenerator->toString();
 }
Esempio n. 4
0
 public function bootstrapFile()
 {
     $codeGenFile = new Zend_Tool_CodeGenerator_Php_File(array('requiredFiles' => array('Zend/Loader.php'), 'body' => 'Zend_Loader::registerAutoloader();' . PHP_EOL . PHP_EOL . '// bootstrap application here'));
     return $codeGenFile->toString();
 }