@@ -11,24 +11,24 @@ |
||
11 | 11 | |
12 | 12 | class PublicDirectory |
13 | 13 | { |
14 | - /** |
|
15 | - * @param $projectDir |
|
16 | - * |
|
17 | - * @return bool|string |
|
18 | - */ |
|
19 | - public static function getPublicDir($projectDir) |
|
20 | - { |
|
21 | - $webDir = "$projectDir/web/"; |
|
22 | - $publicDir = "$projectDir/public/"; |
|
14 | + /** |
|
15 | + * @param $projectDir |
|
16 | + * |
|
17 | + * @return bool|string |
|
18 | + */ |
|
19 | + public static function getPublicDir($projectDir) |
|
20 | + { |
|
21 | + $webDir = "$projectDir/web/"; |
|
22 | + $publicDir = "$projectDir/public/"; |
|
23 | 23 | |
24 | - if (file_exists($webDir)) { |
|
25 | - return $webDir; |
|
26 | - } |
|
24 | + if (file_exists($webDir)) { |
|
25 | + return $webDir; |
|
26 | + } |
|
27 | 27 | |
28 | - if (file_exists($publicDir)) { |
|
29 | - return $publicDir; |
|
30 | - } |
|
28 | + if (file_exists($publicDir)) { |
|
29 | + return $publicDir; |
|
30 | + } |
|
31 | 31 | |
32 | - return false; |
|
33 | - } |
|
32 | + return false; |
|
33 | + } |
|
34 | 34 | } |
35 | 35 | \ No newline at end of file |
@@ -17,15 +17,15 @@ discard block |
||
17 | 17 | |
18 | 18 | class ResponseManager |
19 | 19 | { |
20 | - /** |
|
21 | - * @var GuzzleResponse |
|
22 | - */ |
|
23 | - protected $response; |
|
20 | + /** |
|
21 | + * @var GuzzleResponse |
|
22 | + */ |
|
23 | + protected $response; |
|
24 | 24 | |
25 | - /** |
|
26 | - * @var string |
|
27 | - */ |
|
28 | - protected $projectDir; |
|
25 | + /** |
|
26 | + * @var string |
|
27 | + */ |
|
28 | + protected $projectDir; |
|
29 | 29 | |
30 | 30 | /** |
31 | 31 | * ResponseManager constructor. |
@@ -33,55 +33,55 @@ discard block |
||
33 | 33 | * @param ResponseInterface $response |
34 | 34 | * @param string $projectDir |
35 | 35 | */ |
36 | - public function __construct(ResponseInterface $response, $projectDir = __DIR__) |
|
37 | - { |
|
38 | - $this->response = $response; |
|
39 | - $this->projectDir = $projectDir; |
|
40 | - } |
|
36 | + public function __construct(ResponseInterface $response, $projectDir = __DIR__) |
|
37 | + { |
|
38 | + $this->response = $response; |
|
39 | + $this->projectDir = $projectDir; |
|
40 | + } |
|
41 | 41 | |
42 | - /** |
|
43 | - * @return BinaryFileResponse|Response |
|
44 | - */ |
|
45 | - public function getResponse() |
|
46 | - { |
|
47 | - if ($this->response->hasHeader('Content-Disposition')) { |
|
48 | - return $this->getBinaryFileResponse(); |
|
49 | - } |
|
42 | + /** |
|
43 | + * @return BinaryFileResponse|Response |
|
44 | + */ |
|
45 | + public function getResponse() |
|
46 | + { |
|
47 | + if ($this->response->hasHeader('Content-Disposition')) { |
|
48 | + return $this->getBinaryFileResponse(); |
|
49 | + } |
|
50 | 50 | |
51 | - return $this->getHttpResponse(); |
|
52 | - } |
|
51 | + return $this->getHttpResponse(); |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * @return BinaryFileResponse |
|
56 | - */ |
|
57 | - protected function getBinaryFileResponse() |
|
58 | - { |
|
59 | - $projectDir = PublicDirectory::getPublicDir($this->projectDir); |
|
60 | - $filename = $projectDir.mt_rand(); |
|
54 | + /** |
|
55 | + * @return BinaryFileResponse |
|
56 | + */ |
|
57 | + protected function getBinaryFileResponse() |
|
58 | + { |
|
59 | + $projectDir = PublicDirectory::getPublicDir($this->projectDir); |
|
60 | + $filename = $projectDir.mt_rand(); |
|
61 | 61 | |
62 | - $fileSystem = new Filesystem(); |
|
63 | - $fileSystem->dumpFile( |
|
64 | - $filename, |
|
65 | - $this->response->getBody()->getContents() |
|
66 | - ); |
|
62 | + $fileSystem = new Filesystem(); |
|
63 | + $fileSystem->dumpFile( |
|
64 | + $filename, |
|
65 | + $this->response->getBody()->getContents() |
|
66 | + ); |
|
67 | 67 | |
68 | - return ( |
|
69 | - new BinaryFileResponse( |
|
70 | - $filename, |
|
71 | - $this->response->getStatusCode(), |
|
72 | - $this->response->getHeaders() |
|
73 | - ) |
|
74 | - )->deleteFileAfterSend(true); |
|
75 | - } |
|
68 | + return ( |
|
69 | + new BinaryFileResponse( |
|
70 | + $filename, |
|
71 | + $this->response->getStatusCode(), |
|
72 | + $this->response->getHeaders() |
|
73 | + ) |
|
74 | + )->deleteFileAfterSend(true); |
|
75 | + } |
|
76 | 76 | |
77 | - /** |
|
78 | - * @return Response |
|
79 | - */ |
|
80 | - protected function getHttpResponse() |
|
81 | - { |
|
82 | - $response = new Response($this->response->getBody()); |
|
83 | - $response->setStatusCode($this->response->getStatusCode()); |
|
77 | + /** |
|
78 | + * @return Response |
|
79 | + */ |
|
80 | + protected function getHttpResponse() |
|
81 | + { |
|
82 | + $response = new Response($this->response->getBody()); |
|
83 | + $response->setStatusCode($this->response->getStatusCode()); |
|
84 | 84 | |
85 | - return $response; |
|
86 | - } |
|
85 | + return $response; |
|
86 | + } |
|
87 | 87 | } |
88 | 88 | \ No newline at end of file |
@@ -42,19 +42,19 @@ |
||
42 | 42 | /** @var Client $client */ |
43 | 43 | $client = $this->get($guzzleServiceName); |
44 | 44 | |
45 | - $contentType = RequestMethodMapping::$contentTypes[$method]; |
|
46 | - $methodName = RequestMethodMapping::$methodsMapping[$method]; |
|
45 | + $contentType = RequestMethodMapping::$contentTypes[$method]; |
|
46 | + $methodName = RequestMethodMapping::$methodsMapping[$method]; |
|
47 | 47 | |
48 | 48 | /** @var ResponseInterface $guzzleResponse */ |
49 | 49 | $guzzleResponse = $client->{$method}( |
50 | 50 | $params->getRouteId(), |
51 | 51 | [ |
52 | - $contentType => $request->{$methodName}->all() |
|
52 | + $contentType => $request->{$methodName}->all() |
|
53 | 53 | ] |
54 | 54 | ); |
55 | 55 | |
56 | - return ( |
|
57 | - new ResponseManager($guzzleResponse, $this->container->getParameter('kernel.project_dir')) |
|
56 | + return ( |
|
57 | + new ResponseManager($guzzleResponse, $this->container->getParameter('kernel.project_dir')) |
|
58 | 58 | )->getResponse(); |
59 | 59 | } |
60 | 60 |
@@ -42,8 +42,8 @@ |
||
42 | 42 | /** @var Client $client */ |
43 | 43 | $client = $this->get($guzzleServiceName); |
44 | 44 | |
45 | - $contentType = RequestMethodMapping::$contentTypes[$method]; |
|
46 | - $methodName = RequestMethodMapping::$methodsMapping[$method]; |
|
45 | + $contentType = RequestMethodMapping::$contentTypes[ $method ]; |
|
46 | + $methodName = RequestMethodMapping::$methodsMapping[ $method ]; |
|
47 | 47 | |
48 | 48 | /** @var ResponseInterface $guzzleResponse */ |
49 | 49 | $guzzleResponse = $client->{$method}( |