Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

Commit

Permalink
Spread priorization.
Browse files Browse the repository at this point in the history
  • Loading branch information
stephpy committed Apr 10, 2017
1 parent ff9c3e7 commit 281e327
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions DependencyInjection/Compiler/AddSpreadCompilerPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,20 @@ class AddSpreadCompilerPass implements CompilerPassInterface
*/
public function process(ContainerBuilder $container)
{
$alias = $container->getAlias('spy_timeline.spread.deployer');
$spreadDeployer = $container->getDefinition((string) $alias);
$alias = $container->getAlias('spy_timeline.spread.deployer');
$spreadDeployer = $container->getDefinition((string) $alias);
$spreadByPriority = [];

foreach ($container->findTaggedServiceIds('spy_timeline.spread') as $id => $tags) {
$spreadDeployer->addMethodCall('addSpread', array($container->getDefinition($id)));
foreach ($container->findTaggedServiceIds('spy_timeline.spread') as $id => $options) {
$priority = array_key_exists('priority', $options[0]) ? $options[0]['priority'] : 0;

$spreadByPriority[$priority][] = $container->getDefinition($id);
}

krsort($spreadByPriority);

foreach ($spreadByPriority as $spreads) {
$spreadDeployer->addMethodCall('addSpread', $spreads);
}
}
}

0 comments on commit 281e327

Please sign in to comment.