diff --git a/core/modules/user/lib/Drupal/user/ProfileFormController.php b/core/modules/user/lib/Drupal/user/ProfileFormController.php index 201bc73..94825ac 100644 --- a/core/modules/user/lib/Drupal/user/ProfileFormController.php +++ b/core/modules/user/lib/Drupal/user/ProfileFormController.php @@ -8,18 +8,34 @@ namespace Drupal\user; use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\DependencyInjection\ContainerInterface; +use Drupal\Core\Session\AccountInterface; /** * Form controller for the profile forms. */ class ProfileFormController extends AccountFormController { - /** - * {@inheritdoc} - */ - public function buildForm(array $form, array &$form_state, Request $request = NULL) { - $this->request = $request; - return parent::buildForm($form, $form_state); + /** + * The user accessing the form. + * + * @var UserInterface + */ + var $user; + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container) { + $user = $container->get('request')->attributes->get('_account'); + return new static($user); + } + + /** + * Constructor. + */ + public function __construct(AccountInterface $user) { + $this->user = $user; } /** @@ -32,7 +48,7 @@ protected function actions(array $form, array &$form_state) { $account = $this->entity; // The user doing the editing. - $user = $this->request->attributes->get('_account'); + $user = $this->user; $element['delete']['#type'] = 'submit'; $element['delete']['#value'] = t('Cancel account');