|
@@ -135,7 +135,7 @@ class UserController extends Controller
|
135
|
135
|
{
|
136
|
136
|
$userManager = $this->container->get('fos_user.user_manager');
|
137
|
137
|
$user = $this->getNewUser($userManager);
|
138
|
|
- $form = $this->createForm(new RegistrationFormType(), $user);
|
|
138
|
+ $form = $this->getRegistrationForm($user);
|
139
|
139
|
$form->bindRequest($request);
|
140
|
140
|
|
141
|
141
|
if ($form->isValid())
|
|
@@ -149,9 +149,15 @@ class UserController extends Controller
|
149
|
149
|
return $this->getFailureRegistrationResponse($form);
|
150
|
150
|
}
|
151
|
151
|
|
|
152
|
+ protected function getRegistrationForm(User $user)
|
|
153
|
+ {
|
|
154
|
+ return $this->createForm(new RegistrationFormType(), $user);
|
|
155
|
+ }
|
|
156
|
+
|
152
|
157
|
/** @return User */
|
153
|
|
- protected function getNewUser($userManager)
|
|
158
|
+ protected function getNewUser()
|
154
|
159
|
{
|
|
160
|
+ $userManager = $this->container->get('fos_user.user_manager');
|
155
|
161
|
$user = $userManager->createUser();
|
156
|
162
|
$user->setUsername($this->generateUsername());
|
157
|
163
|
$user->setPlainPassword($this->generatePassword(32));
|
|
@@ -182,42 +188,6 @@ class UserController extends Controller
|
182
|
188
|
return $result;
|
183
|
189
|
}
|
184
|
190
|
|
185
|
|
- public function registerOldAction()
|
186
|
|
- {
|
187
|
|
- $form = $this->container->get('fos_user.registration.form');
|
188
|
|
- $formHandler = $this->container->get('fos_user.registration.form.handler');
|
189
|
|
- $confirmationEnabled = $this->container->getParameter('fos_user.registration.confirmation.enabled');
|
190
|
|
-
|
191
|
|
- $process = $formHandler->process($confirmationEnabled);
|
192
|
|
- if ($process)
|
193
|
|
- {
|
194
|
|
- $user = $form->getData();
|
195
|
|
-
|
196
|
|
- $authUser = false;
|
197
|
|
- if ($confirmationEnabled) {
|
198
|
|
- $this->container->get('session')->set('fos_user_send_confirmation_email/email', $user->getEmail());
|
199
|
|
- $route = 'fos_user_registration_check_email';
|
200
|
|
- } else {
|
201
|
|
- $authUser = true;
|
202
|
|
- $route = 'start';
|
203
|
|
- }
|
204
|
|
-
|
205
|
|
- $response = $this->getSuccessRegistrationResponse();
|
206
|
|
- if ($authUser) {
|
207
|
|
- $this->authenticateUser($user, $response);
|
208
|
|
- }
|
209
|
|
-
|
210
|
|
- $formHandler->getToken()->addUseCount();
|
211
|
|
- $em = $this->getDoctrine()->getEntityManager();
|
212
|
|
- $em->persist($formHandler->getToken());
|
213
|
|
- $em->flush();
|
214
|
|
-
|
215
|
|
- return $response;
|
216
|
|
- }
|
217
|
|
-
|
218
|
|
- return $this->getFailureRegistrationResponse($form, $formHandler);
|
219
|
|
- }
|
220
|
|
-
|
221
|
191
|
protected function getSuccessRegistrationResponse()
|
222
|
192
|
{
|
223
|
193
|
if (!$this->getRequest()->isXmlHttpRequest())
|
|
@@ -692,7 +662,7 @@ class UserController extends Controller
|
692
|
662
|
return $this->jsonResponse(array(
|
693
|
663
|
'status' => 'success',
|
694
|
664
|
'data' => $this->render('MuzichUserBundle:Account:subscribe_or_login.html.twig', array(
|
695
|
|
- 'form' => $this->container->get('fos_user.registration.form')->createView()
|
|
665
|
+ 'form' => $this->getRegistrationForm($this->getNewUser())->createView()
|
696
|
666
|
))->getContent()
|
697
|
667
|
));
|
698
|
668
|
}
|