/** * {@inheritdoc} */ protected function handleParsing(AbstractCommand $command, Response $response, $contentType) { $operation = $command->getOperation(); $type = $operation->getResponseType(); $model = null; if ($type == OperationInterface::TYPE_MODEL) { $model = $operation->getServiceDescription()->getModel($operation->getResponseClass()); } elseif ($type == OperationInterface::TYPE_CLASS) { $responseClassInterface = __NAMESPACE__ . '\\ResponseClassInterface'; $className = $operation->getResponseClass(); if (!class_exists($className)) { throw new ResponseClassException("{$className} does not exist"); } elseif (!is_subclass_of($className, $responseClassInterface)) { throw new ResponseClassException("{$className} must implement {$responseClassInterface}"); } return $className::fromCommand($command); } if (!$model) { // Return basic processing if the responseType is not model or the model cannot be found return parent::handleParsing($command, $response, $contentType); } elseif ($command->get(AbstractCommand::RESPONSE_PROCESSING) != AbstractCommand::TYPE_MODEL) { // Returns a model with no visiting if the command response processing is not model return new Model(parent::handleParsing($command, $response, $contentType), $model); } else { return new Model($this->visitResult($model, $command, $response), $model); } }
/** * {@inheritdoc} */ protected function handleParsing(AbstractCommand $command, Response $response, $contentType) { $operation = $command->getOperation(); $model = $operation->getResponseType() == OperationInterface::TYPE_MODEL ? $operation->getServiceDescription()->getModel($operation->getResponseClass()) : null; if (!$model) { // Return basic processing if the responseType is not model or the model cannot be found return parent::handleParsing($command, $response, $contentType); } elseif ($command->get(AbstractCommand::RESPONSE_PROCESSING) != AbstractCommand::TYPE_MODEL) { // Returns a model with no visiting if the command response processing is not model return new Model(parent::handleParsing($command, $response, $contentType), $model); } else { return new Model($this->visitResult($model, $command, $response), $model); } }
protected function handleParsing(CommandInterface $command, Response $response, $contentType) { $operation = $command->getOperation(); $type = $operation->getResponseType(); $model = null; if ($type == OperationInterface::TYPE_MODEL) { $model = $operation->getServiceDescription()->getModel($operation->getResponseClass()); } elseif ($type == OperationInterface::TYPE_CLASS) { return $this->parseClass($command); } if (!$model) { return parent::handleParsing($command, $response, $contentType); } elseif ($command[AbstractCommand::RESPONSE_PROCESSING] != AbstractCommand::TYPE_MODEL) { return new Model(parent::handleParsing($command, $response, $contentType)); } else { return new Model($this->visitResult($model, $command, $response), $this->schemaInModels ? $model : null); } }
protected function handleParsing(CommandInterface $command, Response $response, $contentType) { $operation = $command->getOperation(); $type = $operation->getResponseType(); $model = null; if ($type == OperationInterface::TYPE_MODEL) { $model = $operation->getServiceDescription()->getModel($operation->getResponseClass()); } elseif ($type == OperationInterface::TYPE_CLASS) { return $this->parseClass($command); } if (!$model) { // Return basic processing if the responseType is not model or the model cannot be found return parent::handleParsing($command, $response, $contentType); } elseif ($command[AbstractCommand::RESPONSE_PROCESSING] != AbstractCommand::TYPE_MODEL) { // Returns a model with no visiting if the command response processing is not model return new Model(parent::handleParsing($command, $response, $contentType)); } else { // Only inject the schema into the model if "schemaInModel" is true return new Model($this->visitResult($model, $command, $response), $this->schemaInModels ? $model : null); } }