public function addGetResultInstantiationInfoMethod()
    {
        $body = '    return null;';
        $responseClass = $this->operationDefinition->getResponseClass();
        if ($responseClass) {
            $responseClass = addslashes($responseClass);
            $body = <<<BODY
        return ['instantiate' => '{$responseClass}'];
BODY;
        }
        $docBlock = new DocBlockGenerator('Return how the result of this operation should be instantiated.');
        $methodGenerator = $this->createMethodGenerator('getResultInstantiationInfo', $body, $docBlock, [], '\\Amp\\Artax\\Response');
        $this->classGenerator->addMethodFromGenerator($methodGenerator);
    }
Ejemplo n.º 2
0
 /**
  * @param $service
  * @param $operationName
  * @param $baseURL
  * @return OperationDefinition
  * @throws \ArtaxServiceBuilder\APIBuilderException
  */
 function createOperationDescription($service, $operationName, $baseURL)
 {
     if (isset($service["operations"][$operationName]) == false) {
         throw new APIBuilderException("Service does not have operation named `{$operationName}`.");
     }
     $operationDescription = $service["operations"][$operationName];
     if (isset($operationDescription['extends'])) {
         $operation = $this->createOperationDescription($service, $operationDescription['extends'], $baseURL);
     } else {
         $operation = new OperationDefinition();
     }
     $operation->setName($operationName);
     $operation->setURL($baseURL);
     //Do this first, as it can be overwritten
     $operation->setFromServiceDescription($operationDescription, $baseURL, $this);
     return $operation;
 }