|
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: CodeGenerator.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_Content_Engine_CodeGenerator |
|
35 { |
|
36 /** |
|
37 * @var Zend_Tool_Framework_Client_Storage |
|
38 */ |
|
39 protected $_storage = null; |
|
40 |
|
41 /** |
|
42 * @var string |
|
43 */ |
|
44 protected $_contentPrefix = null; |
|
45 |
|
46 /** |
|
47 * __construct() |
|
48 * |
|
49 * @param Zend_Tool_Framework_Client_Storage $storage |
|
50 * @param string $contentPrefix |
|
51 */ |
|
52 public function __construct(Zend_Tool_Framework_Client_Storage $storage, $contentPrefix) |
|
53 { |
|
54 $this->_storage = $storage; |
|
55 $this->_contentPrefix = $contentPrefix; |
|
56 } |
|
57 |
|
58 /** |
|
59 * hasContent() |
|
60 * |
|
61 * @param Zend_Tool_Project_Context_Interface $context |
|
62 * @param string $method |
|
63 * @return string |
|
64 */ |
|
65 public function hasContent(Zend_Tool_Project_Context_Interface $context, $method) |
|
66 { |
|
67 return $this->_storage->has($this->_contentPrefix . '/' . $context->getName() . '/' . $method . '.php'); |
|
68 } |
|
69 |
|
70 /** |
|
71 * getContent() |
|
72 * |
|
73 * @param Zend_Tool_Project_Context_Interface $context |
|
74 * @param string $method |
|
75 * @param mixed $parameters |
|
76 * @return string |
|
77 */ |
|
78 public function getContent(Zend_Tool_Project_Context_Interface $context, $method, $parameters) |
|
79 { |
|
80 $streamUri = $this->_storage->getStreamUri($this->_contentPrefix . '/' . $context->getName() . '/' . $method . '.php'); |
|
81 |
|
82 if (method_exists($context, 'getCodeGenerator')) { |
|
83 $codeGenerator = $context->getCodeGenerator(); |
|
84 } else { |
|
85 $codeGenerator = new Zend_CodeGenerator_Php_File(); |
|
86 } |
|
87 |
|
88 $codeGenerator = include $streamUri; |
|
89 |
|
90 if (!$codeGenerator instanceof Zend_CodeGenerator_Abstract) { |
|
91 throw new Zend_Tool_Project_Exception('Custom file at ' . $streamUri . ' did not return the $codeGenerator object.'); |
|
92 } |
|
93 |
|
94 return $codeGenerator->generate(); |
|
95 } |
|
96 |
|
97 |
|
98 } |