Skip to content

Commit

Permalink
revert: use tosLink and privacyLink instead of tosUrl and privacyUrl …
Browse files Browse the repository at this point in the history
…to handle retrocompatibility
  • Loading branch information
TakeshiDaveau committed Aug 31, 2023
1 parent e3abaf6 commit f509fb4
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions src/Presenter/BillingPresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,8 @@ public function present($params)
'id' => $this->getModule()->name,
'displayName' => $this->getModule()->displayName,
'logoSrc' => $this->encodeImage($this->getModuleLogo()),
'privacyUrl' => !empty($params['privacyUrl']) ? $params['privacyUrl'] : '',
'tosUrl' => !empty($params['tosUrl']) ? $params['tosUrl'] : '',
'privacyUrl' => !empty($params['privacyUrl']) ? $params['privacyUrl'] : $params['privacyLink'],
'tosUrl' => !empty($params['tosUrl']) ? $params['tosUrl'] : $params['tosLink'],
],
],
],
Expand All @@ -126,17 +126,19 @@ public function present($params)
*/
private function validateContextArgs($params)
{
if (empty($params['tosUrl'])) {
throw new BillingContextException('"tosUrl" must be provided (value=' . $params['tosUrl'] . ')');
$tosUrl = !empty($params['tosUrl']) ? $params['tosUrl'] : $params['tosLink'];
$privacyUrl = !empty($params['privacyUrl']) ? $params['privacyUrl'] : $params['privacyLink'];
if (empty($tosUrl)) {
throw new BillingContextException('"tosUrl" must be provided (value=' . $tosUrl . ')');
}
if (!\Validate::isAbsoluteUrl($params['tosUrl'])) {
throw new BillingContextException('"tosUrl" must be a valid url (value=' . $params['tosUrl'] . ')');
if (!\Validate::isAbsoluteUrl($tosUrl)) {
throw new BillingContextException('"tosUrl" must be a valid url (value=' . $tosUrl . ')');
}
if (empty($params['privacyUrl'])) {
throw new BillingContextException('"privacyUrl" must be provided (value=' . $params['privacyUrl'] . ')');
if (empty($privacyUrl)) {
throw new BillingContextException('"privacyUrl" must be provided (value=' . $privacyUrl . ')');
}
if (!\Validate::isAbsoluteUrl($params['privacyUrl'])) {
throw new BillingContextException('"privacyUrl" must be a valid url (value=' . $params['privacyUrl'] . ')');
if (!\Validate::isAbsoluteUrl($privacyUrl)) {
throw new BillingContextException('"privacyUrl" must be a valid url (value=' . $privacyUrl . ')');
}
}

Expand Down

0 comments on commit f509fb4

Please sign in to comment.