From a809fb8c417fd3525a28473a2f39a9905e6fbc13 Mon Sep 17 00:00:00 2001 From: NicoHood Date: Sun, 3 Jan 2021 13:42:26 +0100 Subject: [PATCH 1/3] Fix #2781 asset manager pipeline order. Patch taken from @pamtbaau --- system/src/Grav/Common/Assets.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/system/src/Grav/Common/Assets.php b/system/src/Grav/Common/Assets.php index 74ba296d0..4e275f084 100644 --- a/system/src/Grav/Common/Assets.php +++ b/system/src/Grav/Common/Assets.php @@ -59,6 +59,8 @@ class Assets extends PropertyObject protected $collections; protected $timestamp; + /** @var array to contain next 'order' value per asset 'type', 'group' and 'position' combination */ + protected $order = []; /** * Initialization called in the Grav lifecycle to initialize the Assets with appropriate configuration @@ -190,7 +192,14 @@ class Assets extends PropertyObject $options['timestamp'] = $this->timestamp; // Set order - $options['order'] = \count($this->$collection); + $group = $options['group'] ?? 'head'; + $position = $options['position'] ?? 'pipeline'; + + if (!isset($this->order[$type][$group][$position])) { + $this->order[$type][$group][$position] = 0; + } + + $options['order'] = $this->order[$type][$group][$position]++; // Create asset of correct type $asset_class = "\\Grav\\Common\\Assets\\{$type}"; From f8972f812afbd3aeedf19d878660bae7323270fa Mon Sep 17 00:00:00 2001 From: NicoHood Date: Sat, 9 Jan 2021 22:02:01 +0100 Subject: [PATCH 2/3] Fix asset unit test --- system/src/Grav/Common/Assets/Traits/TestingAssetsTrait.php | 1 + 1 file changed, 1 insertion(+) diff --git a/system/src/Grav/Common/Assets/Traits/TestingAssetsTrait.php b/system/src/Grav/Common/Assets/Traits/TestingAssetsTrait.php index 84b83e304..d2a05087b 100644 --- a/system/src/Grav/Common/Assets/Traits/TestingAssetsTrait.php +++ b/system/src/Grav/Common/Assets/Traits/TestingAssetsTrait.php @@ -188,6 +188,7 @@ trait TestingAssetsTrait $this->resetJs(); $this->setCssPipeline(false); $this->setJsPipeline(false); + $this->order = []; return $this; } From 42daf75124d554dfc9bfe2ecf5e8c31425bef321 Mon Sep 17 00:00:00 2001 From: NicoHood Date: Fri, 15 Jan 2021 15:04:10 +0100 Subject: [PATCH 3/3] Fix documentation for asset array variable --- system/src/Grav/Common/Assets.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/src/Grav/Common/Assets.php b/system/src/Grav/Common/Assets.php index 4e275f084..f951c03d6 100644 --- a/system/src/Grav/Common/Assets.php +++ b/system/src/Grav/Common/Assets.php @@ -59,7 +59,7 @@ class Assets extends PropertyObject protected $collections; protected $timestamp; - /** @var array to contain next 'order' value per asset 'type', 'group' and 'position' combination */ + /** @var array Array to contain next 'order' value per asset 'type', 'group' and 'position' combination */ protected $order = []; /**