DbTable.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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: View.php 18386 2009-09-23 20:44:43Z ralph $
  21. */
  22. /**
  23. * @see Zend_Tool_Project_Provider_Abstract
  24. */
  25. require_once 'Zend/Tool/Project/Provider/Abstract.php';
  26. /**
  27. * @category Zend
  28. * @package Zend_Tool
  29. * @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
  30. * @license http://framework.zend.com/license/new-bsd New BSD License
  31. */
  32. class Zend_Tool_Project_Provider_DbTable extends Zend_Tool_Project_Provider_Abstract
  33. {
  34. protected $_specialties = array('FromDatabase');
  35. /**
  36. * @var Zend_Filter
  37. */
  38. protected $_nameFilter = null;
  39. public static function createResource(Zend_Tool_Project_Profile $profile, $dbTableName, $moduleName = null)
  40. {
  41. $profileSearchParams = array();
  42. if ($moduleName != null && is_string($moduleName)) {
  43. $profileSearchParams = array('modulesDirectory', 'moduleDirectory' => array('moduleName' => $moduleName));
  44. }
  45. $profileSearchParams[] = 'modelsDirectory';
  46. $modelsDirectory = $profile->search($profileSearchParams);
  47. if (!($dbTableDirectory = $modelsDirectory->search('DbTableDirectory'))) {
  48. $dbTableDirectory = $modelsDirectory->createResource('DbTableDirectory');
  49. }
  50. $dbTableFile = $dbTableDirectory->createResource('DbTableFile', array('dbTableName' => $dbTableName));
  51. return $dbTableFile;
  52. }
  53. public function create($tableName, $module = null)
  54. {
  55. //@todo create
  56. }
  57. public function createFromDatabase($module = null)
  58. {
  59. //@todo create from db
  60. }
  61. protected function _convertTableNameToClassName($tableName)
  62. {
  63. if ($this->_nameFilter == null) {
  64. $this->_nameFilter = new Zend_Filter();
  65. $this->_nameFilter
  66. ->addFilter(new Zend_Filter_Word_UnderscoreToCamelCase());
  67. }
  68. return $this->_nameFilter->filter($tableName);
  69. }
  70. }