소스 검색

Move password field into main buildForm method

Not quite as concise as it could've been, but at this point we just
need to support PHP 5.3 with minimum fuss. Slapping everything in one
block is the easiest way to avoid any other issues.
Dave Shoreman 11 년 전
부모
커밋
ac649679dd
1개의 변경된 파일8개의 추가작업 그리고 17개의 파일을 삭제
  1. 8 17
      src/Packagist/WebBundle/Form/Type/ProfileFormType.php

+ 8 - 17
src/Packagist/WebBundle/Form/Type/ProfileFormType.php

@@ -28,30 +28,21 @@ class ProfileFormType extends BaseType
         $builder->add('username', null, array('label' => 'form.username', 'translation_domain' => 'FOSUserBundle'))
                 ->add('email', 'email', array('label' => 'form.email', 'translation_domain' => 'FOSUserBundle'));
 
-        // Horrible hack for people stuck in the past on PHP5.3
-        $self = $this;
-        $builder->addEventListener(FormEvents::PRE_SET_DATA, function(FormEvent $event) use ($self)
+        $builder->addEventListener(FormEvents::PRE_SET_DATA, function(FormEvent $event)
         {
             if ( ! ($user = $event->getData())) return;
 
             if ( ! $user->getGithubId()) {
-                $self->addPasswordField($event);
+                $event->getForm()->add('current_password', 'password', array(
+                    'label' => 'form.current_password',
+                    'translation_domain' => 'FOSUserBundle',
+                    'mapped' => false,
+                    'constraints' => new UserPassword(),
+                ));
             }
         });
 
-        $builder->add('failureNotifications', null, array(
-            'required' => false,
-        ));
-    }
-
-    private function addPasswordField($event)
-    {
-        $event->getForm()->add('current_password', 'password', array(
-            'label' => 'form.current_password',
-            'translation_domain' => 'FOSUserBundle',
-            'mapped' => false,
-            'constraints' => new UserPassword(),
-        ));
+        $builder->add('failureNotifications', null, array('required' => false, 'label' => 'Notify me of package update failures'));
     }
 
     /**