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_Console_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      * actionName
0088      *   - metadata for actions
0089      *   - value will be a dashed name for the action named in 'actionName'
0090      * providerName
0091      *   - metadata for providers
0092      *   - value will be a dashed-name for the provider named in 'providerName'
0093      * providerSpecialtyNames
0094      *   - metadata for providers
0095      * actionableMethodLongParameters
0096      *   - metadata for providers
0097      * actionableMethodShortParameters
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         $ccToDashedFilter = new Zend_Filter();
0108         $ccToDashedFilter
0109             ->addFilter(new Zend_Filter_Word_CamelCaseToDash())
0110             ->addFilter(new Zend_Filter_StringToLower());
0111 
0112         // get the registry to get the action and provider repository
0113         $actionRepository   = $this->_registry->getActionRepository();
0114         $providerRepository = $this->_registry->getProviderRepository();
0115 
0116         // loop through all actions and create a metadata for each
0117         foreach ($actionRepository->getActions() as $action) {
0118             // each action metadata will be called
0119             $metadatas[] = new Zend_Tool_Framework_Metadata_Tool(array(
0120                 'name'            => 'actionName',
0121                 'value'           => $ccToDashedFilter->filter($action->getName()),
0122                 'reference'       => $action,
0123                 'actionName'      => $action->getName(),
0124                 'clientName'      => 'console',
0125                 'clientReference' => $this->_registry->getClient()
0126                 ));
0127         }
0128 
0129         foreach ($providerRepository->getProviderSignatures() as $providerSignature) {
0130 
0131             // create the metadata for the provider's cliProviderName
0132             $metadatas[] = new Zend_Tool_Framework_Metadata_Tool(array(
0133                 'name'            => 'providerName',
0134                 'value'           => $ccToDashedFilter->filter($providerSignature->getName()),
0135                 'reference'       => $providerSignature,
0136                 'clientName'      => 'console',
0137                 'providerName'    => $providerSignature->getName(),
0138                 'clientReference' => $this->_registry->getClient()
0139                 ));
0140 
0141             // create the metadatas for the per provider specialites in providerSpecaltyNames
0142             foreach ($providerSignature->getSpecialties() as $specialty) {
0143 
0144                 $metadatas[] = new Zend_Tool_Framework_Metadata_Tool(array(
0145                     'name'            => 'specialtyName',
0146                     'value'           =>  $ccToDashedFilter->filter($specialty),
0147                     'reference'       => $providerSignature,
0148                     'clientName'      => 'console',
0149                     'providerName'    => $providerSignature->getName(),
0150                     'specialtyName'   => $specialty,
0151                     'clientReference' => $this->_registry->getClient()
0152                     ));
0153 
0154             }
0155 
0156             // $actionableMethod is keyed by the methodName (but not used)
0157             foreach ($providerSignature->getActionableMethods() as $actionableMethodData) {
0158 
0159                 $methodLongParams  = array();
0160                 $methodShortParams = array();
0161 
0162                 // $actionableMethodData get both the long and short names
0163                 foreach ($actionableMethodData['parameterInfo'] as $parameterInfoData) {
0164 
0165                     // filter to dashed
0166                     $methodLongParams[$parameterInfoData['name']] = $ccToDashedFilter->filter($parameterInfoData['name']);
0167 
0168                     // simply lower the character, (its only 1 char after all)
0169                     $methodShortParams[$parameterInfoData['name']] = strtolower($parameterInfoData['name'][0]);
0170 
0171                 }
0172 
0173                 // create metadata for the long name cliActionableMethodLongParameters
0174                 $metadatas[] = new Zend_Tool_Framework_Metadata_Tool(array(
0175                     'name'            => 'actionableMethodLongParams',
0176                     'value'           => $methodLongParams,
0177                     'clientName'      => 'console',
0178                     'providerName'    => $providerSignature->getName(),
0179                     'specialtyName'   => $actionableMethodData['specialty'],
0180                     'actionName'      => $actionableMethodData['actionName'],
0181                     'reference'       => &$actionableMethodData,
0182                     'clientReference' => $this->_registry->getClient()
0183                     ));
0184 
0185                 // create metadata for the short name cliActionableMethodShortParameters
0186                 $metadatas[] = new Zend_Tool_Framework_Metadata_Tool(array(
0187                     'name'            => 'actionableMethodShortParams',
0188                     'value'           => $methodShortParams,
0189                     'clientName'      => 'console',
0190                     'providerName'    => $providerSignature->getName(),
0191                     'specialtyName'   => $actionableMethodData['specialty'],
0192                     'actionName'      => $actionableMethodData['actionName'],
0193                     'reference'       => &$actionableMethodData,
0194                     'clientReference' => $this->_registry->getClient()
0195                     ));
0196 
0197             }
0198 
0199         }
0200 
0201         return $metadatas;
0202     }
0203 
0204     public function getIndex()
0205     {
0206         return 10000;
0207     }
0208 
0209 }