Skip to content
Snippets Groups Projects
Verified Commit 9533440f authored by Bartek Jaskulski's avatar Bartek Jaskulski
Browse files

feat: add ordered loader with priority option

parent e9af0d13
No related branches found
No related tags found
2 merge requests!5feat: remove compilation command,!4feat: remove compilation command
<?php
declare( strict_types=1 );
namespace WPDesk\Init\Binding\Loader;
final class OrderedBindingLoader implements BindingDefinitions {
private BindingDefinitions $loader;
public function __construct( BindingDefinitions $loader ) {
$this->loader = $loader;
}
public function load(): iterable {
$definitions = [];
foreach ( $this->loader->load() as $def ) {
$definitions[] = $def;
}
usort(
$definitions,
fn ( $a, $b ) => $a->option( 'priority' ) <=> $b->option( 'priority' )
);
yield from array_reverse( $definitions, false );
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment