Created
July 22, 2014 18:53
-
-
Save JaronKing/355c0490bb8ceca12116 to your computer and use it in GitHub Desktop.
controller
This file contains hidden or 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 ADS\IPBundle\Controller; | |
use Symfony\Bundle\FrameworkBundle\Controller\Controller; | |
use Symfony\Component\HttpKernel\Event\FilterResponseEvent; | |
use Symfony\Component\Security\Core\SecurityContext; | |
use Symfony\Component\HttpKernel\Event\GetResponseEvent; | |
use Symfony\Component\Security\Core\SecurityContextInterface; | |
class DefaultController extends Controller | |
{ | |
private $securityContext; | |
public function __construct(SecurityContext $context, $container, array $query = array()) | |
{ | |
$this->securityContext = $context; | |
$this->container = $container; | |
$this->query = $query; | |
} | |
public function onKernelRequest(GetResponseEvent $event) | |
{ | |
$container = $this->container; | |
$securityContext = $this->securityContext; | |
// if( $this->container->get('security.context')->isGranted('ROLE_USER') ){ | |
// // authenticated (NON anonymous) | |
// } | |
// if( $container->get('security.context')->isGranted('IS_AUTHENTICATED_FULLY') ){ | |
// echo "hello"; | |
// } | |
// if (!$event->getRequest()->hasSession()) { | |
// echo "holymoly"; | |
// } | |
// $request = $event->getRequest(); | |
// $session = $request->getSession(); | |
// if (null === $session) { | |
// echo "null session"; | |
// } | |
// var_dump($this->securityContext); | |
// $userName = $this->securityContext->getToken('user')->getUsername(); | |
// var_dump($userName); | |
} | |
public function onKernalResponse(FilterResponseEvent $event){ | |
echo "bye"; | |
} | |
public function indexAction($name) | |
{ | |
return $this->render('ADSIPBundle:Default:index.html.twig', array('name' => $name)); | |
} | |
public function addAction(){ | |
return $this->render('ADSIPBundle:Default:index.html.twig', array('name' => "add me")); | |
} | |
public function removeAction(){ | |
return $this->render('ADSIPBundle:Default:index.html.twig', array('name' => "remove me")); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment