Commit bd04faaa authored by Mat's avatar Mat

la même chose, avec array_map (plus concis, plus propre, plus complexe)

-- similaire en jquery :
users.forEach(function(user) {
});
parent 0bd1b3c8
......@@ -149,15 +149,11 @@ class ChatHub implements MessageComponentInterface
// twig va génèrer le fragment à retourner
$twig = $this->container->get('templating');
$users = array();
foreach (array_keys($this->clients) as $name)
{
$user = $repo->findOneBy(array('username' => $name));
$users[] = $user;
}
// array_map récupère chaque user et le map avec nos clients
$fragment = $twig->render('@Socket/Chat/listUsers.html.twig', array(
'usernames' => $users
'users' => array_map(function ($username) use($repo) {
return $repo->findOneBy(array('username' => $username));
}, array_keys($this->clients))
));
// formate la response
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment