Created
June 26, 2012 00:47
-
-
Save MDrollette/2992370 to your computer and use it in GitHub Desktop.
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 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