Skip to content

Instantly share code, notes, and snippets.

@MDrollette
Created June 26, 2012 00:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MDrollette/2992370 to your computer and use it in GitHub Desktop.
Save MDrollette/2992370 to your computer and use it in GitHub Desktop.
<?php
namespace SOTB\CustomerBundle\Controller;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Security\Core\SecurityContextInterface;
use SOTB\CoreBundle\Model\InitializableControllerInterface;
/**
* @author Matt Drollette <matt@drollette.com>
*/
class CustomerController implements InitializableControllerInterface
{
private $user;
private $company;
public function initialize(Request $request, SecurityContextInterface $security_context)
{
$this->user = $security_context->getToken()->getUser();
$this->company = $this->user->getCompany();
if (!$this->company) {
throw new NotFoundHttpException('You are not assigned to a company.');
}
}
// ... rest of controller actions
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment