예제 #1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $logger = new ConsoleLogger($output);
     try {
         $this->getSecretKey();
         $forest = $this->getContainer()->get('forestadmin.forest');
         if ($forest->postApimap()) {
             $text = 'Success!';
         } else {
             $logger->error('Could not post API map for an unknown reason.');
             $text = 'Failure!';
         }
     } catch (ClientException $exc) {
         $logger->error('Client Failure: ' . $exc->getMessage());
         $text = 'Cannot contact the client.';
     } catch (RequestException $exc) {
         $logger->critical('Request Failure: ' . $exc->getMessage());
         $text = 'Malformed request.';
     } catch (InvalidArgumentException $exc) {
         $logger->debug('Client tried to contact us without secret key');
         $text = "Failure: " . $exc->getMessage() . "\n" . "Configure your secret key with the key you received when you registered your app to Forest.";
     } catch (\Exception $exc) {
         $logger->error('Unexpected exception triggered: ' . $exc->getMessage());
         $text = get_class($exc) . ' Failure: ' . $exc->getMessage();
     }
     $output->writeln($text);
 }