Merge branch 'NicoHood-asset_order_fix' into develop

This commit is contained in:
Matias Griese
2021-02-09 21:10:15 +02:00
3 changed files with 13 additions and 1 deletions

View File

@@ -21,6 +21,7 @@
* Fixed save error when editing accounts that have been created with capital letters in their username [#3211](https://github.com/getgrav/grav/issues/3211)
* Fixed renaming flex objects key when using file storage
* Fixed wrong values in Admin pages list [#3214](https://github.com/getgrav/grav/issues/3214)
* Fixed pipelined asset using different hash when extra asset is added to before/after position [#2781](https://github.com/getgrav/grav/issues/2781)
# v1.7.5
## 02/01/2021

View File

@@ -92,6 +92,8 @@ class Assets extends PropertyObject
protected $collections;
/** @var string */
protected $timestamp;
/** @var array Keeping track for order counts (for sorting) */
protected $order = [];
/**
* Initialization called in the Grav lifecycle to initialize the Assets with appropriate configuration
@@ -232,7 +234,15 @@ class Assets extends PropertyObject
$options['timestamp'] = $this->timestamp;
// Set order
$options['order'] = count($this->$collection);
$group = $options['group'] ?? 'head';
$position = $options['position'] ?? 'pipeline';
$orderKey = "{$type}|{$group}|{$position}";
if (!isset($this->order[$orderKey])) {
$this->order[$orderKey] = 0;
}
$options['order'] = ++$this->order[$orderKey];
// Create asset of correct type
$asset_object = new $type();

View File

@@ -189,6 +189,7 @@ trait TestingAssetsTrait
$this->resetJs();
$this->setCssPipeline(false);
$this->setJsPipeline(false);
$this->order = [];
return $this;
}