|
@@ -55,14 +55,12 @@ abstract class AbstractGenerator
|
|
|
$headers[] = "HTTP_HOST: {$routeDomain}";
|
|
|
$headers[] = "SERVER_NAME: {$routeDomain}";
|
|
|
|
|
|
- $content = '';
|
|
|
$response = null;
|
|
|
$docblockResponse = $this->getDocblockResponse($routeDescription['tags']);
|
|
|
if ($docblockResponse) {
|
|
|
// we have a response from the docblock ( @response )
|
|
|
$response = $docblockResponse;
|
|
|
$showresponse = true;
|
|
|
- $content = $response->getContent();
|
|
|
}
|
|
|
if (! $response) {
|
|
|
$transformerResponse = $this->getTransformerResponse($routeDescription['tags']);
|
|
@@ -70,22 +68,17 @@ abstract class AbstractGenerator
|
|
|
// we have a transformer response from the docblock ( @transformer || @transformercollection )
|
|
|
$response = $transformerResponse;
|
|
|
$showresponse = true;
|
|
|
- $content = $response->getContent();
|
|
|
}
|
|
|
}
|
|
|
if (! $response && $withResponse) {
|
|
|
try {
|
|
|
$response = $this->getRouteResponse($route, $bindings, $headers);
|
|
|
- if ($response->headers->get('Content-Type') === 'application/json') {
|
|
|
- $content = json_decode($response->getContent(), JSON_PRETTY_PRINT);
|
|
|
- } else {
|
|
|
- $content = $response->getContent();
|
|
|
- }
|
|
|
} catch (\Exception $e) {
|
|
|
dump("Couldn't get response for route: ".implode(',', $this->getMethods($route)).'] '.$route->uri().'', $e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ $content = $this->getResponseContent($response);
|
|
|
return $this->getParameters([
|
|
|
'id' => md5($this->getUri($route).':'.implode($this->getMethods($route))),
|
|
|
'resource' => $routeGroup,
|
|
@@ -665,4 +658,21 @@ abstract class AbstractGenerator
|
|
|
return $rule;
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param $response
|
|
|
+ * @return mixed
|
|
|
+ */
|
|
|
+ private function getResponseContent($response)
|
|
|
+ {
|
|
|
+ if (empty($response)) {
|
|
|
+ return '';
|
|
|
+ }
|
|
|
+ if ($response->headers->get('Content-Type') === 'application/json') {
|
|
|
+ $content = json_decode($response->getContent(), JSON_PRETTY_PRINT);
|
|
|
+ } else {
|
|
|
+ $content = $response->getContent();
|
|
|
+ }
|
|
|
+ return $content;
|
|
|
+ }
|
|
|
}
|