-1

I have configure FOSUserBundle and now i want to display all users connected to databse but i don't know how to do it. I need to create method in controller to display the list

public function indexAction()
    {
         $em = $this->container->get('doctrine')->getManager();
         $users = $em->getRepository('RegisterUserBundle:User')->.....
        $em->flush();
    return $this->container->get('templating')->renderResponse('RegisterUserBundle:Default:index.html.twig',
    array('users' => $users

      )
    );

Can someone help me to resolve this issues and i 'm debutant in symfony.

Horizon_Net
  • 5,959
  • 4
  • 31
  • 34
  • 1
    What do you mean by "all users connected" ? You can get a list of users registered in the database, you could have a list of users that have done a request in the last n minutes and have not logged out yet. – Dric512 Sep 14 '15 at 14:21

1 Answers1

0

If you want a list of users that are currently active (Activity in the last n minutes), there is a tutorial here:

Symfony how to return all logged in Active Users

This is basically adding a field:

protected $lastActivityAt;

That is updated each time a user does a request. And a function:

public function isActiveNow()

Telling if a user accessed the database recently.

Community
  • 1
  • 1
Dric512
  • 3,525
  • 1
  • 20
  • 27