1 | <?php |
||||||
2 | /** |
||||||
3 | * Vite plugin for Craft CMS |
||||||
4 | * |
||||||
5 | * Allows the use of the Vite.js next generation frontend tooling with Craft CMS |
||||||
6 | * |
||||||
7 | * @link https://nystudio107.com |
||||||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||||||
8 | * @copyright Copyright (c) 2021 nystudio107 |
||||||
0 ignored issues
–
show
|
|||||||
9 | */ |
||||||
0 ignored issues
–
show
|
|||||||
10 | |||||||
11 | namespace nystudio107\vite\variables; |
||||||
12 | |||||||
13 | use craft\helpers\Template; |
||||||
14 | use nystudio107\pluginvite\variables\ViteVariableInterface; |
||||||
15 | use nystudio107\pluginvite\variables\ViteVariableTrait; |
||||||
16 | use nystudio107\vite\Vite; |
||||||
17 | use Twig\Error\LoaderError; |
||||||
18 | use Twig\Markup; |
||||||
19 | |||||||
20 | /** |
||||||
0 ignored issues
–
show
|
|||||||
21 | * @author nystudio107 |
||||||
0 ignored issues
–
show
Content of the @author tag must be in the form "Display Name <[email protected]>"
![]() |
|||||||
22 | * @package Vite |
||||||
0 ignored issues
–
show
|
|||||||
23 | * @since 1.0.5 |
||||||
0 ignored issues
–
show
|
|||||||
24 | */ |
||||||
0 ignored issues
–
show
|
|||||||
25 | class ViteVariable implements ViteVariableInterface |
||||||
26 | { |
||||||
27 | use ViteVariableTrait; |
||||||
28 | |||||||
29 | /** |
||||||
30 | * Returns the Critical CSS file for $template wrapped in <style></style> |
||||||
31 | * tags |
||||||
32 | * |
||||||
33 | * @param null|string $name |
||||||
0 ignored issues
–
show
|
|||||||
34 | * @param array $attributes additional HTML key/value pair attributes to add to the resulting tag |
||||||
0 ignored issues
–
show
|
|||||||
35 | * |
||||||
36 | * @return Markup |
||||||
37 | * @throws LoaderError |
||||||
38 | */ |
||||||
39 | public function includeCriticalCssTags(?string $name = null, array $attributes = []): Markup |
||||||
40 | { |
||||||
41 | return Template::raw( |
||||||
42 | Vite::$plugin->helper->getCriticalCssTags($name, $attributes) |
||||||
0 ignored issues
–
show
The method
getCriticalCssTags() does not exist on null .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||||||
43 | ); |
||||||
44 | } |
||||||
45 | |||||||
46 | /** |
||||||
47 | * Returns the passed in CSS file at the specified file system path or URL, wrapped in |
||||||
48 | * <style></style> tags |
||||||
49 | * |
||||||
50 | * @param string $path |
||||||
0 ignored issues
–
show
|
|||||||
51 | * @param array $attributes additional HTML key/value pair attributes to add to the resulting tag |
||||||
0 ignored issues
–
show
|
|||||||
52 | * |
||||||
53 | * @return string |
||||||
54 | */ |
||||||
55 | public function getCssInlineTags(string $path, array $attributes = []): string |
||||||
56 | { |
||||||
57 | return Template::raw( |
||||||
58 | Vite::$plugin->helper->getCssInlineTags($path, $attributes) |
||||||
59 | ); |
||||||
60 | } |
||||||
61 | |||||||
62 | /** |
||||||
63 | * Return the hash value for the first CSS file bundled with the module specified via $path |
||||||
64 | * |
||||||
65 | * @param $path |
||||||
0 ignored issues
–
show
|
|||||||
66 | * @return Markup |
||||||
0 ignored issues
–
show
|
|||||||
67 | */ |
||||||
68 | public function getCssHash($path): Markup |
||||||
69 | { |
||||||
70 | return Template::raw( |
||||||
71 | Vite::$plugin->helper->getCssHash($path) |
||||||
72 | ); |
||||||
73 | } |
||||||
74 | } |
||||||
75 |