Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 4d6fdc0

Browse filesBrowse files
committed
Simplyfing the way to flatten the array acording to @stof comments
1 parent 91812e2 commit 4d6fdc0
Copy full SHA for 4d6fdc0

File tree

Expand file treeCollapse file tree

1 file changed

+6
-5
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+6
-5
lines changed

‎src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/SerializerPass.php

Copy file name to clipboardExpand all lines: src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Compiler/SerializerPass.php
+6-5Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,20 +41,21 @@ public function process(ContainerBuilder $container)
4141
private function findAndSortTaggedServices($tag_name, $container)
4242
{
4343
// Find tagged services
44-
$servs = array();
44+
$services = array();
4545
foreach ($container->findTaggedServiceIds($tag_name) as $serviceId => $tags) {
4646
foreach($tags as $tag) {
4747
$priority = isset($tag['priority']) ? $tag['priority'] : 0;
48-
$servs[$priority][] = new Reference($serviceId);
48+
$services[$priority][] = new Reference($serviceId);
4949
}
5050
}
5151

5252
// Sort them
53-
krsort($servs);
53+
krsort($services);
5454

5555
// Flatten the array
56-
$services = array();
57-
array_walk_recursive($servs, function($a) use (&$services) { $services[] = $a; });
56+
if(!empty($services)) {
57+
$services = call_user_func_array('array_merge', $services);
58+
}
5859

5960
return $services;
6061
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.