Skip to content

Commit

Permalink
refactor: use single iteration
Browse files Browse the repository at this point in the history
Co-authored-by: MGatner <[email protected]>
  • Loading branch information
kenjis and MGatner committed Nov 5, 2023
1 parent d78db06 commit e193afe
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions system/Filters/Filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -264,19 +264,25 @@ public function runRequired(string $position = 'before')
}

// Set the toolbar filter to the last position to be executed
if (
in_array('toolbar', $this->config->required['after'], true)
&& ($count = count($this->config->required['after'])) > 1
&& $this->config->required['after'][$count - 1] !== 'toolbar'
) {
array_splice(
$this->config->required['after'],
array_search('toolbar', $this->config->required['after'], true),
1
);
$this->config->required['after'][] = 'toolbar';
$afters = [];
$found = false;

foreach ($this->config->required['after'] as $alias) {
if ($alias === 'toolbar') {
$found = true;

continue;
}

$afters[] = $alias;
}

if ($found) {
$afters[] = 'toolbar';
}

$this->config->required['after'] = $afters;

$filterClasses = [];

foreach ($this->config->required[$position] as $alias) {
Expand Down

0 comments on commit e193afe

Please sign in to comment.