Skip to content

Commit

Permalink
Fixed Assets options array mixed with standalone priority #2477
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed Apr 25, 2019
1 parent 9057a80 commit f30334d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Added `Pages::setCheckMethod()` method to override page configuration in Admin Plugin
1. [](#bugfix)
* Fixed `$grav['route']` from being modified when the route instance gets modified
* Fixed Assets options array mixed with standalone priority [#2477](https://github.com/getgrav/grav/issues/2477)

# v1.6.8
## 04/23/2019
Expand Down
21 changes: 14 additions & 7 deletions system/src/Grav/Common/Assets/Traits/LegacyAssetsTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,21 @@ protected function unifyLegacyArguments($args, $type = Assets::CSS_TYPE)
// First argument is always the asset
array_shift($args);

if (\count($args) === 0) {
if (count($args) === 0) {
return [];
}
if (\count($args) === 1 && \is_array($args[0])) {
// New options array format
if (count($args) === 1 && is_array($args[0])) {
return $args[0];
}
// Handle obscure case where options array is mixed with a priority
if (count($args) === 2 && is_array($args[0]) && is_int($args[1])) {
$arguments = $args[0];
$arguments['priority'] = $args[1];
return $arguments;
}

switch ($type) {
case(Assets::INLINE_CSS_TYPE):
$defaults = ['priority' => null, 'group' => null];
$arguments = $this->createArgumentsFromLegacy($args, $defaults);
break;

case(Assets::JS_TYPE):
$defaults = ['priority' => null, 'pipeline' => true, 'loading' => null, 'group' => null];
$arguments = $this->createArgumentsFromLegacy($args, $defaults);
Expand All @@ -55,6 +57,11 @@ protected function unifyLegacyArguments($args, $type = Assets::CSS_TYPE)

break;

case(Assets::INLINE_CSS_TYPE):
$defaults = ['priority' => null, 'group' => null];
$arguments = $this->createArgumentsFromLegacy($args, $defaults);
break;

default:
case(Assets::CSS_TYPE):
$defaults = ['priority' => null, 'pipeline' => true, 'group' => null, 'loading' => null];
Expand Down

0 comments on commit f30334d

Please sign in to comment.