private function enforceOwnerSecurity(User $event)
 {
     $user = $this->getUser();
     if ($user != $event->getOwner()) {
         // if you're using 2.5 or higher
         // throw $this->createAccessDeniedException('You are not the owner!!!');
         throw new AccessDeniedException('You are not the owner!!!');
     }
 }
Beispiel #2
0
require_once __DIR__ . '/app/AppKernel.php';
$kernel = new AppKernel('dev', true);
$kernel->loadClassCache();
$request = Request::createFromGlobals();
$kernel->boot();
$container = $kernel->getContainer();
$container->enterScope('request');
$container->set('request', $request);
$templating = $container->get('templating');
//all our setup is done !!!!
/*echo $templating->render(
    'FunQBundle:Default:index.html.twig',
    array(
        'name' => 'Yoda',
        'count' => 5,
    )
);*/
use FunQ\Bundle\FunQBundle\Entity\User;
$user = new User();
$user->setFirstName('John');
$user->setLastName('Doe');
$user->setBirthdate(new \DateTime('1993-01-10'));
$user->setClass('C1');
$user->setGender('M');
$user->setIQ(0);
$user->setSchool('Allman Town Primary');
$user->setUsername('JohnDoe');
$user->setPassword('password');
$em = $container->get('doctrine')->getManager();
$em->persist($user);
$em->flush();