Esempio n. 1
0
 /**
  * Lists all API calls for a specific service
  *
  * @param Console\Input\InputInterface $input The input interface
  * @param Console\Output\OutputInterface $output The output interface
  * @throws PartKeepr\Console\Commands\Exceptions\ServiceNotFoundException If the call was not found in the service
  * @see Console\Command\Command
  */
 protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
 {
     $service = $input->getArgument("service");
     if (substr($service, -7) == "Service") {
         $service = substr($service, 0, strlen($service) - 7);
     }
     $className = "PartKeepr\\" . $service . "\\" . $service . "Service";
     if (!class_exists($className)) {
         throw new ServiceNotFoundException(sprintf("The service %s doesn't exist", $service));
     }
     $reflector = new ServiceReflector($className);
     // Stores the maximum length, for nice console formatting
     $maxLength = 0;
     foreach ($reflector->getCalls() as $call) {
         if (strlen($call->getName()) > $maxLength) {
             $maxLength = strlen($call->getName());
         }
     }
     $output->writeln(sprintf("<comment>Calls for service <info>%s</info>:</comment>", $reflector->getName()));
     $output->writeln("");
     foreach ($reflector->getCalls() as $call) {
         $name = str_pad($call->getName(), $maxLength);
         $output->writeln(sprintf("<info>%s</info>  %s", $name, $call->getDescription()));
     }
 }
 /**
  * Lists all API services
  *
  * @param Console\Input\InputInterface $input The input interface
  * @param Console\Output\OutputInterface $output The output interface
  * @see Console\Command\Command
  */
 protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
 {
     $classNames = ServiceManager::getInstance()->getRegisteredServices();
     $services = array();
     // Stores the maximum length, for nice console formatting
     $maxLength = 0;
     foreach ($classNames as $className) {
         $reflector = new ServiceReflector($className);
         if (strlen($reflector->getName()) > $maxLength) {
             $maxLength = strlen($reflector->getName());
         }
         $services[] = $reflector;
     }
     $output->writeln("<comment>PartKeepr Services:</comment>");
     $output->writeln("");
     foreach ($services as $service) {
         $name = str_pad($service->getName(), $maxLength);
         $output->writeln(sprintf("<info>%s</info>  %s", $name, $service->getDescription()));
     }
 }
 /**
  * Describes a specific call.
  *
  * @param Console\Input\InputInterface $input The input interface
  * @param Console\Output\OutputInterface $output The output interface
  * @throws PartKeepr\Console\Commands\Exceptions\ServiceCallNotFoundException If the call was not found in the service
  * @see Console\Command\Command
  */
 protected function execute(Console\Input\InputInterface $input, Console\Output\OutputInterface $output)
 {
     $service = $input->getArgument("service");
     if (substr($service, -7) == "Service") {
         $service = substr($service, 0, strlen($service) - 7);
     }
     $className = "PartKeepr\\" . $service . "\\" . $service . "Service";
     if (!class_exists($className)) {
         throw new \Exception(sprintf("The service %s doesn't exist", $service));
     }
     $reflector = new ServiceReflector($className);
     $call = $reflector->getCall($input->getArgument("call"));
     if (!$call instanceof \PartKeepr\Service\ServiceCallReflector) {
         throw new ServiceCallNotFoundException(sprintf("The call %s was not found in the service %s", $input->getArgument("call"), $service));
     }
     $output->writeln(sprintf("<info>%s:%s</info>: %s", $service, $input->getArgument("call"), $call->getDescription()));
     $output->writeln("");
     $output->writeln($call->getDocumentation());
     $output->writeln("");
     $this->outputParameterTable($call, $output);
     $output->writeln("");
     $this->outputReturnedValuesTable($call, $output);
 }