legacy fix

This commit is contained in:
Andy Miller
2018-09-26 16:52:10 -06:00
parent 26aea439c6
commit c796474bce
2 changed files with 15 additions and 5 deletions

View File

@@ -226,7 +226,7 @@ class Assets extends PropertyObject
*/
public function addJs($asset)
{
return $this->addType(Assets::JS_TYPE, Assets::JS_TYPE, $asset, $this->unifyLegacyArguments(func_get_args()));
return $this->addType(Assets::JS_TYPE, Assets::JS_TYPE, $asset, $this->unifyLegacyArguments(func_get_args()), Assets::JS_TYPE);
}
/**
@@ -236,7 +236,7 @@ class Assets extends PropertyObject
*/
public function addInlineJs($asset)
{
return $this->addType(Assets::JS_TYPE, Assets::INLINE_JS_TYPE, $asset, $this->unifyLegacyArguments(func_get_args()));
return $this->addType(Assets::JS_TYPE, Assets::INLINE_JS_TYPE, $asset, $this->unifyLegacyArguments(func_get_args()), Assets::JS_TYPE);
}

View File

@@ -8,10 +8,12 @@
namespace Grav\Common\Assets\Traits;
use Grav\Common\Assets;
trait LegacyAssetsTrait
{
protected function unifyLegacyArguments($args)
protected function unifyLegacyArguments($args, $type = Assets::CSS_TYPE)
{
$arguments = [];
@@ -35,10 +37,18 @@ trait LegacyAssetsTrait
if (isset($args[1])) { $arguments['pipeline'] = $args[1]; }
break;
case 2:
if (isset($args[2])) { $arguments['group'] = $args[2]; }
if ($type === Assets::CSS_TYPE) {
if (isset($args[2])) { $arguments['group'] = $args[2]; }
} else {
if (isset($args[2])) { $arguments['loading'] = $args[2]; }
}
break;
case 3:
if (isset($args[3])) { $arguments['loading'] = $args[3]; }
if ($type === Assets::CSS_TYPE) {
if (isset($args[3])) { $arguments['loading'] = $args[3]; }
} else {
if (isset($args[3])) { $arguments['group'] = $args[3]; }
}
break;
}
}