@@ -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,26 @@ 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+ public function getRenderedScripts (bool $ includeAttributes = false ): array
130138 {
131- return $ this ->renderedFiles ['scripts ' ];
139+ return $ includeAttributes ? $ this -> renderedFilesWithAttributes [ ' scripts ' ] : $ this ->renderedFiles ['scripts ' ];
132140 }
133141
134- public function getRenderedStyles (): array
142+ /**
143+ * @param bool $includeAttributes Whether to include the attributes or not.
144+ * In WebpackEncoreBundle 3.0, this parameter will be removed,
145+ * and the attributes will always be included.
146+ * TODO WebpackEncoreBundle 3.0
147+ */
148+ public function getRenderedStyles (bool $ includeAttributes = false ): array
135149 {
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 ' ];
150+ return $ includeAttributes ? $ this ->renderedFilesWithAttributes ['styles ' ] : $ this ->renderedFiles ['styles ' ];
147151 }
148152
149153 public function getDefaultAttributes (): array
0 commit comments