logout or signout in symfony php

To logout or signout in symfony just add the below code and call the function wherever you want to call

public function executeLogout()
{
$this->getUser()->setAuthenticated(false);
$this->getUser()->shutdown();
return $this->redirect(‘security/login’);
}

Thanks,

Sachin