import v2.0.0.0_RC3 | 2012-07-01
https://github.com/lucanos/CommunityID -> http://www.itadmins.net/archives/357
This commit is contained in:
@ -17,7 +17,7 @@
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: ArgumentParser.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
* @version $Id: ArgumentParser.php 18951 2009-11-12 16:26:19Z alexander $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -31,9 +31,9 @@ require_once 'Zend/Console/Getopt.php';
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Tool_Framework_Client_Console_ArgumentParser implements Zend_Tool_Framework_Registry_EnabledInterface
|
||||
class Zend_Tool_Framework_Client_Console_ArgumentParser implements Zend_Tool_Framework_Registry_EnabledInterface
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @var Zend_Tool_Framework_Registry_Interface
|
||||
*/
|
||||
@ -63,8 +63,8 @@ class Zend_Tool_Framework_Client_Console_ArgumentParser implements Zend_Tool_Fra
|
||||
protected $_helpKnownAction = false;
|
||||
protected $_helpKnownProvider = false;
|
||||
protected $_helpKnownSpecialty = false;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* setArguments
|
||||
*
|
||||
@ -76,7 +76,7 @@ class Zend_Tool_Framework_Client_Console_ArgumentParser implements Zend_Tool_Fra
|
||||
$this->_argumentsOriginal = $this->_argumentsWorking = $arguments;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* setRegistry()
|
||||
*
|
||||
@ -87,14 +87,14 @@ class Zend_Tool_Framework_Client_Console_ArgumentParser implements Zend_Tool_Fra
|
||||
{
|
||||
// get the client registry
|
||||
$this->_registry = $registry;
|
||||
|
||||
|
||||
// set manifest repository, request, response for easy access
|
||||
$this->_manifestRepository = $this->_registry->getManifestRepository();
|
||||
$this->_request = $this->_registry->getRequest();
|
||||
$this->_response = $this->_registry->getResponse();
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Parse() - This method does the work of parsing the arguments into the enpooint request,
|
||||
* this will also (during help operations) fill the response in with information as needed
|
||||
@ -108,10 +108,10 @@ class Zend_Tool_Framework_Client_Console_ArgumentParser implements Zend_Tool_Fra
|
||||
require_once 'Zend/Tool/Framework/Client/Exception.php';
|
||||
throw new Zend_Tool_Framework_Client_Exception('The client registry must have both a request and response registered.');
|
||||
}
|
||||
|
||||
|
||||
// setup the help options
|
||||
$helpResponseOptions = array();
|
||||
|
||||
|
||||
// check to see if the first cli arg is the script name
|
||||
if ($this->_argumentsWorking[0] == $_SERVER['SCRIPT_NAME' ]) {
|
||||
array_shift($this->_argumentsWorking);
|
||||
@ -128,7 +128,7 @@ class Zend_Tool_Framework_Client_Console_ArgumentParser implements Zend_Tool_Fra
|
||||
// ensure there are arguments left
|
||||
if (count($this->_argumentsWorking) == 0) {
|
||||
$this->_request->setDispatchable(false); // at this point request is not dispatchable
|
||||
|
||||
|
||||
// check to see if this was a help request
|
||||
if ($this->_help) {
|
||||
$this->_createHelpResponse();
|
||||
@ -149,17 +149,17 @@ class Zend_Tool_Framework_Client_Console_ArgumentParser implements Zend_Tool_Fra
|
||||
|
||||
if ($this->_helpKnownAction) {
|
||||
$helpResponseOptions = array_merge(
|
||||
$helpResponseOptions,
|
||||
$helpResponseOptions,
|
||||
array('actionName' => $this->_request->getActionName())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
/* @TODO Action Parameter Requirements */
|
||||
|
||||
// make sure there are more "words" on the command line
|
||||
if (count($this->_argumentsWorking) == 0) {
|
||||
$this->_request->setDispatchable(false); // at this point request is not dispatchable
|
||||
|
||||
|
||||
// check to see if this is a help request
|
||||
if ($this->_help) {
|
||||
$this->_createHelpResponse($helpResponseOptions);
|
||||
@ -169,7 +169,7 @@ class Zend_Tool_Framework_Client_Console_ArgumentParser implements Zend_Tool_Fra
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// process the provider part of the command line
|
||||
try {
|
||||
$this->_parseProviderPart();
|
||||
@ -178,21 +178,21 @@ class Zend_Tool_Framework_Client_Console_ArgumentParser implements Zend_Tool_Fra
|
||||
$this->_createHelpResponse(array('error' => $exception->getMessage()));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if ($this->_helpKnownProvider) {
|
||||
$helpResponseOptions = array_merge(
|
||||
$helpResponseOptions,
|
||||
$helpResponseOptions,
|
||||
array('providerName' => $this->_request->getProviderName())
|
||||
);
|
||||
}
|
||||
|
||||
if ($this->_helpKnownSpecialty) {
|
||||
$helpResponseOptions = array_merge(
|
||||
$helpResponseOptions,
|
||||
$helpResponseOptions,
|
||||
array('specialtyName' => $this->_request->getSpecialtyName())
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// if there are arguments on the command line, lets process them as provider options
|
||||
if (count($this->_argumentsWorking) != 0) {
|
||||
$this->_parseProviderOptionsPart();
|
||||
@ -234,7 +234,7 @@ class Zend_Tool_Framework_Client_Console_ArgumentParser implements Zend_Tool_Fra
|
||||
$getoptOptions['pretend|p'] = 'PRETEND';
|
||||
$getoptOptions['debug|d'] = 'DEBUG';
|
||||
$getoptParser = new Zend_Console_Getopt($getoptOptions, $this->_argumentsWorking, array('parseAll' => false));
|
||||
|
||||
|
||||
// @todo catch any exceptions here
|
||||
$getoptParser->parse();
|
||||
|
||||
@ -247,7 +247,7 @@ class Zend_Tool_Framework_Client_Console_ArgumentParser implements Zend_Tool_Fra
|
||||
$this->_request->setVerbose(true);
|
||||
} else {
|
||||
$property = '_'.$option;
|
||||
$this->{$property} = true;
|
||||
$this->{$property} = true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -313,7 +313,7 @@ class Zend_Tool_Framework_Client_Console_ArgumentParser implements Zend_Tool_Fra
|
||||
$this->_help = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// get the cli provider names from the manifest
|
||||
$providerMetadata = $this->_manifestRepository->getMetadata(array(
|
||||
'type' => 'Tool',
|
||||
@ -331,15 +331,15 @@ class Zend_Tool_Framework_Client_Console_ArgumentParser implements Zend_Tool_Fra
|
||||
|
||||
$this->_helpKnownProvider = true;
|
||||
$this->_request->setProviderName($providerMetadata->getProviderName());
|
||||
|
||||
|
||||
if ($consoleSpecialtyName == '?') {
|
||||
$this->_help = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$providerSpecialtyMetadata = $this->_manifestRepository->getMetadata(array(
|
||||
'type' => 'Tool',
|
||||
'name' => 'specialtyName',
|
||||
'type' => 'Tool',
|
||||
'name' => 'specialtyName',
|
||||
'value' => $consoleSpecialtyName,
|
||||
'providerName' => $providerMetadata->getProviderName(),
|
||||
'clientName' => 'console'
|
||||
@ -368,7 +368,7 @@ class Zend_Tool_Framework_Client_Console_ArgumentParser implements Zend_Tool_Fra
|
||||
$this->_help = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
$searchParams = array(
|
||||
'type' => 'Tool',
|
||||
'providerName' => $this->_request->getProviderName(),
|
||||
@ -399,10 +399,10 @@ class Zend_Tool_Framework_Client_Console_ArgumentParser implements Zend_Tool_Fra
|
||||
|
||||
// process ParameterInfo into array for command line option matching
|
||||
if ($parameterInfo['type'] == 'string' || $parameterInfo['type'] == 'bool') {
|
||||
$optionConfig .= $paramNameShortValues[$parameterNameLong]
|
||||
$optionConfig .= $paramNameShortValues[$parameterNameLong]
|
||||
. (($parameterInfo['optional']) ? '-' : '=') . 's';
|
||||
} elseif (in_array($parameterInfo['type'], array('int', 'integer', 'float'))) {
|
||||
$optionConfig .= $paramNameShortValues[$parameterNameLong]
|
||||
$optionConfig .= $paramNameShortValues[$parameterNameLong]
|
||||
. (($parameterInfo['optional']) ? '-' : '=') . 'i';
|
||||
} else {
|
||||
$optionConfig .= $paramNameShortValues[$parameterNameLong] . '-s';
|
||||
@ -467,7 +467,7 @@ class Zend_Tool_Framework_Client_Console_ArgumentParser implements Zend_Tool_Fra
|
||||
$this->_metadataProviderOptionsLong = $actionableMethodLongParamsMetadata;
|
||||
$this->_metadataProviderOptionsShort = $actionableMethodShortParamsMetadata;
|
||||
*/
|
||||
|
||||
|
||||
$this->_argumentsWorking = $getoptParser->getRemainingArgs();
|
||||
|
||||
return;
|
||||
@ -483,11 +483,11 @@ class Zend_Tool_Framework_Client_Console_ArgumentParser implements Zend_Tool_Fra
|
||||
require_once 'Zend/Tool/Framework/Client/Console/HelpSystem.php';
|
||||
$helpSystem = new Zend_Tool_Framework_Client_Console_HelpSystem();
|
||||
$helpSystem->setRegistry($this->_registry);
|
||||
|
||||
|
||||
if (isset($options['error'])) {
|
||||
$helpSystem->respondWithErrorMessage($options['error']);
|
||||
}
|
||||
|
||||
|
||||
if (isset($options['actionName']) && isset($options['providerName'])) {
|
||||
$helpSystem->respondWithSpecialtyAndParamHelp($options['providerName'], $options['actionName']);
|
||||
} elseif (isset($options['actionName'])) {
|
||||
|
@ -17,7 +17,7 @@
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: HelpSystem.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
* @version $Id: HelpSystem.php 18305 2009-09-19 16:31:16Z beberlei $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -297,7 +297,9 @@ class Zend_Tool_Framework_Client_Console_HelpSystem
|
||||
'clientName' => 'console'
|
||||
));
|
||||
|
||||
$this->_respondWithCommand($providerMetadata, $actionMetadata, $specialtyMetadata, $actionableSpecialtyLongMetadata);
|
||||
if($actionableSpecialtyLongMetadata) {
|
||||
$this->_respondWithCommand($providerMetadata, $actionMetadata, $specialtyMetadata, $actionableSpecialtyLongMetadata);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@
|
||||
* @subpackage Framework
|
||||
* @copyright Copyright (c) 2005-2009 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
* @version $Id: Manifest.php 16971 2009-07-22 18:05:45Z mikaelkael $
|
||||
* @version $Id: Manifest.php 18951 2009-11-12 16:26:19Z alexander $
|
||||
*/
|
||||
|
||||
/**
|
||||
@ -58,7 +58,7 @@ require_once 'Zend/Tool/Framework/Registry/EnabledInterface.php';
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
class Zend_Tool_Framework_Client_Console_Manifest
|
||||
implements Zend_Tool_Framework_Registry_EnabledInterface,
|
||||
implements Zend_Tool_Framework_Registry_EnabledInterface,
|
||||
Zend_Tool_Framework_Manifest_MetadataManifestable
|
||||
{
|
||||
|
||||
@ -66,7 +66,7 @@ class Zend_Tool_Framework_Client_Console_Manifest
|
||||
* @var Zend_Tool_Framework_Registry_Interface
|
||||
*/
|
||||
protected $_registry = null;
|
||||
|
||||
|
||||
/**
|
||||
* setRegistry() - Required for the Zend_Tool_Framework_Registry_EnabledInterface interface
|
||||
*
|
||||
@ -78,12 +78,12 @@ class Zend_Tool_Framework_Client_Console_Manifest
|
||||
$this->_registry = $registry;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* getMetadata() is required by the Manifest Interface.
|
||||
*
|
||||
*
|
||||
* These are the following metadatas that will be setup:
|
||||
*
|
||||
*
|
||||
* actionName
|
||||
* - metadata for actions
|
||||
* - value will be a dashed name for the action named in 'actionName'
|
||||
@ -102,17 +102,17 @@ class Zend_Tool_Framework_Client_Console_Manifest
|
||||
public function getMetadata()
|
||||
{
|
||||
$metadatas = array();
|
||||
|
||||
|
||||
// setup the camelCase to dashed filter to use since cli expects dashed named
|
||||
$ccToDashedFilter = new Zend_Filter();
|
||||
$ccToDashedFilter
|
||||
->addFilter(new Zend_Filter_Word_CamelCaseToDash())
|
||||
->addFilter(new Zend_Filter_StringToLower());
|
||||
|
||||
|
||||
// get the registry to get the action and provider repository
|
||||
$actionRepository = $this->_registry->getActionRepository();
|
||||
$providerRepository = $this->_registry->getProviderRepository();
|
||||
|
||||
|
||||
// loop through all actions and create a metadata for each
|
||||
foreach ($actionRepository->getActions() as $action) {
|
||||
// each action metadata will be called
|
||||
@ -140,7 +140,7 @@ class Zend_Tool_Framework_Client_Console_Manifest
|
||||
|
||||
// create the metadatas for the per provider specialites in providerSpecaltyNames
|
||||
foreach ($providerSignature->getSpecialties() as $specialty) {
|
||||
|
||||
|
||||
$metadatas[] = new Zend_Tool_Framework_Metadata_Tool(array(
|
||||
'name' => 'specialtyName',
|
||||
'value' => $ccToDashedFilter->filter($specialty),
|
||||
@ -149,25 +149,25 @@ class Zend_Tool_Framework_Client_Console_Manifest
|
||||
'providerName' => $providerSignature->getName(),
|
||||
'specialtyName' => $specialty,
|
||||
'clientReference' => $this->_registry->getClient()
|
||||
));
|
||||
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
// $actionableMethod is keyed by the methodName (but not used)
|
||||
foreach ($providerSignature->getActionableMethods() as $actionableMethodData) {
|
||||
|
||||
|
||||
$methodLongParams = array();
|
||||
$methodShortParams = array();
|
||||
|
||||
|
||||
// $actionableMethodData get both the long and short names
|
||||
foreach ($actionableMethodData['parameterInfo'] as $parameterInfoData) {
|
||||
|
||||
|
||||
// filter to dashed
|
||||
$methodLongParams[$parameterInfoData['name']] = $ccToDashedFilter->filter($parameterInfoData['name']);
|
||||
|
||||
|
||||
// simply lower the character, (its only 1 char after all)
|
||||
$methodShortParams[$parameterInfoData['name']] = strtolower($parameterInfoData['name'][0]);
|
||||
|
||||
|
||||
}
|
||||
|
||||
// create metadata for the long name cliActionableMethodLongParameters
|
||||
@ -181,7 +181,7 @@ class Zend_Tool_Framework_Client_Console_Manifest
|
||||
'reference' => &$actionableMethodData,
|
||||
'clientReference' => $this->_registry->getClient()
|
||||
));
|
||||
|
||||
|
||||
// create metadata for the short name cliActionableMethodShortParameters
|
||||
$metadatas[] = new Zend_Tool_Framework_Metadata_Tool(array(
|
||||
'name' => 'actionableMethodShortParams',
|
||||
@ -197,13 +197,13 @@ class Zend_Tool_Framework_Client_Console_Manifest
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
return $metadatas;
|
||||
}
|
||||
|
||||
|
||||
public function getIndex()
|
||||
{
|
||||
return 10000;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user