Symfony - Création d'un espace sécurisé (Controllers)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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() {} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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