Преглед на файлове

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'));
     }
 
     /**