From 1c4dd55396f49c7d643ecf671eb097b3e1eda307 Mon Sep 17 00:00:00 2001 From: Dennis Eichhorn Date: Mon, 1 Apr 2019 21:54:26 +0200 Subject: [PATCH] Allow attributes --- Model/Html/Head.php | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/Model/Html/Head.php b/Model/Html/Head.php index d2fe2bb9b..f0d743416 100644 --- a/Model/Html/Head.php +++ b/Model/Html/Head.php @@ -147,9 +147,9 @@ class Head implements RenderableInterface * * @since 1.0.0 */ - public function addAsset(int $type, string $uri) : void + public function addAsset(int $type, string $uri, array $attributes = []) : void { - $this->assets[$uri] = $type; + $this->assets[$uri] = ['type' => $type, 'attributes' => $attributes]; } /** @@ -299,16 +299,22 @@ class Head implements RenderableInterface */ public function renderAssets() : string { - $asset = ''; - foreach ($this->assets as $uri => $type) { - if ($type === AssetType::CSS) { - $asset .= ''; - } elseif ($type === AssetType::JS) { - $asset .= ''; + $rendered = ''; + foreach ($this->assets as $uri => $asset) { + if ($asset['type'] === AssetType::CSS) { + $rendered .= ''; + } elseif ($asset['type'] === AssetType::JS) { + $rendered .= ''; } } - return $asset; + return $rendered; } /** @@ -320,13 +326,19 @@ class Head implements RenderableInterface */ public function renderAssetsLate() : string { - $asset = ''; - foreach ($this->assets as $uri => $type) { - if ($type === AssetType::JSLATE) { - $asset .= ''; + $rendered = ''; + foreach ($this->assets as $uri => $asset) { + if ($asset['type']=== AssetType::JSLATE) { + $rendered .= ''; } } - return $asset; + return $rendered; } }