protected function generateFunction(SwaggerApi $api, SwaggerOperation $operation) { switch ($operation->getHttpMethod()) { case SwaggerOperation::METHOD_GET: $function = new Action\Get(); break; case SwaggerOperation::METHOD_POST: $function = new Action\Post(); break; case SwaggerOperation::METHOD_PUT: $function = new Action\Put(); break; case SwaggerOperation::METHOD_DELETE: $function = new Action\Delete(); break; default: return false; } $function->setApi($api); $function->setOperation($operation); $function->generate(); if (($requestClass = $function->getParameterClassGenerator()) && count($requestClass->getProperties())) { $this->addRequestClass($requestClass); } return $function->getMethodGenerator(); }
public function hydrate($data, Hydrator\HydratorInterface $operationHydrator = null) { if (isset($data['operations']) && ($operations = $data['operations'])) { unset($data['operations']); $operationProto = new Operation(); if ($operationHydrator) { $operationProto->setHydrator($operationHydrator); } foreach ($operations as $operationData) { $operation = clone $operationProto; $operation->hydrate($operationData); $this->addOperation($operation); } } $hydrator = $this->getHydrator(); $hydrator->hydrate($data, $this); return $this; }