/** * Set the username from the security context by listening on core.request * * @param GetResponseEvent $event */ public function onKernelRequest(GetResponseEvent $event) { $request = $this->container->get('request'); $username = $request->get('_username', 'unknown'); if (null === $this->securityContext) { $this->domainWorkflow->setUsername($username); $this->recordWorkflow->setUsername($username); return; } $token = $this->securityContext->getToken(); if (null !== $token && $this->securityContext->isGranted('IS_AUTHENTICATED_REMEMBERED')) { $username = $token->getUsername(); if ($event->getRequest()->get('_username') && 0 != strlen($event->getRequest()->get('_username'))) { $username = $username . ' (' . $_REQUEST['_username'] . ')'; } $this->domainWorkflow->setUsername($username); $this->recordWorkflow->setUsername($username); return; } $this->domainWorkflow->setUsername($username); $this->recordWorkflow->setUsername($username); }
public function testCreateForceIsDisabled() { try { $domainObj = new Domains(); $domainObj->setName('foo.de'); $this->workflow->create($domainObj, array(), true); } catch (\Exception $e) { $this->assertInstanceOf('SysEleven\\PowerDnsBundle\\Lib\\Exceptions\\ValidationException', $e); /** * @type ValidationException $e */ $this->assertCount(2, $e->getErrors()); $p = array(); /** * @type \Symfony\Component\Validator\ConstraintViolation $error */ foreach ($e->getErrors() as $error) { $p[] = $error->getPropertyPath(); } $this->assertContains('name', $p); $this->assertContains('type', $p); } }