ModelFile.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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_ModelFile extends Zend_Tool_Project_Context_Zf_AbstractClassFile
  34. {
  35. /**
  36. * @var string
  37. */
  38. protected $_modelName = 'Base';
  39. /**
  40. * @var string
  41. */
  42. protected $_moduleName = null;
  43. /**
  44. * @var string
  45. */
  46. protected $_filesystemName = 'modelName';
  47. /**
  48. * init()
  49. *
  50. */
  51. public function init()
  52. {
  53. $this->_modelName = $this->_resource->getAttribute('modelName');
  54. //$this->_moduleName = $this->_resource->getAttribute('moduleName');
  55. $this->_filesystemName = ucfirst($this->_modelName) . '.php';
  56. parent::init();
  57. }
  58. /**
  59. * getPersistentAttributes
  60. *
  61. * @return array
  62. */
  63. public function getPersistentAttributes()
  64. {
  65. return array(
  66. 'modelName' => $this->getModelName()
  67. );
  68. }
  69. /**
  70. * getName()
  71. *
  72. * @return string
  73. */
  74. public function getName()
  75. {
  76. return 'ModelFile';
  77. }
  78. public function getModelName()
  79. {
  80. return $this->_modelName;
  81. }
  82. public function getContents()
  83. {
  84. $className = $this->getFullClassName($this->_modelName, 'Model');
  85. $codeGenFile = new Zend_CodeGenerator_Php_File(array(
  86. 'fileName' => $this->getPath(),
  87. 'classes' => array(
  88. new Zend_CodeGenerator_Php_Class(array(
  89. 'name' => $className,
  90. //'methods' => array(
  91. // new Zend_CodeGenerator_Php_Method(array(
  92. // 'name' => 'someMethodName',
  93. // 'body' => '/* method body here */',
  94. // ))
  95. // )
  96. ))
  97. )
  98. ));
  99. return $codeGenFile->generate();
  100. }
  101. }