/**
  * Handles incoming requests.
  *
  * @return void Handle the request and output a response.
  */
 public final function handle()
 {
     $this->_isDebugEnabled = $this->_logger->isHandling(ehough_epilog_Logger::DEBUG);
     if ($this->_isDebugEnabled) {
         $this->_logger->debug('Handling incoming request');
     }
     $httpRequestParameterService = tubepress_impl_patterns_sl_ServiceLocator::getHttpRequestParameterService();
     $httpResponseCodeHandler = tubepress_impl_patterns_sl_ServiceLocator::getHttpResponseCodeHandler();
     $actionName = $httpRequestParameterService->getParamValue(tubepress_spi_const_http_ParamName::ACTION);
     if ($actionName == '') {
         $httpResponseCodeHandler->setResponseCode(400);
         echo 'Missing "action" parameter';
         return;
     }
     $chosenCommandHandler = null;
     if ($this->_isDebugEnabled) {
         $this->_logger->debug('There are ' . count($this->_commandHandlers) . ' pluggable Ajax command service(s) registered');
     }
     /**
      * @var $commandHandler tubepress_spi_http_PluggableAjaxCommandService
      */
     foreach ($this->_commandHandlers as $commandHandler) {
         if ($commandHandler->getName() === $actionName) {
             $chosenCommandHandler = $commandHandler;
             break;
         }
         if ($this->_isDebugEnabled) {
             $this->_logger->debug($commandHandler->getName() . ' could not handle action ' . $actionName);
         }
     }
     if ($chosenCommandHandler === null) {
         if ($this->_isDebugEnabled) {
             $this->_logger->debug('No pluggable Ajax command services could handle action ' . $actionName);
         }
         $httpResponseCodeHandler->setResponseCode(500);
         return;
     }
     if ($this->_isDebugEnabled) {
         $this->_logger->debug($chosenCommandHandler->getName() . ' chose to handle action ' . $actionName);
     }
     $chosenCommandHandler->handle();
     $httpResponseCodeHandler->setResponseCode($chosenCommandHandler->getHttpStatusCode());
     echo $chosenCommandHandler->getOutput();
 }