Instantly share code, notes, and snippets.

Embed
What would you like to do?
Symfony - Création d'un espace sécurisé (Controllers)
<?php
namespace AppBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
/**
* Class AdminController
* @package AppBundle\Controller
* @Route("/admin")
*/
class AdminController extends Controller {
/**
* @Route("/", name="admin_index")
*/
public function indexAction() {
// ...
}
/**
* @Route("/login", name="login_check")
*/
public function loginCheckAction() {}
/**
* @Route("/logout", name="logout")
*/
public function logoutAction() {}
}
<?php
namespace AppBundle\Controller;
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\HttpFoundation\Request;
class DefaultController extends Controller
{
/**
* @Route("/", name="homepage")
*/
public function indexAction(Request $request)
{
// ...
}
/**
* @Route("/login", name="login")
*/
public function loginAction() {
$helper = $this->get('security.authentication_utils');
return $this->render('default/login.html.twig', array(
'last_username' => $helper->getLastUsername(),
'error' => $helper->getLastAuthenticationError()
));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment