Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,15 @@
'php_unit_dedicate_assert' => ['target' => 'newest'],
'php_unit_dedicate_assert_internal_type' => true,
'php_unit_mock' => true,
'php_unit_test_case_static_method_calls' => ['call_type' => 'static'],
'php_unit_test_case_static_method_calls' => ['methods' => [
'any' => 'this',
'never' => 'this',
'atLeast' => 'this',
'atLeastOnce' => 'this',
'once' => 'this',
'exactly' => 'this',
'atMost' => 'this',
]],
'self_accessor' => false,
'single_line_throw' => false,
'single_quote' => ['strings_containing_single_quote_chars' => true],
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "swag/swag-extension-store",
"version": "3.5.0",
"version": "6.0.0",
"description": "SWAG Extension Store",
"type": "shopware-platform-plugin",
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/InAppPurchasesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public function orderCart(RequestDataBag $data, Context $context): Response
\assert($positions instanceof RequestDataBag);
$extensionName = $data->get('name');

$positionCollection = InAppPurchaseCartPositionCollection::fromArray($positions->all());
$positionCollection = InAppPurchaseCartPositionCollection::fromArray(array_values($positions->all()));

$app = $this->getAppByName($extensionName, $context);
if (!$app) {
Expand Down
30 changes: 25 additions & 5 deletions src/Exception/ExtensionStoreApiException.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,44 @@ class ExtensionStoreApiException extends StoreApiException

public function __construct(ClientException $exception)
{
$data = json_decode($exception->getResponse()->getBody()->getContents(), true);

parent::__construct($exception);

$data = $this->getData($exception);
$this->apiCode = $data['code'] ?? '';
$this->description = $data['description'] ?? '';
}

public function getErrors(bool $withTrace = false): \Generator
{
$errors = parent::getErrors($withTrace);

foreach ($errors as $error) {
foreach (parent::getErrors($withTrace) as $error) {
yield [
...$error,
'apiCode' => $this->apiCode,
'description' => $this->description,
];
}
}

/**
* @return array<array-key, mixed>
*/
private function getData(ClientException $exception): array
{
$body = $exception->getResponse()->getBody();

// The parent constructor already read the body to its end and left the stream at EOF,
// so reading it again without rewinding yields an empty string.
if ($body->isSeekable()) {
$body->rewind();
}

try {
$data = json_decode($body->getContents(), true, 512, \JSON_THROW_ON_ERROR);
} catch (\JsonException) {
return [];
}

// A body may be valid JSON without being an object, e.g. a bare string or number.
return \is_array($data) ? $data : [];
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
.sw-dashboard-statistics-promotion-banner {
display: block;
container-type: inline-size;
container-name: sw-dashboard-statistics-promotion-banner;
margin: 32px auto;
border-radius: $border-radius-lg;
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 10%), 0 2px 1px 0 rgba(0, 0, 0, 6%), 0 1px 1px 0 rgba(0, 0, 0, 8%);
Expand Down Expand Up @@ -101,7 +102,7 @@
}
}

@container (max-width: 750px) {
@container sw-dashboard-statistics-promotion-banner (max-width: 750px) {
&-details {
display: block;
}
Expand Down Expand Up @@ -152,10 +153,7 @@
margin-top: 14px;
}

@container (max-width: 525px) {
&-app {
}

@container sw-dashboard-statistics-promotion-banner (max-width: 525px) {
&-go-to-app {
float: left;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% block sw_dashboard_index_content_intro_card %}
{% parent %}
<sw-dashboard-statistics-promotion-card />
{% parent %}
{% endblock %}
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
{
"sw-extension-store": {
"component": {
"sw-extension-permissions-details-modal": {
"operationUpdate": "Bearbeiten",
"operationDelete": "Löschen"
}
},
"general": {
"title": "Store",
"taxNotice": "* Alle Preise verstehen sich zzgl. Mehrwertsteuer"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
{
"sw-extension-store": {
"component": {
"sw-extension-permissions-details-modal": {
"operationUpdate": "Edit",
"operationDelete": "Delete"
}
},
"general": {
"title": "Store",
"taxNotice": "* All prices are exclusive of VAT"
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/Services/InAppPurchasesService.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function listPurchases(string $extensionName, Context $context): InAppPur
{
$purchases = $this->client->listInAppPurchases($extensionName, $context);

return $purchases->filter(fn (InAppPurchaseStruct $purchase) => $purchase->getStatus() === InAppPurchaseStatus::ACTIVE);
return $purchases->filter(static fn (InAppPurchaseStruct $purchase) => $purchase->getStatus() === InAppPurchaseStatus::ACTIVE);
}

public function getInAppPurchase(string $extensionName, string $inAppPurchase, Context $context): InAppPurchaseStruct
Expand Down
2 changes: 1 addition & 1 deletion src/Services/StoreClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function createInAppPurchaseCart(string $extensionName, string $feature,
}

$inAppPurchaseCart = InAppPurchaseCartStruct::fromArray(json_decode((string) $response->getBody(), true));
$inAppPurchaseCart->getPositions()->map(function (InAppPurchaseCartPositionStruct $position) use ($extensionName): void {
$inAppPurchaseCart->getPositions()->map(static function (InAppPurchaseCartPositionStruct $position) use ($extensionName): void {
$position->setExtensionName($position->getExtensionName() ?: $extensionName);
});

Expand Down
4 changes: 2 additions & 2 deletions src/Struct/InAppPurchaseCartPositionCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
class InAppPurchaseCartPositionCollection extends Collection
{
/**
* @param InAppPurchaseCartPosition[] $data
* @param list<InAppPurchaseCartPosition> $data
*/
public static function fromArray(array $data): self
{
Expand Down Expand Up @@ -53,7 +53,7 @@ public function filterValidInAppPurchases(
InAppPurchaseCartPositionCollection $allPurchases,
array $validPurchases,
): self {
return $allPurchases->filter(function (InAppPurchaseCartPositionStruct $purchase) use ($validPurchases) {
return $allPurchases->filter(static function (InAppPurchaseCartPositionStruct $purchase) use ($validPurchases) {
return \in_array($purchase->getInAppFeatureIdentifier(), $validPurchases, true);
});
}
Expand Down
43 changes: 39 additions & 4 deletions src/Struct/InAppPurchaseCartPositionStruct.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,49 @@
use Shopware\Core\Framework\Struct\Struct;

/**
* @codeCoverageIgnore
*
* @phpstan-import-type InAppPurchase from InAppPurchaseStruct
* @phpstan-import-type InAppPurchasePriceModel from InAppPurchasePriceModelStruct
* @phpstan-import-type InAppPurchaseSubscriptionChange from InAppPurchaseSubscriptionChangeStruct
*
* @phpstan-type InAppPurchaseCartPosition array{subscriptionChange?: InAppPurchaseSubscriptionChange, extensionName: string, inAppFeatureIdentifier: string, netPrice: float, grossPrice: float, taxRate: float, taxValue: float}
* @phpstan-type InAppPurchaseCartItem array{extensionName: string, inAppFeatureIdentifier: string, netPrice: float, taxValue: float, grossPrice: float, taxRate: float, variant: string, subscriptionChange?: array{type: string, currentInAppFeatureIdentifier: string}}
* @phpstan-type InAppPurchaseCartPosition array{
* subscriptionChange?: InAppPurchaseSubscriptionChange,
* extensionName: string,
* inAppFeatureIdentifier: string,
* priceModel?: array{
* type: string,
* price: float,
* duration: int|null,
* oneTimeOnly: bool,
* },
* feature?: array{
* name: string,
* identifier: string,
* description: string|null,
* priceModels: array{
* type: string,
* price: float,
* duration: int|null,
* oneTimeOnly: bool,
* },
* },
* netPrice: float,
* grossPrice: float,
* taxRate: float,
* taxValue: float,
* }
* @phpstan-type InAppPurchaseCartItem array{
* extensionName: string,
* inAppFeatureIdentifier: string,
* netPrice: float,
* taxValue: float,
* grossPrice: float,
* taxRate: float,
* variant: string,
* subscriptionChange?: array{
* type: string,
* currentInAppFeatureIdentifier: string
* }
* }
*/
#[Package('checkout')]
class InAppPurchaseCartPositionStruct extends Struct
Expand Down
10 changes: 9 additions & 1 deletion src/Struct/InAppPurchaseCartStruct.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,15 @@
* @phpstan-import-type InAppPurchaseCartPosition from InAppPurchaseCartPositionStruct
*
* @phpstan-type Shop array{id: int, domain: string}|array{}
* @phpstan-type InAppPurchaseCart array{positions: InAppPurchaseCartPosition[], bookingShop: Shop, licenseShop: Shop, netPrice: float, grossPrice: float, taxRate: float, taxValue: float}
* @phpstan-type InAppPurchaseCart array{
* positions: list<InAppPurchaseCartPosition>,
* bookingShop?: Shop,
* licenseShop?: Shop,
* netPrice?: float,
* grossPrice?: float,
* taxRate?: float,
* taxValue?: float
* }
*/
#[Package('checkout')]
class InAppPurchaseCartStruct extends Struct
Expand Down
4 changes: 2 additions & 2 deletions src/Struct/InAppPurchaseCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
class InAppPurchaseCollection extends Collection
{
/**
* @param InAppPurchase[] $data
* @param array<InAppPurchase> $data
*/
public static function fromArray(array $data): self
{
Expand All @@ -42,7 +42,7 @@ public function filterValidInAppPurchases(
InAppPurchaseCollection $allPurchases,
array $validPurchases,
): InAppPurchaseCollection {
return $allPurchases->filter(function (InAppPurchaseStruct $purchase) use ($validPurchases) {
return $allPurchases->filter(static function (InAppPurchaseStruct $purchase) use ($validPurchases) {
return \in_array($purchase->getIdentifier(), $validPurchases, true);
});
}
Expand Down
9 changes: 8 additions & 1 deletion src/Struct/InAppPurchasePriceModelStruct.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@
/**
* @codeCoverageIgnore
*
* @phpstan-type InAppPurchasePriceModel array{type: string, price: float, duration: int|null, oneTimeOnly: bool|null, conditionsType: string|null}
* @phpstan-type InAppPurchasePriceModel array{
* variant?: string,
* type?: string,
* price?: float,
* duration?: int|null,
* oneTimeOnly?: bool|null,
* conditionsType?: string|null
* }
*/
#[Package('checkout')]
class InAppPurchasePriceModelStruct extends Struct
Expand Down
15 changes: 12 additions & 3 deletions src/Struct/InAppPurchaseStruct.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,20 @@
use Shopware\Core\Framework\Struct\Struct;

/**
* @codeCoverageIgnore
*
* @phpstan-import-type InAppPurchasePriceModel from InAppPurchasePriceModelStruct
*
* @phpstan-type InAppPurchase array{identifier: string, name: string, description: string|null, priceModels: InAppPurchasePriceModel[]}
* @phpstan-type InAppPurchase array{
* id?: int,
* extensionName?: string,
* identifier: string,
* name: string,
* description: string|null,
* priceModels: list<InAppPurchasePriceModel>,
* serviceConditions?: string|null,
* websiteGtc?: string|null,
* preselectedVariant?: string|null,
* status?: string,
* }
*/
#[Package('checkout')]
class InAppPurchaseStruct extends Struct
Expand Down
2 changes: 0 additions & 2 deletions src/Struct/InAppPurchaseSubscriptionChangeStruct.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
use Shopware\Core\Framework\Struct\Struct;

/**
* @codeCoverageIgnore
*
* @phpstan-import-type InAppPurchase from InAppPurchaseStruct
* @phpstan-import-type InAppPurchasePendingDowngrade from InAppPurchasePendingDowngradeStruct
*
Expand Down
Loading
Loading