Skip to content

Commit c7e3018

Browse files
committed
Remove vars parameter from asset render method.
1 parent 9a435e6 commit c7e3018

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

src/Asset.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -305,14 +305,8 @@ public function isDirectory() {
305305
*
306306
* @param \DrupalCodeGenerator\Helper\Renderer $renderer
307307
* Renderer helper.
308-
* @param array $vars
309-
* Template variables.
310308
*/
311-
public function render(Renderer $renderer, array $vars) {
312-
// Template variables are also used in path substitution, so the asset
313-
// should have them.
314-
// @see \DrupalCodeGenerator\Asset::getPath().
315-
$this->getVars() || $this->vars($vars);
309+
public function render(Renderer $renderer) {
316310
if (!$this->isDirectory() && is_null($this->getContent())) {
317311
$content = '';
318312
if ($header_template = $this->getHeaderTemplate()) {

src/Command/BaseGenerator.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,11 @@ protected function execute(InputInterface $input, OutputInterface $output) {
151151
// Render all assets.
152152
$renderer = $this->getHelper('dcg_renderer');
153153
foreach ($this->getAssets() as $asset) {
154-
$asset->render($renderer, $this->vars);
154+
// Supply the asset with all collected variables if it has no local ones.
155+
if (!$asset->getVars()) {
156+
$asset->vars($this->vars);
157+
}
158+
$asset->render($renderer);
155159
}
156160

157161
$dumped_files = $this->getHelper('dcg_dumper')->dump($input, $output);

0 commit comments

Comments
 (0)