|
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: Manifest.php 20096 2010-01-06 02:05:09Z bkarwin $ |
|
21 */ |
|
22 |
|
23 /** |
|
24 * @see Zend_Tool_Framework_Manifest_MetadataManifestable |
|
25 */ |
|
26 require_once 'Zend/Tool/Framework/Manifest/MetadataManifestable.php'; |
|
27 |
|
28 /** |
|
29 * @see Zend_Filter |
|
30 */ |
|
31 require_once 'Zend/Filter.php'; |
|
32 |
|
33 /** |
|
34 * @see Zend_Filter_Word_CamelCaseToDash |
|
35 */ |
|
36 require_once 'Zend/Filter/Word/CamelCaseToDash.php'; |
|
37 |
|
38 /** |
|
39 * @see Zend_Filter_StringToLower |
|
40 */ |
|
41 require_once 'Zend/Filter/StringToLower.php'; |
|
42 |
|
43 /** |
|
44 * @see Zend_Tool_Framework_Metadata_Tool |
|
45 */ |
|
46 require_once 'Zend/Tool/Framework/Metadata/Tool.php'; |
|
47 |
|
48 /** |
|
49 * @see Zend_Tool_Framework_Registry_EnabledInterface |
|
50 */ |
|
51 require_once 'Zend/Tool/Framework/Registry/EnabledInterface.php'; |
|
52 |
|
53 /** |
|
54 * Zend_Tool_Framework_Client_ConsoleClient_Manifest |
|
55 * @category Zend |
|
56 * @package Zend_Tool |
|
57 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
58 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
59 */ |
|
60 class Zend_Tool_Framework_Client_Console_Manifest |
|
61 implements Zend_Tool_Framework_Registry_EnabledInterface, |
|
62 Zend_Tool_Framework_Manifest_MetadataManifestable |
|
63 { |
|
64 |
|
65 /** |
|
66 * @var Zend_Tool_Framework_Registry_Interface |
|
67 */ |
|
68 protected $_registry = null; |
|
69 |
|
70 /** |
|
71 * setRegistry() - Required for the Zend_Tool_Framework_Registry_EnabledInterface interface |
|
72 * |
|
73 * @param Zend_Tool_Framework_Registry_Interface $registry |
|
74 * @return Zend_Tool_Framework_Client_Console_Manifest |
|
75 */ |
|
76 public function setRegistry(Zend_Tool_Framework_Registry_Interface $registry) |
|
77 { |
|
78 $this->_registry = $registry; |
|
79 return $this; |
|
80 } |
|
81 |
|
82 /** |
|
83 * getMetadata() is required by the Manifest Interface. |
|
84 * |
|
85 * These are the following metadatas that will be setup: |
|
86 * |
|
87 * actionName |
|
88 * - metadata for actions |
|
89 * - value will be a dashed name for the action named in 'actionName' |
|
90 * providerName |
|
91 * - metadata for providers |
|
92 * - value will be a dashed-name for the provider named in 'providerName' |
|
93 * providerSpecialtyNames |
|
94 * - metadata for providers |
|
95 * actionableMethodLongParameters |
|
96 * - metadata for providers |
|
97 * actionableMethodShortParameters |
|
98 * - metadata for providers |
|
99 * |
|
100 * @return array Array of Metadatas |
|
101 */ |
|
102 public function getMetadata() |
|
103 { |
|
104 $metadatas = array(); |
|
105 |
|
106 // setup the camelCase to dashed filter to use since cli expects dashed named |
|
107 $ccToDashedFilter = new Zend_Filter(); |
|
108 $ccToDashedFilter |
|
109 ->addFilter(new Zend_Filter_Word_CamelCaseToDash()) |
|
110 ->addFilter(new Zend_Filter_StringToLower()); |
|
111 |
|
112 // get the registry to get the action and provider repository |
|
113 $actionRepository = $this->_registry->getActionRepository(); |
|
114 $providerRepository = $this->_registry->getProviderRepository(); |
|
115 |
|
116 // loop through all actions and create a metadata for each |
|
117 foreach ($actionRepository->getActions() as $action) { |
|
118 // each action metadata will be called |
|
119 $metadatas[] = new Zend_Tool_Framework_Metadata_Tool(array( |
|
120 'name' => 'actionName', |
|
121 'value' => $ccToDashedFilter->filter($action->getName()), |
|
122 'reference' => $action, |
|
123 'actionName' => $action->getName(), |
|
124 'clientName' => 'console', |
|
125 'clientReference' => $this->_registry->getClient() |
|
126 )); |
|
127 } |
|
128 |
|
129 foreach ($providerRepository->getProviderSignatures() as $providerSignature) { |
|
130 |
|
131 // create the metadata for the provider's cliProviderName |
|
132 $metadatas[] = new Zend_Tool_Framework_Metadata_Tool(array( |
|
133 'name' => 'providerName', |
|
134 'value' => $ccToDashedFilter->filter($providerSignature->getName()), |
|
135 'reference' => $providerSignature, |
|
136 'clientName' => 'console', |
|
137 'providerName' => $providerSignature->getName(), |
|
138 'clientReference' => $this->_registry->getClient() |
|
139 )); |
|
140 |
|
141 // create the metadatas for the per provider specialites in providerSpecaltyNames |
|
142 foreach ($providerSignature->getSpecialties() as $specialty) { |
|
143 |
|
144 $metadatas[] = new Zend_Tool_Framework_Metadata_Tool(array( |
|
145 'name' => 'specialtyName', |
|
146 'value' => $ccToDashedFilter->filter($specialty), |
|
147 'reference' => $providerSignature, |
|
148 'clientName' => 'console', |
|
149 'providerName' => $providerSignature->getName(), |
|
150 'specialtyName' => $specialty, |
|
151 'clientReference' => $this->_registry->getClient() |
|
152 )); |
|
153 |
|
154 } |
|
155 |
|
156 // $actionableMethod is keyed by the methodName (but not used) |
|
157 foreach ($providerSignature->getActionableMethods() as $actionableMethodData) { |
|
158 |
|
159 $methodLongParams = array(); |
|
160 $methodShortParams = array(); |
|
161 |
|
162 // $actionableMethodData get both the long and short names |
|
163 foreach ($actionableMethodData['parameterInfo'] as $parameterInfoData) { |
|
164 |
|
165 // filter to dashed |
|
166 $methodLongParams[$parameterInfoData['name']] = $ccToDashedFilter->filter($parameterInfoData['name']); |
|
167 |
|
168 // simply lower the character, (its only 1 char after all) |
|
169 $methodShortParams[$parameterInfoData['name']] = strtolower($parameterInfoData['name'][0]); |
|
170 |
|
171 } |
|
172 |
|
173 // create metadata for the long name cliActionableMethodLongParameters |
|
174 $metadatas[] = new Zend_Tool_Framework_Metadata_Tool(array( |
|
175 'name' => 'actionableMethodLongParams', |
|
176 'value' => $methodLongParams, |
|
177 'clientName' => 'console', |
|
178 'providerName' => $providerSignature->getName(), |
|
179 'specialtyName' => $actionableMethodData['specialty'], |
|
180 'actionName' => $actionableMethodData['actionName'], |
|
181 'reference' => &$actionableMethodData, |
|
182 'clientReference' => $this->_registry->getClient() |
|
183 )); |
|
184 |
|
185 // create metadata for the short name cliActionableMethodShortParameters |
|
186 $metadatas[] = new Zend_Tool_Framework_Metadata_Tool(array( |
|
187 'name' => 'actionableMethodShortParams', |
|
188 'value' => $methodShortParams, |
|
189 'clientName' => 'console', |
|
190 'providerName' => $providerSignature->getName(), |
|
191 'specialtyName' => $actionableMethodData['specialty'], |
|
192 'actionName' => $actionableMethodData['actionName'], |
|
193 'reference' => &$actionableMethodData, |
|
194 'clientReference' => $this->_registry->getClient() |
|
195 )); |
|
196 |
|
197 } |
|
198 |
|
199 } |
|
200 |
|
201 return $metadatas; |
|
202 } |
|
203 |
|
204 public function getIndex() |
|
205 { |
|
206 return 10000; |
|
207 } |
|
208 |
|
209 } |