|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* MIT License |
|
5
|
|
|
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. |
|
6
|
|
|
*/ |
|
7
|
|
|
|
|
8
|
|
|
namespace SprykerEco\Zed\Econda\Communication\Controller; |
|
9
|
|
|
|
|
10
|
|
|
use Spryker\Zed\Kernel\Communication\Controller\AbstractController; |
|
|
|
|
|
|
11
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
|
|
|
|
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* @method \SprykerEco\Zed\Econda\Business\EcondaFacadeInterface getFacade() |
|
15
|
|
|
*/ |
|
16
|
|
|
class IndexController extends AbstractController |
|
17
|
|
|
{ |
|
18
|
|
|
|
|
19
|
|
|
const CATEGORIES = 'categories'; |
|
20
|
|
|
const PRODUCTS = 'products'; |
|
21
|
|
|
|
|
22
|
|
|
/** |
|
23
|
|
|
* @param \Symfony\Component\HttpFoundation\Request $request |
|
24
|
|
|
* |
|
25
|
|
|
* @return \Symfony\Component\HttpFoundation\StreamedResponse |
|
|
|
|
|
|
26
|
|
|
*/ |
|
27
|
|
View Code Duplication |
public function categoryAction(Request $request) |
|
|
|
|
|
|
28
|
|
|
{ |
|
29
|
|
|
$response = $this->getFacade()->getFileContent(self::CATEGORIES, $this->getLocale($request)); |
|
30
|
|
|
|
|
31
|
|
|
return $this->streamedResponse( |
|
32
|
|
|
function () use ($response) { |
|
33
|
|
|
echo $response; |
|
34
|
|
|
}, |
|
35
|
|
|
200, |
|
36
|
|
|
["Content-type" => "text/csv", 'Content-Disposition' => 'attachment; filename="categories.csv"'] |
|
37
|
|
|
); |
|
38
|
|
|
} |
|
39
|
|
|
|
|
40
|
|
|
/** |
|
41
|
|
|
* @param \Symfony\Component\HttpFoundation\Request $request |
|
42
|
|
|
* |
|
43
|
|
|
* @return \Symfony\Component\HttpFoundation\StreamedResponse |
|
44
|
|
|
*/ |
|
45
|
|
View Code Duplication |
public function productAction(Request $request) |
|
|
|
|
|
|
46
|
|
|
{ |
|
47
|
|
|
$response = $this->getFacade()->getFileContent(self::PRODUCTS, $this->getLocale($request)); |
|
48
|
|
|
|
|
49
|
|
|
return $this->streamedResponse( |
|
50
|
|
|
function () use ($response) { |
|
51
|
|
|
echo $response; |
|
52
|
|
|
}, |
|
53
|
|
|
200, |
|
54
|
|
|
["Content-type" => "text/csv", 'Content-Disposition' => 'attachment; filename="products.csv"'] |
|
55
|
|
|
); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
/** |
|
59
|
|
|
* @param \Symfony\Component\HttpFoundation\Request $request |
|
60
|
|
|
* |
|
61
|
|
|
* @return string |
|
62
|
|
|
*/ |
|
63
|
|
|
protected function getLocale(Request $request) |
|
64
|
|
|
{ |
|
65
|
|
|
if ($request->query->get('locale') !== null) { |
|
66
|
|
|
return $request->query->get('locale'); |
|
67
|
|
|
} |
|
68
|
|
|
return $this->getApplication()['locale']; |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
} |
|
72
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths