Skip to content

Commit

Permalink
FrontendCustomerUserFormProvider : overriding is easier with static::
Browse files Browse the repository at this point in the history
  • Loading branch information
Florent Chaintreuil committed Apr 5, 2019
1 parent 61f0f80 commit 528b8ad
Showing 1 changed file with 16 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function getCustomerUserForm(CustomerUser $customerUser)
*/
public function getForgotPasswordFormView(array $options = [])
{
$options['action'] = $this->generateUrl(self::ACCOUNT_USER_RESET_REQUEST_ROUTE_NAME);
$options['action'] = isset($options['action']) ?: $this->generateUrl(static::ACCOUNT_USER_RESET_REQUEST_ROUTE_NAME);

return $this->getFormView(CustomerUserPasswordRequestType::class, null, $options);
}
Expand All @@ -63,7 +63,7 @@ public function getForgotPasswordFormView(array $options = [])
*/
public function getForgotPasswordForm(array $options = [])
{
$options['action'] = $this->generateUrl(self::ACCOUNT_USER_RESET_REQUEST_ROUTE_NAME);
$options['action'] = isset($options['action']) ?: $this->generateUrl(static::ACCOUNT_USER_RESET_REQUEST_ROUTE_NAME);

return $this->getForm(CustomerUserPasswordRequestType::class, null, $options);
}
Expand All @@ -75,7 +75,7 @@ public function getForgotPasswordForm(array $options = [])
*/
public function getResetPasswordFormView(CustomerUser $customerUser = null)
{
$options['action'] = $this->generateUrl(self::ACCOUNT_USER_PASSWORD_RESET_ROUTE_NAME);
$options['action'] = isset($options['action']) ?: $this->generateUrl(static::ACCOUNT_USER_PASSWORD_RESET_ROUTE_NAME);

return $this->getFormView(CustomerUserPasswordResetType::class, $customerUser, $options);
}
Expand All @@ -87,7 +87,7 @@ public function getResetPasswordFormView(CustomerUser $customerUser = null)
*/
public function getResetPasswordForm(CustomerUser $customerUser = null)
{
$options['action'] = $this->generateUrl(self::ACCOUNT_USER_PASSWORD_RESET_ROUTE_NAME);
$options['action'] = isset($options['action']) ?: $this->generateUrl(static::ACCOUNT_USER_PASSWORD_RESET_ROUTE_NAME);

return $this->getForm(CustomerUserPasswordResetType::class, $customerUser, $options);
}
Expand Down Expand Up @@ -125,14 +125,18 @@ private function getCustomerUserFormOptions(CustomerUser $customerUser)
{
$options = [];

if (isset($options['action'])) {
return $options;
}

if ($customerUser->getId()) {
$options['action'] = $this->generateUrl(
self::ACCOUNT_USER_UPDATE_ROUTE_NAME,
static::ACCOUNT_USER_UPDATE_ROUTE_NAME,
['id' => $customerUser->getId()]
);
} else {
$options['action'] = $this->generateUrl(
self::ACCOUNT_USER_CREATE_ROUTE_NAME
static::ACCOUNT_USER_CREATE_ROUTE_NAME
);
}

Expand All @@ -147,9 +151,14 @@ private function getCustomerUserFormOptions(CustomerUser $customerUser)
private function getProfilerFormOptions(CustomerUser $customerUser)
{
$options = [];

if (isset($options['action'])) {
return $options;
}

if ($customerUser->getId()) {
$options['action'] = $this->generateUrl(
self::ACCOUNT_USER_PROFILE_UPDATE_ROUTE_NAME,
static::ACCOUNT_USER_PROFILE_UPDATE_ROUTE_NAME,
['id' => $customerUser->getId()]
);

Expand Down

0 comments on commit 528b8ad

Please sign in to comment.