@@ -28,7 +28,9 @@ class TagRenderer implements ResetInterface
2828 private $ defaultLinkAttributes ;
2929 private $ eventDispatcher ;
3030
31+ // TODO WebpackEncoreBundle 3.0: remove this property
3132 private $ renderedFiles = [];
33+ // TODO WebpackEncoreBundle 3.0: rename this property to $renderedFiles
3234 private $ renderedFilesWithAttributes = [];
3335
3436 public function __construct (
@@ -87,7 +89,7 @@ public function renderWebpackScriptTags(string $entryName, ?string $packageName
8789 return implode ('' , $ scriptTags );
8890 }
8991
90- public function renderWebpackLinkTags (string $ entryName , ?string $ packageName = null , ?string $ entrypointName = null , array $ extraAttributes = [], bool $ includeAttributes = false ): string
92+ public function renderWebpackLinkTags (string $ entryName , ?string $ packageName = null , ?string $ entrypointName = null , array $ extraAttributes = []): string
9193 {
9294 $ entrypointName = $ entrypointName ?: '_default ' ;
9395 $ scriptTags = [];
@@ -126,24 +128,30 @@ public function renderWebpackLinkTags(string $entryName, ?string $packageName =
126128 return implode ('' , $ scriptTags );
127129 }
128130
129- public function getRenderedScripts (): array
131+ /**
132+ * @param bool $includeAttributes Whether to include the attributes or not.
133+ * In WebpackEncoreBundle 3.0, this parameter will be removed,
134+ * and the attributes will always be included.
135+ * TODO WebpackEncoreBundle 3.0
136+ *
137+ * @return ($includeAttributes is true ? list<array<string, mixed>> : list<string>)
138+ */
139+ public function getRenderedScripts (bool $ includeAttributes = false ): array
130140 {
131- return $ this ->renderedFiles ['scripts ' ];
141+ return $ includeAttributes ? $ this -> renderedFilesWithAttributes [ ' scripts ' ] : $ this ->renderedFiles ['scripts ' ];
132142 }
133143
134- public function getRenderedStyles (): array
144+ /**
145+ * @param bool $includeAttributes Whether to include the attributes or not.
146+ * In WebpackEncoreBundle 3.0, this parameter will be removed,
147+ * and the attributes will always be included.
148+ * TODO WebpackEncoreBundle 3.0
149+ *
150+ * @return ($includeAttributes is true ? list<array<string, mixed>> : list<string>)
151+ */
152+ public function getRenderedStyles (bool $ includeAttributes = false ): array
135153 {
136- return $ this ->renderedFiles ['styles ' ];
137- }
138-
139- public function getRenderedScriptsWithAttributes (): array
140- {
141- return $ this ->renderedFilesWithAttributes ['scripts ' ];
142- }
143-
144- public function getRenderedStylesWithAttributes (): array
145- {
146- return $ this ->renderedFilesWithAttributes ['styles ' ];
154+ return $ includeAttributes ? $ this ->renderedFilesWithAttributes ['styles ' ] : $ this ->renderedFiles ['styles ' ];
147155 }
148156
149157 public function getDefaultAttributes (): array
0 commit comments