src/Sasedev/Commons/SharedBundle/Listener/Activity.php
public function onCoreController(FilterControllerEvent $event)
	{
		// Here we are checking that the current request is a "MASTER_REQUEST",
		// and ignore any
		// subrequest in the process (for example when
		// doing a render() in a twig template)
		if ($event->getRequestType() !== HttpKernel::MASTER_REQUEST) {
			return;
		}

		// We are checking a token authentification is available before using
		// the User
		if ($this->tokenStorage->getToken()) {
			$user = $this->tokenStorage->getToken()->getUser();

			// We are using a delay during wich the user will be considered as
			// still active, in order to
			// avoid too much UPDATE in the
			// database
			// $delay = new \DateTime ();
			// $delay->setTimestamp (strtotime ('2 minutes ago'));

			// We are checking the Admin class in order to be certain we can
			// call "getLastActivity".
			// && $user->getLastActivity() < $delay) {
			if ($user instanceof BaseUser) {
				$user->isActiveNow();
				$this->em->persist($user);
				$this->em->flush();
			}
		}
	}
public function onCoreController(FilterControllerEvent $event)
	{
		// Here we are checking that the current request is a "MASTER_REQUEST",
		// and ignore any
		// subrequest in the process (for example when
		// doing a render() in a twig template)
		if ($event->getRequestType() !== HttpKernel::MASTER_REQUEST) {
			return;
		}

		// We are checking a token authentification is available before using
		// the User
		if ($this->tokenStorage->getToken()) {
			$user = $this->tokenStorage->getToken()->getUser();

			// We are using a delay during wich the user will be considered as
			// still active, in order to
			// avoid too much UPDATE in the
			// database
			// $delay = new \DateTime ();
			// $delay->setTimestamp (strtotime ('2 minutes ago'));

			// We are checking the Admin class in order to be certain we can
			// call "getLastActivity".
			// && $user->getLastActivity() < $delay) {
			if ($user instanceof BaseUser) {
				$user->isActiveNow();
				$this->em->persist($user);
				$this->em->flush();
			}
		}
	}
Update the user "lastActivity" on each request

@param FilterControllerEvent $event