1 | <?php |
||
26 | class RoleLabelUtilityTwigExtension extends AbstractUtilityTwigExtension { |
||
27 | |||
28 | /** |
||
29 | * Service name. |
||
30 | * |
||
31 | * @var string |
||
32 | */ |
||
33 | const SERVICE_NAME = "webeweb.bundle.bootstrapbundle.twig.extension.utility.rolelabel"; |
||
34 | |||
35 | /** |
||
36 | * Extension. |
||
37 | * |
||
38 | * @var LabelComponentTwigExtension |
||
39 | */ |
||
40 | private $extension; |
||
41 | |||
42 | /** |
||
43 | * Translator. |
||
44 | * |
||
45 | * @var TranslatorInterface |
||
46 | */ |
||
47 | private $translator; |
||
48 | |||
49 | /** |
||
50 | * Constructor. |
||
51 | * |
||
52 | * @param LabelComponentTwigExtension $extension The label component Twig extension. |
||
53 | */ |
||
54 | public function __construct(TranslatorInterface $translator, LabelComponentTwigExtension $extension) { |
||
59 | |||
60 | /** |
||
61 | * Apply the color. |
||
62 | * |
||
63 | * @param string $label The label. |
||
64 | * @param string $content The content. |
||
65 | * @param string $color The color. |
||
66 | * @return string Returns the label with applied color. |
||
67 | */ |
||
68 | private function applyColor($label, $content, $color) { |
||
75 | |||
76 | /** |
||
77 | * Display a Bootstrap role label. |
||
78 | * |
||
79 | * @param UserInterface $user The user. |
||
80 | * @param array $roleColors The role colors. |
||
81 | * @param array $roleTrans The role translations. |
||
82 | * @return string Returns the Bootstrap role label. |
||
83 | */ |
||
84 | public function bootstrapRoleLabelFunction(UserInterface $user = null, array $roleColors = [], array $roleTrans = []) { |
||
116 | |||
117 | /** |
||
118 | * Get the Twig functions. |
||
119 | * |
||
120 | * @return array Returns the Twig functions. |
||
121 | */ |
||
122 | public function getFunctions() { |
||
127 | |||
128 | /** |
||
129 | * Get the extension. |
||
130 | * |
||
131 | * @return LabelComponentTwigExtension Returns the extension. |
||
132 | */ |
||
133 | public function getExtension() { |
||
136 | |||
137 | /** |
||
138 | * Get the translator. |
||
139 | * |
||
140 | * @return TranslatorInterface Returns the translator. |
||
141 | */ |
||
142 | public function getTranslator() { |
||
145 | |||
146 | /** |
||
147 | * Set the extension. |
||
148 | * |
||
149 | * @param LabelComponentTwigExtension $extension The extension. |
||
150 | * @return RoleLabelUtilityTwigExtension Returns this role label utility Twig extension. |
||
151 | */ |
||
152 | protected function setExtension(LabelComponentTwigExtension $extension) { |
||
156 | |||
157 | /** |
||
158 | * Set the translator. |
||
159 | * |
||
160 | * @param TranslatorInterface $translator The translator. |
||
161 | * @return RoleLabelUtilityTwigExtension Returns this role label utility Twig extension. |
||
162 | */ |
||
163 | protected function setTranslator(TranslatorInterface $translator) { |
||
167 | |||
168 | } |
||
169 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.