-
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
f0e5808
commit 8bee1dc
Showing
6 changed files
with
93 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shopsys\FrameworkBundle\Model\Transport; | ||
|
||
use Shopsys\FrameworkBundle\Component\Enum\AbstractEnum; | ||
|
||
abstract class AbstractTransportTypeEnum 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Shopsys\FrameworkBundle\Model\Transport; | ||
|
||
class TransportTypeProvider | ||
{ | ||
/** | ||
* @param iterable<\Shopsys\FrameworkBundle\Model\Transport\AbstractTransportTypeEnum> $transportTypeEnums | ||
*/ | ||
public function __construct( | ||
protected readonly iterable $transportTypeEnums, | ||
) { | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function getAllIndexedByTranslations(): array | ||
{ | ||
$allIndexedByTranslations = []; | ||
|
||
foreach ($this->transportTypeEnums as $transportTypeEnum) { | ||
$allIndexedByTranslations = array_merge($allIndexedByTranslations, $transportTypeEnum->getAllIndexedByTranslations()); | ||
} | ||
|
||
return $allIndexedByTranslations; | ||
} | ||
|
||
/** | ||
* @return array<string, string> | ||
*/ | ||
public function getAllEnabledInCartIndexedByTranslations(): array | ||
{ | ||
$enabledInCartCases = []; | ||
|
||
foreach ($this->transportTypeEnums 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