DbTableFile.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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-2014 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-2014 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_DbTableFile extends Zend_Tool_Project_Context_Zf_AbstractClassFile
  34. {
  35. protected $_dbTableName = null;
  36. protected $_actualTableName = null;
  37. /**
  38. * getName()
  39. *
  40. * @return string
  41. */
  42. public function getName()
  43. {
  44. return 'DbTableFile';
  45. }
  46. /**
  47. * init()
  48. *
  49. */
  50. public function init()
  51. {
  52. $this->_dbTableName = $this->_resource->getAttribute('dbTableName');
  53. $this->_actualTableName = $this->_resource->getAttribute('actualTableName');
  54. $this->_filesystemName = ucfirst($this->_dbTableName) . '.php';
  55. parent::init();
  56. }
  57. public function getPersistentAttributes()
  58. {
  59. return array('dbTableName' => $this->_dbTableName);
  60. }
  61. public function getContents()
  62. {
  63. $className = $this->getFullClassName($this->_dbTableName, 'Model_DbTable');
  64. $codeGenFile = new Zend_CodeGenerator_Php_File(array(
  65. 'fileName' => $this->getPath(),
  66. 'classes' => array(
  67. new Zend_CodeGenerator_Php_Class(array(
  68. 'name' => $className,
  69. 'extendedClass' => 'Zend_Db_Table_Abstract',
  70. 'properties' => array(
  71. new Zend_CodeGenerator_Php_Property(array(
  72. 'name' => '_name',
  73. 'visibility' => Zend_CodeGenerator_Php_Property::VISIBILITY_PROTECTED,
  74. 'defaultValue' => $this->_actualTableName
  75. ))
  76. ),
  77. ))
  78. )
  79. ));
  80. return $codeGenFile->generate();
  81. }
  82. }