File indexing completed on 2025-01-19 05:21:35
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_Tool 0017 * @subpackage Framework 0018 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0019 * @license http://framework.zend.com/license/new-bsd New BSD License 0020 * @version $Id$ 0021 */ 0022 0023 /** 0024 * @see Zend_Tool_Framework_Manifest_MetadataManifestable 0025 */ 0026 // require_once 'Zend/Tool/Framework/Manifest/MetadataManifestable.php'; 0027 0028 /** 0029 * @see Zend_Filter 0030 */ 0031 // require_once 'Zend/Filter.php'; 0032 0033 /** 0034 * @see Zend_Filter_Word_CamelCaseToDash 0035 */ 0036 // require_once 'Zend/Filter/Word/CamelCaseToDash.php'; 0037 0038 /** 0039 * @see Zend_Filter_StringToLower 0040 */ 0041 // require_once 'Zend/Filter/StringToLower.php'; 0042 0043 /** 0044 * @see Zend_Tool_Framework_Metadata_Tool 0045 */ 0046 // require_once 'Zend/Tool/Framework/Metadata/Tool.php'; 0047 0048 /** 0049 * @see Zend_Tool_Framework_Registry_EnabledInterface 0050 */ 0051 // require_once 'Zend/Tool/Framework/Registry/EnabledInterface.php'; 0052 0053 /** 0054 * Zend_Tool_Framework_Client_ConsoleClient_Manifest 0055 * @category Zend 0056 * @package Zend_Tool 0057 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0058 * @license http://framework.zend.com/license/new-bsd New BSD License 0059 */ 0060 class Zend_Tool_Framework_Client_Manifest 0061 implements Zend_Tool_Framework_Registry_EnabledInterface, 0062 Zend_Tool_Framework_Manifest_MetadataManifestable 0063 { 0064 0065 /** 0066 * @var Zend_Tool_Framework_Registry_Interface 0067 */ 0068 protected $_registry = null; 0069 0070 /** 0071 * setRegistry() - Required for the Zend_Tool_Framework_Registry_EnabledInterface interface 0072 * 0073 * @param Zend_Tool_Framework_Registry_Interface $registry 0074 * @return Zend_Tool_Framework_Client_Console_Manifest 0075 */ 0076 public function setRegistry(Zend_Tool_Framework_Registry_Interface $registry) 0077 { 0078 $this->_registry = $registry; 0079 return $this; 0080 } 0081 0082 /** 0083 * getMetadata() is required by the Manifest Interface. 0084 * 0085 * These are the following metadatas that will be setup: 0086 * 0087 * normalizedActionName 0088 * - metadata for actions 0089 * - value will be a dashed name for the action named in 'actionName' 0090 * normalizedProviderName 0091 * - metadata for providers 0092 * - value will be a dashed-name for the provider named in 'providerName' 0093 * normalizedProviderSpecialtyNames 0094 * - metadata for providers 0095 * normalizedActionableMethodLongParameters 0096 * - metadata for providers 0097 * normalizedActionableMethodShortParameters 0098 * - metadata for providers 0099 * 0100 * @return array Array of Metadatas 0101 */ 0102 public function getMetadata() 0103 { 0104 $metadatas = array(); 0105 0106 // setup the camelCase to dashed filter to use since cli expects dashed named 0107 $lowerFilter = new Zend_Filter(); 0108 $lowerFilter->addFilter(new Zend_Filter_StringToLower()); 0109 0110 // get the registry to get the action and provider repository 0111 $actionRepository = $this->_registry->getActionRepository(); 0112 $providerRepository = $this->_registry->getProviderRepository(); 0113 0114 // loop through all actions and create a metadata for each 0115 foreach ($actionRepository->getActions() as $action) { 0116 // each action metadata will be called 0117 $metadatas[] = new Zend_Tool_Framework_Metadata_Tool(array( 0118 'name' => 'normalizedActionName', 0119 'value' => $lowerFilter->filter($action->getName()), 0120 'reference' => $action, 0121 'actionName' => $action->getName(), 0122 'clientName' => 'all' 0123 )); 0124 } 0125 0126 foreach ($providerRepository->getProviderSignatures() as $providerSignature) { 0127 0128 // create the metadata for the provider's cliProviderName 0129 $metadatas[] = new Zend_Tool_Framework_Metadata_Tool(array( 0130 'name' => 'normalizedProviderName', 0131 'value' => $lowerFilter->filter($providerSignature->getName()), 0132 'reference' => $providerSignature, 0133 'clientName' => 'all', 0134 'providerName' => $providerSignature->getName() 0135 )); 0136 0137 // create the metadatas for the per provider specialites in providerSpecaltyNames 0138 foreach ($providerSignature->getSpecialties() as $specialty) { 0139 0140 if ($specialty == '_Global') { 0141 continue; 0142 } 0143 0144 $metadatas[] = new Zend_Tool_Framework_Metadata_Tool(array( 0145 'name' => 'normalizedSpecialtyName', 0146 'value' => $lowerFilter->filter($specialty), 0147 'reference' => $providerSignature, 0148 'clientName' => 'all', 0149 'providerName' => $providerSignature->getName(), 0150 'specialtyName' => $specialty 0151 )); 0152 0153 } 0154 0155 // $actionableMethod is keyed by the methodName (but not used) 0156 foreach ($providerSignature->getActionableMethods() as $actionableMethodData) { 0157 0158 $methodLongParams = array(); 0159 $methodShortParams = array(); 0160 0161 // $actionableMethodData get both the long and short names 0162 foreach ($actionableMethodData['parameterInfo'] as $parameterInfoData) { 0163 0164 // filter to dashed 0165 $methodLongParams[$parameterInfoData['name']] = $lowerFilter->filter($parameterInfoData['name']); 0166 0167 // simply lower the character, (its only 1 char after all) 0168 $methodShortParams[$parameterInfoData['name']] = strtolower($parameterInfoData['name'][0]); 0169 0170 } 0171 0172 // create metadata for the long name cliActionableMethodLongParameters 0173 $metadatas[] = new Zend_Tool_Framework_Metadata_Tool(array( 0174 'name' => 'normalizedActionableMethodLongParams', 0175 'value' => $methodLongParams, 0176 'clientName' => 'console', 0177 'providerName' => $providerSignature->getName(), 0178 'specialtyName' => $actionableMethodData['specialty'], 0179 'actionName' => $actionableMethodData['actionName'], 0180 'reference' => &$actionableMethodData 0181 )); 0182 0183 // create metadata for the short name cliActionableMethodShortParameters 0184 $metadatas[] = new Zend_Tool_Framework_Metadata_Tool(array( 0185 'name' => 'normalizedActionableMethodShortParams', 0186 'value' => $methodShortParams, 0187 'clientName' => 'console', 0188 'providerName' => $providerSignature->getName(), 0189 'specialtyName' => $actionableMethodData['specialty'], 0190 'actionName' => $actionableMethodData['actionName'], 0191 'reference' => &$actionableMethodData 0192 )); 0193 0194 } 0195 0196 } 0197 0198 return $metadatas; 0199 } 0200 0201 public function getIndex() 0202 { 0203 return 100000; 0204 } 0205 0206 }