1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of the thealternativezurich/feedback project. |
5
|
|
|
* |
6
|
|
|
* (c) Florian Moser <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace App\Controller\Base; |
13
|
|
|
|
14
|
|
|
use App\Entity\FrontendUser; |
|
|
|
|
15
|
|
|
use App\Model\Breadcrumb; |
16
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; |
17
|
|
|
use Symfony\Component\HttpFoundation\Response; |
18
|
|
|
use Symfony\Component\Security\Csrf\TokenStorage\TokenStorageInterface; |
19
|
|
|
use Symfony\Component\Translation\TranslatorInterface; |
20
|
|
|
|
21
|
|
|
class BaseController extends AbstractController |
22
|
|
|
{ |
23
|
|
|
public static function getSubscribedServices() |
24
|
|
|
{ |
25
|
|
|
return parent::getSubscribedServices() + |
26
|
|
|
[ |
27
|
|
|
'security.token_storage' => TokenStorageInterface::class, |
28
|
|
|
'translator' => TranslatorInterface::class, |
29
|
|
|
]; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @return TranslatorInterface |
34
|
|
|
*/ |
35
|
|
|
protected function getTranslator() |
36
|
|
|
{ |
37
|
|
|
return $this->get('translator'); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
/** |
41
|
|
|
* @param string $message the translation message to display |
42
|
|
|
* @param string $link |
43
|
|
|
*/ |
44
|
|
|
protected function displayError($message, $link = null) |
45
|
|
|
{ |
46
|
|
|
$this->displayFlash('danger', $message, $link); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* @param string $message the translation message to display |
51
|
|
|
* @param string $link |
52
|
|
|
*/ |
53
|
|
|
protected function displaySuccess($message, $link = null) |
54
|
|
|
{ |
55
|
|
|
$this->displayFlash('success', $message, $link); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @param string $message the translation message to display |
60
|
|
|
* @param string $link |
61
|
|
|
*/ |
62
|
|
|
protected function displayInfo($message, $link = null) |
63
|
|
|
{ |
64
|
|
|
$this->displayFlash('info', $message, $link); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @param $type |
69
|
|
|
* @param $message |
70
|
|
|
* @param string $link |
71
|
|
|
*/ |
72
|
|
|
private function displayFlash($type, $message, $link = null) |
73
|
|
|
{ |
74
|
|
|
if (null !== $link) { |
75
|
|
|
$message = '<a href="'.$link.'">'.$message.'</a>'; |
76
|
|
|
} |
77
|
|
|
$this->get('session')->getFlashBag()->set($type, $message); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* @return FrontendUser|null |
82
|
|
|
*/ |
83
|
|
|
protected function getUser() |
84
|
|
|
{ |
85
|
|
|
return parent::getUser(); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* @return Breadcrumb[]|array |
90
|
|
|
*/ |
91
|
|
|
protected function getIndexBreadcrumbs() |
92
|
|
|
{ |
93
|
|
|
return []; |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* Renders a view. |
98
|
|
|
* |
99
|
|
|
* @param Breadcrumb[] $breadcrumbs |
100
|
|
|
*/ |
101
|
|
|
protected function render(string $view, array $parameters = [], Response $response = null, array $breadcrumbs = []): Response |
|
|
|
|
102
|
|
|
{ |
103
|
|
|
$parameters['breadcrumbs'] = array_merge($this->getIndexBreadcrumbs(), $breadcrumbs); |
104
|
|
|
|
105
|
|
|
return parent::render($view, $parameters); |
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
|
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