xima-media /
depmon
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Xima\DepmonBundle\Controller; |
||
| 4 | |||
| 5 | |||
| 6 | use Symfony\Bundle\FrameworkBundle\Console\Application; |
||
| 7 | use Symfony\Component\Console\Input\ArrayInput; |
||
|
0 ignored issues
–
show
|
|||
| 8 | use Symfony\Component\Console\Output\BufferedOutput; |
||
|
0 ignored issues
–
show
The type
Symfony\Component\Console\Output\BufferedOutput was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 9 | use Symfony\Component\HttpFoundation\JsonResponse; |
||
| 10 | use Symfony\Component\HttpFoundation\ResponseHeaderBag; |
||
| 11 | use Symfony\Component\HttpKernel\KernelInterface; |
||
| 12 | use Symfony\Component\Routing\Exception\InvalidParameterException; |
||
| 13 | use Xima\DepmonBundle\Service\Cache; |
||
| 14 | use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; |
||
| 15 | use Symfony\Component\HttpFoundation\Response; |
||
| 16 | use Symfony\Component\Yaml\Yaml; |
||
|
0 ignored issues
–
show
The type
Symfony\Component\Yaml\Yaml was not found. Maybe you did not declare it correctly or list all dependencies?
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. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 17 | |||
| 18 | /** |
||
| 19 | * Class DefaultController |
||
| 20 | * @package Xima\DepmonBundle\Controller |
||
| 21 | */ |
||
| 22 | class DefaultController extends AbstractController |
||
| 23 | { |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @var Cache |
||
| 27 | */ |
||
| 28 | private $cache; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * @var KernelInterface |
||
| 32 | */ |
||
| 33 | private $kernel; |
||
| 34 | |||
| 35 | /** |
||
| 36 | * DefaultController constructor. |
||
| 37 | * @param Cache $cache |
||
| 38 | */ |
||
| 39 | public function __construct(Cache $cache, KernelInterface $kernel) |
||
| 40 | { |
||
| 41 | $this->cache = $cache; |
||
| 42 | $this->kernel = $kernel; |
||
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Index action. |
||
| 47 | * @return Response |
||
| 48 | */ |
||
| 49 | public function index(): Response |
||
| 50 | { |
||
| 51 | $projects = []; |
||
| 52 | $error = null; |
||
| 53 | |||
| 54 | $projectsConfig = $this->getParameter('xima_depmon.projects'); |
||
| 55 | |||
| 56 | if (is_array($projectsConfig)) { |
||
| 57 | foreach ($projectsConfig as $project) { |
||
| 58 | $projects[] = $this->cache->get($project['name']); |
||
| 59 | } |
||
| 60 | } else { |
||
| 61 | $error = 1; |
||
| 62 | } |
||
| 63 | $metadata = $this->cache->get('metadata'); |
||
| 64 | |||
| 65 | if (empty($projects)) { |
||
| 66 | $error = 2; |
||
| 67 | } |
||
| 68 | |||
| 69 | return $this->render('@XimaDepmon/index.html.twig', [ |
||
| 70 | 'projects' => $projects, |
||
| 71 | 'metadata' => $metadata, |
||
| 72 | 'error' => $error |
||
| 73 | ]); |
||
| 74 | } |
||
| 75 | |||
| 76 | /** |
||
| 77 | * Detail action |
||
| 78 | * @param string $projectName |
||
| 79 | * @return Response |
||
| 80 | */ |
||
| 81 | public function detail($project): Response |
||
| 82 | { |
||
| 83 | $projects = []; |
||
| 84 | $error = null; |
||
| 85 | |||
| 86 | $projectsConfig = $this->getParameter('xima_depmon.projects'); |
||
| 87 | if (is_array($projectsConfig)) { |
||
| 88 | foreach ($projectsConfig as $projectData) { |
||
| 89 | if ($project == $projectData['name']) { |
||
| 90 | $projects[] = $this->cache->get($projectData['name']); |
||
| 91 | } |
||
| 92 | } |
||
| 93 | } else { |
||
| 94 | $error = 1; |
||
| 95 | } |
||
| 96 | $metadata = $this->cache->get('metadata'); |
||
| 97 | |||
| 98 | if (empty($projects)) { |
||
| 99 | $error = 3; |
||
| 100 | } |
||
| 101 | |||
| 102 | return $this->render('@XimaDepmon/index.html.twig', [ |
||
| 103 | 'projects' => $projects, |
||
| 104 | 'metadata' => $metadata, |
||
| 105 | 'detail' => $project, |
||
| 106 | 'error' => $error |
||
| 107 | ]); |
||
| 108 | } |
||
| 109 | |||
| 110 | /** |
||
| 111 | * State action for checking the summary dependency state of a project and returning a SVG. |
||
| 112 | * @param string $project |
||
| 113 | * @return Response |
||
| 114 | */ |
||
| 115 | public function state($project): Response |
||
| 116 | { |
||
| 117 | $data = $this->cache->get($project); |
||
| 118 | if ($data == '') { |
||
| 119 | throw $this->createNotFoundException("No data for project \"$project\" found."); |
||
| 120 | } |
||
| 121 | $state = $data['meta']['projectState']; |
||
| 122 | |||
| 123 | $filename = $project . ".svg"; |
||
| 124 | $response = new Response(); |
||
| 125 | $response->headers->set('Cache-Control', 'private'); |
||
| 126 | $response->headers->set('Content-type', 'image/svg+xml'); |
||
| 127 | $response->headers->set('Content-Disposition', |
||
| 128 | 'filename="' . basename($filename) . '";'); |
||
| 129 | $response->sendHeaders(); |
||
| 130 | |||
| 131 | readfile(__DIR__ . "/../Resources/public/img/states/$state.svg"); |
||
| 132 | |||
| 133 | return $response; |
||
| 134 | } |
||
| 135 | |||
| 136 | /** |
||
| 137 | * Update action |
||
| 138 | * @return JsonResponse |
||
| 139 | */ |
||
| 140 | public function update(KernelInterface $kernel): JsonResponse |
||
| 141 | { |
||
| 142 | $application = new Application($kernel); |
||
| 143 | $application->setAutoExit(false); |
||
| 144 | |||
| 145 | $input = new ArrayInput(array( |
||
| 146 | 'command' => 'depmon:aggregate' |
||
| 147 | )); |
||
| 148 | |||
| 149 | $output = new BufferedOutput(); |
||
| 150 | $application->run($input, $output); |
||
| 151 | |||
| 152 | $content = $output->fetch(); |
||
| 153 | $httpResponseCode = 200; |
||
| 154 | |||
| 155 | if ($application->areExceptionsCaught()) { |
||
| 156 | $httpResponseCode = 500; |
||
| 157 | } |
||
| 158 | |||
| 159 | return new JsonResponse($content, $httpResponseCode); |
||
| 160 | } |
||
| 161 | } |
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