Example #1
0
 /**
  * respondWithErrorMessage()
  *
  * @param string $errorMessage
  * @param Exception $exception
  */
 public function respondWithErrorMessage($errorMessage, \Exception $exception = null)
 {
     // break apart the message into wrapped chunks
     $errorMessages = explode(PHP_EOL, wordwrap($errorMessage, 70, PHP_EOL, false));
     $text = 'An Error Has Occurred';
     $this->_response->appendContent($text, array('color' => array('hiWhite', 'bgRed'), 'aligncenter' => true));
     $this->_response->appendContent($errorMessage, array('indention' => 1, 'blockize' => 72, 'color' => array('white', 'bgRed')));
     if ($exception && $this->_registry->getRequest()->isDebug()) {
         $this->_response->appendContent($exception->getTraceAsString());
     }
     $this->_response->appendContent(null, array('separator' => true));
     return $this;
 }
Example #2
0
 /**
  * setRegistry()
  *
  * @param \Zend\Tool\Framework\Registry $registry
  * @return \Zend\Tool\Framework\Client\Console\ArgumentParser
  */
 public function setRegistry(Registry $registry)
 {
     // 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;
 }
Example #3
0
 protected function _handleDispatch()
 {
     // get the provider repository
     $providerRepository = $this->_registry->getProviderRepository();
     $request = $this->_registry->getRequest();
     // get the dispatchable provider signature
     $providerSignature = $providerRepository->getProviderSignature($request->getProviderName());
     // get the actual provider
     $provider = $providerSignature->getProvider();
     // ensure that we can pretend if this is a pretend request
     if ($request->isPretend() && !$provider instanceof \Zend\Tool\Framework\Provider\Pretendable) {
         throw new Exception('Dispatcher error - provider does not support pretend');
     }
     // get the action name
     $actionName = $this->_registry->getRequest()->getActionName();
     $specialtyName = $this->_registry->getRequest()->getSpecialtyName();
     if (!($actionableMethod = $providerSignature->getActionableMethodByActionName($actionName, $specialtyName))) {
         throw new Exception('Dispatcher error - actionable method not found');
     }
     // get the actual method and param information
     $methodName = $actionableMethod['methodName'];
     $methodParameters = $actionableMethod['parameterInfo'];
     // get the provider params
     $requestParameters = $this->_registry->getRequest()->getProviderParameters();
     // @todo This seems hackish, determine if there is a better way
     $callParameters = array();
     foreach ($methodParameters as $methodParameterName => $methodParameterValue) {
         if (!array_key_exists($methodParameterName, $requestParameters) && $methodParameterValue['optional'] == false) {
             if ($this instanceof Interactive\InteractiveInput) {
                 $promptSting = $this->getMissingParameterPromptString($provider, $actionableMethod['action'], $methodParameterValue['name']);
                 $parameterPromptValue = $this->promptInteractiveInput($promptSting)->getContent();
                 if ($parameterPromptValue == null) {
                     throw new Exception('Value supplied for required parameter "' . $methodParameterValue['name'] . '" is empty');
                 }
                 $callParameters[] = $parameterPromptValue;
             } else {
                 throw new Exception('A required parameter "' . $methodParameterValue['name'] . '" was not supplied.');
             }
         } else {
             $callParameters[] = array_key_exists($methodParameterName, $requestParameters) ? $requestParameters[$methodParameterName] : $methodParameterValue['default'];
         }
     }
     $this->_handleDispatchExecution($provider, $methodName, $callParameters);
 }