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
8 changes: 4 additions & 4 deletions Classes/Domain/Model/Cart/Cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* LICENSE file that was distributed with this source code.
*/

use Extcode\Cart\Configuration\Loader\CurrencyTranslationLoaderInterface;
use Extcode\Cart\Service\CurrencyTranslationServiceInterface;
use InvalidArgumentException;
use LogicException;
use TYPO3\CMS\Core\Utility\GeneralUtility;
Expand Down Expand Up @@ -71,7 +71,7 @@ class Cart implements AdditionalDataInterface

protected string $shippingCountry = '';

private ?CurrencyTranslationLoaderInterface $currencyTranslationLoader = null;
private ?CurrencyTranslationServiceInterface $currencyTranslationLoader = null;

public function __construct(
protected array $taxClasses,
Expand All @@ -80,7 +80,7 @@ public function __construct(
protected string $currencySign = '€',
protected float $currencyTranslation = 1.00
) {
$this->currencyTranslationLoader = GeneralUtility::makeInstance(CurrencyTranslationLoaderInterface::class);
$this->currencyTranslationLoader = GeneralUtility::makeInstance(CurrencyTranslationServiceInterface::class);

$this->net = 0.0;
$this->gross = 0.0;
Expand Down Expand Up @@ -983,7 +983,7 @@ public function setCurrencySign(string $currencySign): void
public function translatePrice(?float $price = null): ?float
{
if (is_null($this->currencyTranslationLoader)) {
$this->currencyTranslationLoader = GeneralUtility::makeInstance(CurrencyTranslationLoaderInterface::class);
$this->currencyTranslationLoader = GeneralUtility::makeInstance(CurrencyTranslationServiceInterface::class);
}

return $this->currencyTranslationLoader->translatePrice($this->getCurrencyTranslation(), $price);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Extcode\Cart\Configuration\Loader;
namespace Extcode\Cart\Service;

/*
* This file is part of the package extcode/cart.
Expand All @@ -11,7 +11,7 @@
* LICENSE file that was distributed with this source code.
*/

class CurrencyTranslationLoader implements CurrencyTranslationLoaderInterface
class CurrencyTranslationService implements CurrencyTranslationServiceInterface
{
public function translatePrice(float $factor, ?float $price = null): ?float
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Extcode\Cart\Configuration\Loader;
namespace Extcode\Cart\Service;

/*
* This file is part of the package extcode/cart.
Expand All @@ -14,7 +14,7 @@
/**
* @internal This class is marked internal and is not considered part of the public API. The interface will change in the next major version (v12.0.0).
*/
interface CurrencyTranslationLoaderInterface
interface CurrencyTranslationServiceInterface
{
public function translatePrice(float $factor, ?float $price = null): ?float;
}
34 changes: 31 additions & 3 deletions Configuration/Services.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
namespace Extcode\Cart\Configuration;

use Extcode\Cart\Hooks\ItemsProcFunc;
use Extcode\Cart\Service\CurrencyTranslationService;
use Extcode\Cart\Service\CurrencyTranslationServiceInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use TYPO3\CMS\Dashboard\Widgets\BarChartWidget;
Expand All @@ -23,17 +25,43 @@
$containerConfigurator->import('Backend/Widgets/TurnoverPerDayWidget.php');
}

$services = $containerConfigurator
->services()
->defaults()
->autowire()
->autoconfigure()
;

$services
->load(
'Extcode\\Cart\\',
'../Classes/*'
)
->exclude(
[
'../Classes/Widgets/*',
'../Classes/Command/*',
]
)
;

$services
->alias(
CurrencyTranslationServiceInterface::class,
CurrencyTranslationService::class
)
->public()
;

if (
$containerBuilder->hasDefinition(ConfigurationManager::class)
&& $containerBuilder->hasDefinition(FormPersistenceManager::class)
) {
$services = $containerConfigurator->services();

$services->set(ItemsProcFunc::class)
->public()
;
}

$containerConfigurator->import('Services/Configuration.php');
$containerConfigurator->import('Services/ConfigurationLoader.php');
$containerConfigurator->import('Services/ConsoleCommands.php');
};
6 changes: 0 additions & 6 deletions Configuration/Services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@ services:
autoconfigure: true
public: false

Extcode\Cart\:
resource: '../Classes/*'
exclude:
- '../Classes/Widgets/*'
- '../Classes/Command/*'

Extcode\Cart\EventListener\Template\Components\ModifyButtonBar:
tags:
- name: event.listener
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

declare(strict_types=1);

use Extcode\Cart\Configuration\Loader\CurrencyTranslationLoader;
use Extcode\Cart\Configuration\Loader\CurrencyTranslationLoaderInterface;
use Extcode\Cart\Configuration\Loader\PaymentMethodsLoaderInterface;
use Extcode\Cart\Configuration\Loader\ShippingMethodsLoaderInterface;
use Extcode\Cart\Configuration\Loader\SiteSets\PaymentMethodsLoader as SiteSetsPaymentMethodsLoader;
Expand All @@ -19,20 +17,17 @@
return static function (ContainerConfigurator $containerConfigurator): void {
$services = $containerConfigurator
->services()
;

$services
->alias(
CurrencyTranslationLoaderInterface::class,
CurrencyTranslationLoader::class
)
->defaults()
->autowire()
->autoconfigure()
;

$services
->alias(
PaymentMethodsLoaderInterface::class,
TypoScriptPaymentMethodsLoader::class
)
->public()
;

$services
Expand All @@ -50,6 +45,7 @@
ShippingMethodsLoaderInterface::class,
TypoScriptShippingMethodsLoader::class
)
->public()
;

$services
Expand All @@ -72,6 +68,7 @@
TaxClassLoaderInterface::class,
TypoScriptTaxClassLoader::class
)
->public()
;

$services
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,13 @@ moved to `Configuration/Loader`.

The interfaces was moved form `Service` to `Configuration`:

`Classes/Service/CurrencyTranslationServiceInterface.php` => `Classes/Configuration/Loader/CurrencyTranslationLoaderInterface.php`
`Classes/Service/TaxClassServiceInterface.php` => `Classes/Configuration/Loader/TaxClassLoaderInterface.php`
`Classes/Service/PaymentMethodsServiceInterface.php` => `Classes/Configuration/Loader/PaymentMethodsLoaderInterface.php`
`Classes/Service/ShippingMethodsServiceInterface.php` => `Classes/Configuration/Loader/ShippingMethodsLoaderInterface.php`
`Classes/Service/SpecialOptionsServiceInterface.php` => `Classes/Configuration/Loader/SpecialOptionsLoaderInterface.php`

The classes was moved form `Service` to `Configuration` or `Configuration/TypoScript`:

`Classes/Service/CurrencyTranslationService.php` => `Classes/Configuration/Loader/CurrencyTranslationLoader.php`
`Classes/Service/PaymentMethodsFromTypoScriptService.php` => `Classes/Configuration/Loader/TypoScript/PaymentMethodsLoader.php`
`Classes/Service/ShippingMethodsFromTypoScriptService.php` => `Classes/Configuration/Loader/TypoScript/ShippingMethodsLoader.php`
`Classes/Service/SpecialOptionsFromTypoScriptService.php` => `Classes/Configuration/Loader/TypoScript/SpecialOptionsLoader.php`
Expand Down
8 changes: 4 additions & 4 deletions Tests/Unit/Domain/Model/Cart/CartCouponFixTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
* LICENSE file that was distributed with this source code.
*/

use Extcode\Cart\Configuration\Loader\CurrencyTranslationLoader;
use Extcode\Cart\Configuration\Loader\CurrencyTranslationLoaderInterface;
use Extcode\Cart\Domain\Model\Cart\Cart;
use Extcode\Cart\Domain\Model\Cart\CartCouponFix;
use Extcode\Cart\Domain\Model\Cart\TaxClass;
use Extcode\Cart\Service\CurrencyTranslationService;
use Extcode\Cart\Service\CurrencyTranslationServiceInterface;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\MockObject\MockObject;
Expand Down Expand Up @@ -240,8 +240,8 @@ public function isUsableReturnsFalseIfCartMinPriceIsGreaterToGivenPrice(): void
private function createCartMock(array $methods = ['getGross']): Cart|MockObject
{
GeneralUtility::addInstance(
CurrencyTranslationLoaderInterface::class,
new CurrencyTranslationLoader()
CurrencyTranslationServiceInterface::class,
new CurrencyTranslationService()
);

return $this->getMockBuilder(Cart::class)
Expand Down
8 changes: 4 additions & 4 deletions Tests/Unit/Domain/Model/Cart/CartCouponPercentageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@
* LICENSE file that was distributed with this source code.
*/

use Extcode\Cart\Configuration\Loader\CurrencyTranslationLoader;
use Extcode\Cart\Configuration\Loader\CurrencyTranslationLoaderInterface;
use Extcode\Cart\Domain\Model\Cart\Cart;
use Extcode\Cart\Domain\Model\Cart\CartCouponPercentage;
use Extcode\Cart\Domain\Model\Cart\TaxClass;
use Extcode\Cart\Service\CurrencyTranslationService;
use Extcode\Cart\Service\CurrencyTranslationServiceInterface;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\MockObject\MockObject;
Expand Down Expand Up @@ -270,8 +270,8 @@ public function isUsableReturnsFalseIfCartMinPriceIsGreaterToGivenPrice(): void
private function createCartMock(array $methods = ['getGross']): Cart|MockObject
{
GeneralUtility::addInstance(
CurrencyTranslationLoaderInterface::class,
new CurrencyTranslationLoader()
CurrencyTranslationServiceInterface::class,
new CurrencyTranslationService()
);

return $this->getMockBuilder(Cart::class)
Expand Down
28 changes: 14 additions & 14 deletions Tests/Unit/Domain/Model/Cart/CartTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
* LICENSE file that was distributed with this source code.
*/

use Extcode\Cart\Configuration\Loader\CurrencyTranslationLoader;
use Extcode\Cart\Configuration\Loader\CurrencyTranslationLoaderInterface;
use Extcode\Cart\Domain\Model\Cart\Cart;
use Extcode\Cart\Domain\Model\Cart\CartCouponFix;
use Extcode\Cart\Domain\Model\Cart\ProductFactory;
use Extcode\Cart\Domain\Model\Cart\ProductFactoryInterface;
use Extcode\Cart\Domain\Model\Cart\TaxClass;
use Extcode\Cart\Service\CurrencyTranslationService;
use Extcode\Cart\Service\CurrencyTranslationServiceInterface;
use LogicException;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
Expand Down Expand Up @@ -1315,8 +1315,8 @@ public function getSubtotalGrossReturnsSubtotalGross(): void
$couponGross = 10.00;

GeneralUtility::addInstance(
CurrencyTranslationLoaderInterface::class,
new CurrencyTranslationLoader()
CurrencyTranslationServiceInterface::class,
new CurrencyTranslationService()
);
$cart = $this->getMockBuilder(Cart::class)
->onlyMethods(['getCouponGross', 'getCurrencyTranslation'])
Expand Down Expand Up @@ -1353,8 +1353,8 @@ public function getSubtotalNetReturnsSubtotalNet(): void
$couponNet = $couponGross / 1.19;

GeneralUtility::addInstance(
CurrencyTranslationLoaderInterface::class,
new CurrencyTranslationLoader()
CurrencyTranslationServiceInterface::class,
new CurrencyTranslationService()
);
$cart = $this->getMockBuilder(Cart::class)
->onlyMethods(['getCouponNet', 'getCurrencyTranslation'])
Expand Down Expand Up @@ -1402,8 +1402,8 @@ public function getCurrencyCodeInitiallyReturnsString(): void
public function constructorSetsCurrencyCode(): void
{
GeneralUtility::addInstance(
CurrencyTranslationLoaderInterface::class,
new CurrencyTranslationLoader()
CurrencyTranslationServiceInterface::class,
new CurrencyTranslationService()
);
$cart = new Cart(
$this->taxClasses,
Expand Down Expand Up @@ -1455,8 +1455,8 @@ public function getCurrencySignInitiallyReturnsString(): void
public function constructorSetsCurrencySign(): void
{
GeneralUtility::addInstance(
CurrencyTranslationLoaderInterface::class,
new CurrencyTranslationLoader()
CurrencyTranslationServiceInterface::class,
new CurrencyTranslationService()
);
$cart = new Cart(
$this->taxClasses,
Expand Down Expand Up @@ -1508,8 +1508,8 @@ public function getCurrencyTranslationInitiallyReturnsFloat(): void
public function constructorSetsCurrencyTranslation(): void
{
GeneralUtility::addInstance(
CurrencyTranslationLoaderInterface::class,
new CurrencyTranslationLoader()
CurrencyTranslationServiceInterface::class,
new CurrencyTranslationService()
);
$cart = new Cart(
$this->taxClasses,
Expand Down Expand Up @@ -1603,8 +1603,8 @@ protected function addFirstProductToCarts(): void
private function createCart(bool $isNetCart): Cart
{
GeneralUtility::addInstance(
CurrencyTranslationLoaderInterface::class,
new CurrencyTranslationLoader()
CurrencyTranslationServiceInterface::class,
new CurrencyTranslationService()
);

return new Cart($this->taxClasses, $isNetCart);
Expand Down
8 changes: 4 additions & 4 deletions Tests/Unit/Domain/Model/Cart/ServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
* LICENSE file that was distributed with this source code.
*/

use Extcode\Cart\Configuration\Loader\CurrencyTranslationLoader;
use Extcode\Cart\Configuration\Loader\CurrencyTranslationLoaderInterface;
use Extcode\Cart\Domain\Model\Cart\Cart;
use Extcode\Cart\Domain\Model\Cart\Product;
use Extcode\Cart\Domain\Model\Cart\Service;
use Extcode\Cart\Domain\Model\Cart\TaxClass;
use Extcode\Cart\Service\CurrencyTranslationService;
use Extcode\Cart\Service\CurrencyTranslationServiceInterface;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\MockObject\MockObject;
Expand Down Expand Up @@ -471,8 +471,8 @@ public function forTaxClassIdMinusTwoReturnsPseudoTaxClassWithIdMinusTwo(): void
private function createCartMock(array $methods = ['getGross']): Cart|MockObject
{
GeneralUtility::addInstance(
CurrencyTranslationLoaderInterface::class,
new CurrencyTranslationLoader()
CurrencyTranslationServiceInterface::class,
new CurrencyTranslationService()
);

return $this->getMockBuilder(Cart::class)
Expand Down
Loading