FormFile.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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-2009 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. * @version $Id$
  21. */
  22. /**
  23. * This class is the front most class for utilizing Zend_Tool_Project
  24. *
  25. * A profile is a hierarchical set of resources that keep track of
  26. * items within a specific project.
  27. *
  28. * @category Zend
  29. * @package Zend_Tool
  30. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  31. * @license http://framework.zend.com/license/new-bsd New BSD License
  32. */
  33. class Zend_Tool_Project_Context_Zf_FormFile extends Zend_Tool_Project_Context_Zf_AbstractClassFile
  34. {
  35. /**
  36. * @var string
  37. */
  38. protected $_formName = 'Base';
  39. /**
  40. * @var string
  41. */
  42. protected $_filesystemName = 'formName';
  43. /**
  44. * init()
  45. *
  46. */
  47. public function init()
  48. {
  49. $this->_formName = $this->_resource->getAttribute('formName');
  50. $this->_filesystemName = ucfirst($this->_formName) . '.php';
  51. parent::init();
  52. }
  53. /**
  54. * getPersistentAttributes
  55. *
  56. * @return array
  57. */
  58. public function getPersistentAttributes()
  59. {
  60. return array(
  61. 'formName' => $this->getFormName()
  62. );
  63. }
  64. /**
  65. * getName()
  66. *
  67. * @return string
  68. */
  69. public function getName()
  70. {
  71. return 'FormFile';
  72. }
  73. public function getFormName()
  74. {
  75. return $this->_formName;
  76. }
  77. public function getContents()
  78. {
  79. $className = $this->getFullClassName($this->_formName, 'Form');
  80. $codeGenFile = new Zend_CodeGenerator_Php_File(array(
  81. 'fileName' => $this->getPath(),
  82. 'classes' => array(
  83. new Zend_CodeGenerator_Php_Class(array(
  84. 'name' => $className,
  85. 'extendedClass' => 'Zend_Form',
  86. 'methods' => array(
  87. new Zend_CodeGenerator_Php_Method(array(
  88. 'name' => 'init',
  89. 'body' => '/* Form Elements & Other Definitions Here ... */',
  90. ))
  91. )
  92. ))
  93. )
  94. ));
  95. return $codeGenFile->generate();
  96. }
  97. }