예제 #1
0
 /**
  * Handles the "puli type --update" command.
  *
  * @param Args $args The console arguments.
  *
  * @return int The status code.
  */
 public function handleUpdate(Args $args)
 {
     $name = $args->getArgument('name');
     $typeToUpdate = $this->discoveryManager->getRootBindingType($name);
     $bindingParams = $typeToUpdate->getParameters();
     $description = $typeToUpdate->getDescription();
     $paramDescriptions = array();
     // Collect existing parameter descriptions
     foreach ($bindingParams as $parameter) {
         $paramDescriptions[$parameter->getName()] = $parameter->getDescription();
     }
     $this->parsesParamDescriptions($args, $paramDescriptions);
     $this->parseParams($args, $paramDescriptions, $bindingParams);
     $this->updateParamDescriptions($paramDescriptions, $bindingParams);
     $this->parseUnsetParams($args, $bindingParams);
     if ($args->isOptionSet('description')) {
         $description = $args->getOption('description');
     }
     $updatedType = new BindingTypeDescriptor($name, $description, $bindingParams);
     if ($this->typesEqual($typeToUpdate, $updatedType)) {
         throw new RuntimeException('Nothing to update.');
     }
     $this->discoveryManager->addRootBindingType($updatedType, DiscoveryManager::OVERRIDE);
     return 0;
 }