web/lib/Zend/Tool/Project/Context/Zf/FormFile.php
changeset 64 162c1de6545a
parent 19 1c2f13fd785c
child 68 ecaf28ffe26e
equal deleted inserted replaced
63:5b37998e522e 64:162c1de6545a
       
     1 <?php
       
     2 /**
       
     3  * Zend Framework
       
     4  *
       
     5  * LICENSE
       
     6  *
       
     7  * This source file is subject to the new BSD license that is bundled
       
     8  * with this package in the file LICENSE.txt.
       
     9  * It is also available through the world-wide-web at this URL:
       
    10  * http://framework.zend.com/license/new-bsd
       
    11  * If you did not receive a copy of the license and are unable to
       
    12  * obtain it through the world-wide-web, please send an email
       
    13  * to license@zend.com so we can send you a copy immediately.
       
    14  *
       
    15  * @category   Zend
       
    16  * @package    Zend_Tool
       
    17  * @subpackage Framework
       
    18  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    19  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    20  * @version    $Id: FormFile.php 23343 2010-11-15 15:33:22Z ramon $
       
    21  */
       
    22 
       
    23 /**
       
    24  * @see Zend_Tool_Project_Context_Zf_AbstractClassFile
       
    25  */
       
    26 require_once 'Zend/Tool/Project/Context/Zf/AbstractClassFile.php';
       
    27 
       
    28 /**
       
    29  * This class is the front most class for utilizing Zend_Tool_Project
       
    30  *
       
    31  * A profile is a hierarchical set of resources that keep track of
       
    32  * items within a specific project.
       
    33  *
       
    34  * @category   Zend
       
    35  * @package    Zend_Tool
       
    36  * @copyright  Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
       
    37  * @license    http://framework.zend.com/license/new-bsd     New BSD License
       
    38  */
       
    39 class Zend_Tool_Project_Context_Zf_FormFile extends Zend_Tool_Project_Context_Zf_AbstractClassFile
       
    40 {
       
    41 
       
    42     /**
       
    43      * @var string
       
    44      */
       
    45     protected $_formName = 'Base';
       
    46 
       
    47     /**
       
    48      * @var string
       
    49      */
       
    50     protected $_filesystemName = 'formName';
       
    51 
       
    52     /**
       
    53      * init()
       
    54      *
       
    55      */
       
    56     public function init()
       
    57     {
       
    58         $this->_formName = $this->_resource->getAttribute('formName');
       
    59         $this->_filesystemName = ucfirst($this->_formName) . '.php';
       
    60         parent::init();
       
    61     }
       
    62 
       
    63     /**
       
    64      * getPersistentAttributes
       
    65      *
       
    66      * @return array
       
    67      */
       
    68     public function getPersistentAttributes()
       
    69     {
       
    70         return array(
       
    71             'formName' => $this->getFormName()
       
    72             );
       
    73     }
       
    74 
       
    75     /**
       
    76      * getName()
       
    77      *
       
    78      * @return string
       
    79      */
       
    80     public function getName()
       
    81     {
       
    82         return 'FormFile';
       
    83     }
       
    84 
       
    85     public function getFormName()
       
    86     {
       
    87         return $this->_formName;
       
    88     }
       
    89 
       
    90     public function getContents()
       
    91     {
       
    92 
       
    93         $className = $this->getFullClassName($this->_formName, 'Form');
       
    94 
       
    95         $codeGenFile = new Zend_CodeGenerator_Php_File(array(
       
    96             'fileName' => $this->getPath(),
       
    97             'classes' => array(
       
    98                 new Zend_CodeGenerator_Php_Class(array(
       
    99                     'name' => $className,
       
   100                     'extendedClass' => 'Zend_Form',
       
   101                     'methods' => array(
       
   102                         new Zend_CodeGenerator_Php_Method(array(
       
   103                             'name' => 'init',
       
   104                             'body' => '/* Form Elements & Other Definitions Here ... */',
       
   105                             ))
       
   106                         )
       
   107 
       
   108                     ))
       
   109                 )
       
   110             ));
       
   111         return $codeGenFile->generate();
       
   112     }
       
   113 }