Skip to content

Commit

Permalink
Merge branch 'b-7.0.x-shop_mutations-OXDEV-7458' into b-7.0.x-prototy…
Browse files Browse the repository at this point in the history
…pe-OXDEV-7325
  • Loading branch information
angel-dimitrov committed Nov 28, 2023
2 parents ff98767 + 706b1e0 commit b87e1dc
Show file tree
Hide file tree
Showing 22 changed files with 1,593 additions and 476 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"phpstan-report": "phpstan -ctests/PhpStan/phpstan.neon analyse src/ --error-format=json > tests/reports/phpstan.report.json",

"phpmd": "phpmd src text cleancode,codesize,design,unusedcode",
"phpmd-report": "phpmd src json cleancode,codesize,design,naming,unusedcode --reportfile tests/reports/phpmd.report.json",
"phpmd-report": "phpmd src json cleancode,codesize,design,unusedcode --reportfile tests/reports/phpmd.report.json",

"deptrac": "deptrac analyze",

Expand Down
85 changes: 78 additions & 7 deletions src/Setting/Controller/ShopSettingController.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<?php

/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/

declare(strict_types=1);

namespace OxidEsales\GraphQL\ConfigurationAccess\Setting\Controller;

use OxidEsales\GraphQL\ConfigurationAccess\Setting\DataType\BooleanSetting;
Expand All @@ -10,6 +17,7 @@
use OxidEsales\GraphQL\ConfigurationAccess\Setting\Service\ShopSettingServiceInterface;
use TheCodingMachine\GraphQLite\Annotations\HideIfUnauthorized;
use TheCodingMachine\GraphQLite\Annotations\Logged;
use TheCodingMachine\GraphQLite\Annotations\Mutation;
use TheCodingMachine\GraphQLite\Annotations\Query;
use TheCodingMachine\GraphQLite\Annotations\Right;
use TheCodingMachine\GraphQLite\Types\ID;
Expand All @@ -25,7 +33,7 @@ public function __construct(
#[Logged]
#[HideIfUnauthorized]
#[Right('CHANGE_CONFIGURATION')]
public function getShopSettingInteger(ID $name): IntegerSetting
public function getShopSettingInteger(string $name): IntegerSetting
{
return $this->shopSettingService->getIntegerSetting($name);
}
Expand All @@ -34,7 +42,7 @@ public function getShopSettingInteger(ID $name): IntegerSetting
#[Logged]
#[HideIfUnauthorized]
#[Right('CHANGE_CONFIGURATION')]
public function getShopSettingFloat(ID $name): FloatSetting
public function getShopSettingFloat(string $name): FloatSetting
{
return $this->shopSettingService->getFloatSetting($name);
}
Expand All @@ -43,7 +51,7 @@ public function getShopSettingFloat(ID $name): FloatSetting
#[Logged]
#[HideIfUnauthorized]
#[Right('CHANGE_CONFIGURATION')]
public function getShopSettingBoolean(ID $name): BooleanSetting
public function getShopSettingBoolean(string $name): BooleanSetting
{
return $this->shopSettingService->getBooleanSetting($name);
}
Expand All @@ -52,7 +60,7 @@ public function getShopSettingBoolean(ID $name): BooleanSetting
#[Logged]
#[HideIfUnauthorized]
#[Right('CHANGE_CONFIGURATION')]
public function getShopSettingString(ID $name): StringSetting
public function getShopSettingString(string $name): StringSetting
{
return $this->shopSettingService->getStringSetting($name);
}
Expand All @@ -61,7 +69,7 @@ public function getShopSettingString(ID $name): StringSetting
#[Logged]
#[HideIfUnauthorized]
#[Right('CHANGE_CONFIGURATION')]
public function getShopSettingSelect(ID $name): StringSetting
public function getShopSettingSelect(string $name): StringSetting
{
return $this->shopSettingService->getSelectSetting($name);
}
Expand All @@ -70,7 +78,7 @@ public function getShopSettingSelect(ID $name): StringSetting
#[Logged]
#[HideIfUnauthorized]
#[Right('CHANGE_CONFIGURATION')]
public function getShopSettingCollection(ID $name): StringSetting
public function getShopSettingCollection(string $name): StringSetting
{
return $this->shopSettingService->getCollectionSetting($name);
}
Expand All @@ -79,11 +87,74 @@ public function getShopSettingCollection(ID $name): StringSetting
#[Logged]
#[HideIfUnauthorized]
#[Right('CHANGE_CONFIGURATION')]
public function getShopSettingAssocCollection(ID $name): StringSetting
public function getShopSettingAssocCollection(string $name): StringSetting
{
return $this->shopSettingService->getAssocCollectionSetting($name);
}

#[Mutation]
#[Logged]
#[HideIfUnauthorized]
#[Right('CHANGE_CONFIGURATION')]
public function changeShopSettingInteger(string $name, int $value): IntegerSetting
{
return $this->shopSettingService->changeIntegerSetting($name, $value);
}

#[Mutation]
#[Logged]
#[HideIfUnauthorized]
#[Right('CHANGE_CONFIGURATION')]
public function changeShopSettingFloat(string $name, float $value): FloatSetting
{
return $this->shopSettingService->changeFloatSetting($name, $value);
}

#[Mutation]
#[Logged]
#[HideIfUnauthorized]
#[Right('CHANGE_CONFIGURATION')]
public function changeShopSettingBoolean(string $name, bool $value): BooleanSetting
{
return $this->shopSettingService->changeBooleanSetting($name, $value);
}

#[Mutation]
#[Logged]
#[HideIfUnauthorized]
#[Right('CHANGE_CONFIGURATION')]
public function changeShopSettingString(string $name, string $value): StringSetting
{
return $this->shopSettingService->changeStringSetting($name, $value);
}

#[Mutation]
#[Logged]
#[HideIfUnauthorized]
#[Right('CHANGE_CONFIGURATION')]
public function changeShopSettingSelect(string $name, string $value): StringSetting
{
return $this->shopSettingService->changeSelectSetting($name, $value);
}

#[Mutation]
#[Logged]
#[HideIfUnauthorized]
#[Right('CHANGE_CONFIGURATION')]
public function changeShopSettingCollection(string $name, string $value): StringSetting
{
return $this->shopSettingService->changeCollectionSetting($name, $value);
}

#[Mutation]
#[Logged]
#[HideIfUnauthorized]
#[Right('CHANGE_CONFIGURATION')]
public function changeShopSettingAssocCollection(string $name, string $value): StringSetting
{
return $this->shopSettingService->changeAssocCollectionSetting($name, $value);
}

/**
* @return SettingType[]
*/
Expand Down
14 changes: 14 additions & 0 deletions src/Setting/Exception/NoSettingsFoundException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/

declare(strict_types=1);

namespace OxidEsales\GraphQL\ConfigurationAccess\Setting\Exception;

class NoSettingsFoundException extends \Exception
{
}
20 changes: 20 additions & 0 deletions src/Setting/Exception/NoSettingsFoundForShopException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/

declare(strict_types=1);

namespace OxidEsales\GraphQL\ConfigurationAccess\Setting\Exception;

class NoSettingsFoundForShopException extends NoSettingsFoundException
{
public function __construct(int $shopId)
{
$message = sprintf('No settings found for shop: %d', $shopId);

parent::__construct($message);
}
}
14 changes: 14 additions & 0 deletions src/Setting/Exception/WrongSettingTypeException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/

declare(strict_types=1);

namespace OxidEsales\GraphQL\ConfigurationAccess\Setting\Exception;

final class WrongSettingTypeException extends \Exception
{
}
14 changes: 14 additions & 0 deletions src/Setting/Exception/WrongSettingValueException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

/**
* Copyright © OXID eSales AG. All rights reserved.
* See LICENSE file for license details.
*/

declare(strict_types=1);

namespace OxidEsales\GraphQL\ConfigurationAccess\Setting\Exception;

final class WrongSettingValueException extends \Exception
{
}
Loading

0 comments on commit b87e1dc

Please sign in to comment.