Ejemplo n.º 1
0
    /**
     * getContents()
     *
     * @return string
     */
    public function getContents()
    {
        $codeGenerator = new \Zend\Code\Generator\FileGenerator();
        $codeGenerator->setBody(<<<'EOS'
// Define path to application directory
defined('APPLICATION_PATH')
    || define('APPLICATION_PATH', realpath(__DIR__ . '/../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/Application.php';

// Create application, bootstrap, and run
$application = new Zend\Application\Application (
    APPLICATION_ENV,
    APPLICATION_PATH . '/configs/application.ini'
);
$application->bootstrap()
            ->run();

EOS
);
        return $codeGenerator->generate();
    }
Ejemplo n.º 2
0
 public function getContents()
 {
     $className = $this->getFullClassName($this->_modelName, 'Model');
     $codeGenFile = new \Zend\Code\Generator\FileGenerator();
     $codeGenFile->setFilename($this->getPath());
     $codeGenFile->setClass(new \Zend\Code\Generator\ClassGenerator($className));
     return $codeGenFile->generate();
 }
Ejemplo n.º 3
0
 /**
  *
  * @param unknown $className        	
  * @param unknown $nameSpace        	
  * @param unknown $value        	
  */
 private function generateEntityFileClassFinder($className, $nameSpace, $value)
 {
     // Passing configuration to the constructor:
     $file = new \Zend\Code\Generator\FileGenerator(array('classes' => array(new \Zend\Code\Generator\ClassGenerator($className . "Finder", $nameSpace, null, "\\Model\\Entity\\EntityFinder", array(), array(), array()))));
     // Render the generated file
     $file->generate();
     $classFile = DOC_ROOT . '\\Module\\' . $value['entity'] . 'Finder.php';
     fopen($classFile, "w");
     // or write it to a file:
     $returnFlag = file_put_contents($classFile, $file->generate());
     if ($returnFlag > 0) {
         echo "<span class='glyphicon glyphicon-ok text text-success'></span>";
     } else {
         echo "<span class='glyphicon glyphicon-remove text text-danger'></span>";
     }
 }
Ejemplo n.º 4
0
 /**
  * getContents()
  *
  * @return array
  */
 public function getContents()
 {
     $codeGenFile = new \Zend\Code\Generator\FileGenerator(array('classes' => array(new \Zend\Code\Generator\ClassGenerator('Bootstrap', null, null, '\\Zend\\Application\\Bootstrap'))));
     return $codeGenFile->generate();
 }
Ejemplo n.º 5
0
 /**
  * getContents()
  *
  * @return string
  */
 public function getContents()
 {
     $filter = new \Zend\Filter\Word\DashToCamelCase();
     $className = $filter->filter($this->_projectProviderName) . 'Provider';
     $class = new ClassGenerator($className, null, null, '\\Zend\\Tool\\Project\\Provider\\AbstractProvider');
     $methods = array();
     foreach ($this->_actionNames as $actionName) {
         $methods[] = new MethodGenerator($actionName, array(), MethodGenerator::FLAG_PUBLIC, '        /** @todo Implementation */');
     }
     if ($methods) {
         $class->setMethods($methods);
     }
     $codeGenFile = new \Zend\Code\Generator\FileGenerator();
     $codeGenFile->setClass($class);
     return $codeGenFile->generate();
 }
 /**
  *
  * @param unknown $className        	
  * @param unknown $nameSpace        	
  * @param unknown $value        	
  */
 private function generateEntityFileClassFinder($className, $nameSpace, $value)
 {
     // Passing configuration to the constructor:
     $class = new \Zend\Code\Generator\ClassGenerator();
     $class->setName($className . "Finder");
     $class->setNamespaceName($nameSpace);
     $class->setExtendedClass(self::BASE_DB_FINDER);
     $class->addMethod('__construct', array(array("name" => "table")), \Zend\Code\Generator\MethodGenerator::FLAG_PUBLIC, 'parent::__construct ( $table );');
     $file = new \Zend\Code\Generator\FileGenerator(array('classes' => array($class)));
     // Render the generated file
     $file->generate();
     $classFile = DOC_ROOT . '/module/' . $this->params["directory_location"] . "/" . $value . 'Finder.php';
     if (!file_exists($classFile)) {
         fopen($classFile, "w");
         $returnFlag = file_put_contents($classFile, $file->generate());
     }
     if ($returnFlag > 0) {
         echo "... <span class='glyphicon glyphicon-ok text text-success'></span>";
     } else {
         echo "... <span class='glyphicon glyphicon-remove text text-danger'></span> (not written)";
     }
 }
Ejemplo n.º 7
0
 public function getContents()
 {
     $className = $this->getFullClassName($this->_formName, 'Form');
     $codeGenFile = new \Zend\Code\Generator\FileGenerator();
     $codeGenFile->setFilename($this->getPath());
     $codeGenFile->setClass(new \Zend\Code\Generator\ClassGenerator($className, null, null, '\\Zend\\Form\\Form', array(), array(), new MethodGenerator('init', array(), MethodGenerator::FLAG_PUBLIC, '/* Form Elements & Other Definitions Here ... */')));
     return $codeGenFile->generate();
 }