|
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: DbTableFile.php 20851 2010-02-02 21:45:51Z ralph $ |
|
21 */ |
|
22 |
|
23 /** |
|
24 * This class is the front most class for utilizing Zend_Tool_Project |
|
25 * |
|
26 * A profile is a hierarchical set of resources that keep track of |
|
27 * items within a specific project. |
|
28 * |
|
29 * @category Zend |
|
30 * @package Zend_Tool |
|
31 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
32 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
33 */ |
|
34 class Zend_Tool_Project_Context_Zf_DbTableFile extends Zend_Tool_Project_Context_Zf_AbstractClassFile |
|
35 { |
|
36 |
|
37 protected $_dbTableName = null; |
|
38 |
|
39 protected $_actualTableName = null; |
|
40 |
|
41 /** |
|
42 * getName() |
|
43 * |
|
44 * @return string |
|
45 */ |
|
46 public function getName() |
|
47 { |
|
48 return 'DbTableFile'; |
|
49 } |
|
50 |
|
51 /** |
|
52 * init() |
|
53 * |
|
54 */ |
|
55 public function init() |
|
56 { |
|
57 $this->_dbTableName = $this->_resource->getAttribute('dbTableName'); |
|
58 $this->_actualTableName = $this->_resource->getAttribute('actualTableName'); |
|
59 $this->_filesystemName = ucfirst($this->_dbTableName) . '.php'; |
|
60 parent::init(); |
|
61 } |
|
62 |
|
63 public function getPersistentAttributes() |
|
64 { |
|
65 return array('dbTableName' => $this->_dbTableName); |
|
66 } |
|
67 |
|
68 public function getContents() |
|
69 { |
|
70 $className = $this->getFullClassName($this->_dbTableName, 'Model_DbTable'); |
|
71 |
|
72 $codeGenFile = new Zend_CodeGenerator_Php_File(array( |
|
73 'fileName' => $this->getPath(), |
|
74 'classes' => array( |
|
75 new Zend_CodeGenerator_Php_Class(array( |
|
76 'name' => $className, |
|
77 'extendedClass' => 'Zend_Db_Table_Abstract', |
|
78 'properties' => array( |
|
79 new Zend_CodeGenerator_Php_Property(array( |
|
80 'name' => '_name', |
|
81 'visibility' => Zend_CodeGenerator_Php_Property::VISIBILITY_PROTECTED, |
|
82 'defaultValue' => $this->_actualTableName |
|
83 )) |
|
84 ), |
|
85 |
|
86 )) |
|
87 ) |
|
88 )); |
|
89 return $codeGenFile->generate(); |
|
90 } |
|
91 |
|
92 } |