|
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: ModelFile.php 20096 2010-01-06 02:05:09Z bkarwin $ |
|
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_ModelFile extends Zend_Tool_Project_Context_Zf_AbstractClassFile |
|
35 { |
|
36 |
|
37 /** |
|
38 * @var string |
|
39 */ |
|
40 protected $_modelName = 'Base'; |
|
41 |
|
42 /** |
|
43 * @var string |
|
44 */ |
|
45 protected $_filesystemName = 'modelName'; |
|
46 |
|
47 /** |
|
48 * init() |
|
49 * |
|
50 */ |
|
51 public function init() |
|
52 { |
|
53 $this->_modelName = $this->_resource->getAttribute('modelName'); |
|
54 $this->_filesystemName = ucfirst($this->_modelName) . '.php'; |
|
55 parent::init(); |
|
56 } |
|
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 /** |
|
71 * getName() |
|
72 * |
|
73 * @return string |
|
74 */ |
|
75 public function getName() |
|
76 { |
|
77 return 'ModelFile'; |
|
78 } |
|
79 |
|
80 public function getModelName() |
|
81 { |
|
82 return $this->_modelName; |
|
83 } |
|
84 |
|
85 public function getContents() |
|
86 { |
|
87 |
|
88 $className = $this->getFullClassName($this->_modelName, 'Model'); |
|
89 |
|
90 $codeGenFile = new Zend_CodeGenerator_Php_File(array( |
|
91 'fileName' => $this->getPath(), |
|
92 'classes' => array( |
|
93 new Zend_CodeGenerator_Php_Class(array( |
|
94 'name' => $className, |
|
95 )) |
|
96 ) |
|
97 )); |
|
98 return $codeGenFile->generate(); |
|
99 } |
|
100 |
|
101 |
|
102 } |