コード例 #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');
     $descriptorToUpdate = $this->discoveryManager->getRootTypeDescriptor($name);
     $bindingParams = $descriptorToUpdate->getType()->getParameters();
     $description = $descriptorToUpdate->getDescription();
     $paramDescriptions = $descriptorToUpdate->getParameterDescriptions();
     $this->parseParamDescriptions($args, $paramDescriptions);
     $this->parseParams($args, $bindingParams);
     $this->parseUnsetParams($args, $bindingParams, $paramDescriptions);
     if ($args->isOptionSet('description')) {
         $description = $args->getOption('description');
     }
     $updatedDescriptor = new BindingTypeDescriptor(new BindingType($name, $bindingParams), $description, $paramDescriptions);
     if ($this->typesEqual($descriptorToUpdate, $updatedDescriptor)) {
         throw new RuntimeException('Nothing to update.');
     }
     $this->discoveryManager->addRootTypeDescriptor($updatedDescriptor, DiscoveryManager::OVERRIDE);
     return 0;
 }