| Conditions | 4 |
| Paths | 4 |
| Total Lines | 25 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | public function customCssAction() |
||
| 16 | { |
||
| 17 | $backgroundFilename = $this->getDataStore()->fetchSetting('backgroundFilename'); |
||
| 18 | $customCss = $this->getDataStore()->fetchSetting('customCss'); |
||
| 19 | $backgroundFullPath = dirname($this->get('kernel')->getRootDir()) . '/web/uploads/' . $backgroundFilename; |
||
| 20 | |||
| 21 | $backgroundUrl = null; |
||
| 22 | if ($backgroundFilename && file_exists($backgroundFullPath)) { |
||
| 23 | $backgroundUrl = '/uploads/' . $backgroundFilename; |
||
| 24 | } |
||
| 25 | |||
| 26 | $headers = ['Content-type' => 'text/css']; |
||
| 27 | |||
| 28 | $data = ''; |
||
| 29 | |||
| 30 | if ($backgroundUrl) { |
||
|
|
|||
| 31 | $data .= "body {\n\tbackground-image: url('$backgroundUrl');\n\tbackground-size: cover;\n}\n"; |
||
| 32 | $data .= "@media only screen and (max-device-width: 480px)" . |
||
| 33 | "\n{\tbody {\n\tbackground-image: none !important;\n\t}\n}"; |
||
| 34 | } |
||
| 35 | |||
| 36 | $data .= $customCss; |
||
| 37 | |||
| 38 | return new Response($data, 200, $headers); |
||
| 39 | } |
||
| 40 | } |
||
| 41 |
In PHP, under loose comparison (like
==, or!=, orswitchconditions), values of different types might be equal.For
stringvalues, the empty string''is a special case, in particular the following results might be unexpected: