-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8bee1dc
commit 081f883
Showing
10 changed files
with
125 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shopsys\FrameworkBundle\Model\Payment; | ||
|
||
use Shopsys\FrameworkBundle\Component\Enum\AbstractEnum; | ||
|
||
abstract class AbstractPaymentTypeEnum extends AbstractEnum | ||
{ | ||
/** | ||
* @return string[] | ||
*/ | ||
public function getEnabledInCartCases(): array | ||
{ | ||
return $this->shouldBeDisplayedInDefaultEshopCart() ? $this->getAllCases() : []; | ||
} | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
abstract public function shouldBeDisplayedInDefaultEshopCart(): bool; | ||
|
||
/** | ||
* @return array<string, string> | ||
*/ | ||
abstract public function getAllIndexedByTranslations(): array; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shopsys\FrameworkBundle\Model\Payment; | ||
|
||
class PaymentTypeEnum extends AbstractPaymentTypeEnum | ||
{ | ||
public const string TYPE_BASIC = 'basic'; | ||
public const string TYPE_GOPAY = 'goPay'; | ||
|
||
/** | ||
* @return array<string, string> | ||
*/ | ||
public function getAllIndexedByTranslations(): array | ||
{ | ||
return [ | ||
t('Basic') => self::TYPE_BASIC, | ||
t('GoPay') => self::TYPE_GOPAY, | ||
]; | ||
} | ||
|
||
/** | ||
* @return bool | ||
*/ | ||
public function shouldBeDisplayedInDefaultEshopCart(): bool | ||
{ | ||
return true; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shopsys\FrameworkBundle\Model\Payment; | ||
|
||
class PaymentTypeProvider | ||
{ | ||
/** | ||
* @param iterable<\Shopsys\FrameworkBundle\Model\Payment\AbstractPaymentTypeEnum> $paymentTypeEnums | ||
*/ | ||
public function __construct( | ||
protected readonly iterable $paymentTypeEnums, | ||
) { | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getAllIndexedByTranslations(): array | ||
{ | ||
$allIndexedByTranslations = []; | ||
|
||
foreach ($this->paymentTypeEnums as $transportTypeEnum) { | ||
$allIndexedByTranslations = array_merge($allIndexedByTranslations, $transportTypeEnum->getAllIndexedByTranslations()); | ||
} | ||
|
||
return $allIndexedByTranslations; | ||
} | ||
|
||
/** | ||
* @return array<string, string> | ||
*/ | ||
public function getAllEnabledInCartIndexedByTranslations(): array | ||
{ | ||
$enabledInCartCases = []; | ||
|
||
foreach ($this->paymentTypeEnums as $transportTypeEnum) { | ||
$enabledInCartCases = array_merge($enabledInCartCases, $transportTypeEnum->getEnabledInCartCases()); | ||
} | ||
|
||
return $enabledInCartCases; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters