Skip to content

Commit

Permalink
NTR - rename classes and api routes
Browse files Browse the repository at this point in the history
JanPietrzyk committed Apr 10, 2019
1 parent c97f974 commit 184e978
Showing 78 changed files with 541 additions and 461 deletions.
2 changes: 1 addition & 1 deletion Checkout/Cart/Order/RecalculationService.php
Original file line number Diff line number Diff line change
@@ -15,7 +15,7 @@
use Shopware\Core\Checkout\Cart\LineItem\LineItem;
use Shopware\Core\Checkout\Cart\Order\Transformer\AddressTransformer;
use Shopware\Core\Checkout\Cart\Processor;
use Shopware\Core\Checkout\Cart\Storefront\CartService;
use Shopware\Core\Checkout\Cart\SalesChannel\CartService;
use Shopware\Core\Checkout\Customer\Exception\AddressNotFoundException;
use Shopware\Core\Checkout\Order\Exception\DeliveryWithoutAddressException;
use Shopware\Core\Checkout\Order\Exception\EmptyCartException;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php declare(strict_types=1);

namespace Shopware\Core\Checkout\Cart\Storefront;
namespace Shopware\Core\Checkout\Cart\SalesChannel;

use Shopware\Core\Checkout\Cart\Cart;
use Shopware\Core\Checkout\Cart\CartBehavior;
@@ -18,12 +18,11 @@
use Shopware\Core\Checkout\Cart\Order\OrderPersisterInterface;
use Shopware\Core\Checkout\Cart\Processor;
use Shopware\Core\Checkout\Order\OrderDefinition;
use Shopware\Core\Framework\Context;
use Shopware\Core\System\SalesChannel\SalesChannelContext;

class CartService
{
public const STOREFRONT = 'storefront';
public const SALES_CHANNEL = 'sales-channel';

/**
* @var Processor
@@ -77,7 +76,7 @@ public function setCart(Cart $cart): void
/**
* @throws CartTokenNotFoundException
*/
public function createNew(string $token, string $name = self::STOREFRONT): Cart
public function createNew(string $token, string $name = self::SALES_CHANNEL): Cart
{
$cart = new Cart($name, $token);

@@ -87,7 +86,7 @@ public function createNew(string $token, string $name = self::STOREFRONT): Cart
/**
* @throws CartTokenNotFoundException
*/
public function getCart(string $token, SalesChannelContext $context, string $name = self::STOREFRONT, bool $caching = true): Cart
public function getCart(string $token, SalesChannelContext $context, string $name = self::SALES_CHANNEL, bool $caching = true): Cart
{
if (isset($this->cart[$token]) && $caching) {
return $this->cart[$token];
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php declare(strict_types=1);

namespace Shopware\Core\Checkout\Cart\Storefront;
namespace Shopware\Core\Checkout\Cart\SalesChannel;

use Shopware\Core\Checkout\Cart\Exception\CartTokenNotFoundException;
use Shopware\Core\Checkout\Cart\Exception\InvalidPayloadException;
@@ -26,7 +26,7 @@
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Serializer\Serializer;

class StorefrontCartController extends AbstractController
class SalesChannelCartController extends AbstractController
{
/**
* @var CartService
@@ -54,29 +54,29 @@ public function __construct(
}

/**
* @Route("/storefront-api/v{version}/checkout/cart", name="storefront-api.checkout.cart.detail", methods={"GET"})
* @Route("/sales-channel-api/v{version}/checkout/cart", name="sales-channel-api.checkout.cart.detail", methods={"GET"})
*
* @throws CartTokenNotFoundException
*/
public function getCart(Request $request, SalesChannelContext $context): JsonResponse
{
$token = $request->query->getAlnum('token', $context->getToken());
$name = $request->query->getAlnum('name', CartService::STOREFRONT);
$name = $request->query->getAlnum('name', CartService::SALES_CHANNEL);

$cart = $this->cartService->getCart($token, $context, $name);

return new JsonResponse($this->serialize($cart));
}

/**
* @Route("/storefront-api/v{version}/checkout/cart", name="storefront-api.checkout.cart.create", methods={"POST"})
* @Route("/sales-channel-api/v{version}/checkout/cart", name="sales-channel-api.checkout.cart.create", methods={"POST"})
*
* @throws CartTokenNotFoundException
*/
public function createCart(Request $request, SalesChannelContext $context): JsonResponse
{
$token = $request->request->getAlnum('token', $context->getToken());
$name = $request->request->getAlnum('name', CartService::STOREFRONT);
$name = $request->request->getAlnum('name', CartService::SALES_CHANNEL);

$this->cartService->createNew($token, $name);

@@ -88,7 +88,7 @@ public function createCart(Request $request, SalesChannelContext $context): Json
}

/**
* @Route("/storefront-api/v{version}/checkout/cart/product/{id}", name="storefront-api.checkout.frontend.cart.product.add", methods={"POST"})
* @Route("/sales-channel-api/v{version}/checkout/cart/product/{id}", name="sales-channel-api.checkout.frontend.cart.product.add", methods={"POST"})
*
* @throws MixedLineItemTypeException
* @throws InvalidQuantityException
@@ -118,7 +118,7 @@ public function addProduct(string $id, Request $request, SalesChannelContext $co
* That one will be replaced with a real promotion (if valid) within the
* promotion collector service.
*
* @Route("/storefront-api/v{version}/checkout/cart/code/{code}", name="storefront-api.checkout.frontend.cart.code.add", methods={"POST"})
* @Route("/sales-channel-api/v{version}/checkout/cart/code/{code}", name="sales-channel-api.checkout.frontend.cart.code.add", methods={"POST"})
*
* @throws CartTokenNotFoundException
* @throws InvalidQuantityException
@@ -142,7 +142,7 @@ public function addCode(string $code, Request $request, SalesChannelContext $con
}

/**
* @Route("/storefront-api/v{version}/checkout/cart/line-item/{id}", name="storefront-api.checkout.cart.line-item.add", methods={"POST"})
* @Route("/sales-channel-api/v{version}/checkout/cart/line-item/{id}", name="sales-channel-api.checkout.cart.line-item.add", methods={"POST"})
*
* @throws MissingRequestParameterException
* @throws MixedLineItemTypeException
@@ -174,7 +174,7 @@ public function addLineItem(string $id, Request $request, SalesChannelContext $c
}

/**
* @Route("/storefront-api/v{version}/checkout/cart/line-item/{id}", name="storefront-api.checkout.cart.line-item.delete", methods={"DELETE"})
* @Route("/sales-channel-api/v{version}/checkout/cart/line-item/{id}", name="sales-channel-api.checkout.cart.line-item.delete", methods={"DELETE"})
*
* @throws LineItemNotFoundException
* @throws LineItemNotRemovableException
@@ -196,7 +196,7 @@ public function removeLineItem(string $id, Request $request, SalesChannelContext
}

/**
* @Route("/storefront-api/v{version}/checkout/cart/line-item/{id}", name="storefront-api.checkout.cart.line-item.update", methods={"PATCH"})
* @Route("/sales-channel-api/v{version}/checkout/cart/line-item/{id}", name="sales-channel-api.checkout.cart.line-item.update", methods={"PATCH"})
*
* @throws InvalidQuantityException
* @throws LineItemNotFoundException
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php declare(strict_types=1);

namespace Shopware\Core\Checkout\Cart\Storefront;
namespace Shopware\Core\Checkout\Cart\SalesChannel;

use Shopware\Core\Checkout\Cart\Exception\CartTokenNotFoundException;
use Shopware\Core\Checkout\Cart\Exception\OrderNotFoundException;
use Shopware\Core\Checkout\Customer\Storefront\AccountRegistrationService;
use Shopware\Core\Checkout\Customer\SalesChannel\AccountRegistrationService;
use Shopware\Core\Checkout\Order\OrderEntity;
use Shopware\Core\Checkout\Payment\Exception\AsyncPaymentProcessException;
use Shopware\Core\Checkout\Payment\Exception\InvalidOrderException;
@@ -27,7 +27,7 @@
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Serializer\Serializer;

class StorefrontCheckoutController extends AbstractController
class SalesChannelCheckoutController extends AbstractController
{
/**
* @var PaymentService
@@ -83,7 +83,7 @@ public function __construct(
}

/**
* @Route("/storefront-api/v{version}/checkout/order", name="storefront-api.checkout.order.create", methods={"POST"})
* @Route("/sales-channel-api/v{version}/checkout/order", name="sales-channel-api.checkout.order.create", methods={"POST"})
*
* @throws OrderNotFoundException
* @throws CartTokenNotFoundException
@@ -102,7 +102,7 @@ public function createOrder(Request $request, SalesChannelContext $context): Jso
}

/**
* @Route("/storefront-api/v{version}/checkout/guest-order", name="storefront-api.checkout.guest-order.create", methods={"POST"})
* @Route("/sales-channel-api/v{version}/checkout/guest-order", name="sales-channel-api.checkout.guest-order.create", methods={"POST"})
*
* @throws OrderNotFoundException
* @throws CartTokenNotFoundException
@@ -124,7 +124,7 @@ public function createGuestOrder(Request $request, RequestDataBag $data, SalesCh
}

/**
* @Route("/storefront-api/v{version}/checkout/guest-order/{id}", name="storefront-api.checkout.guest-order.detail", methods={"GET"})
* @Route("/sales-channel-api/v{version}/checkout/guest-order/{id}", name="sales-channel-api.checkout.guest-order.detail", methods={"GET"})
*
* @throws OrderNotFoundException
*/
@@ -150,7 +150,7 @@ public function getDeepLinkOrder(string $id, Request $request, Context $context)
}

/**
* @Route("/storefront-api/v{version}/checkout/order/{orderId}/pay", name="storefront-api.checkout.order.pay", methods={"POST"})
* @Route("/sales-channel-api/v{version}/checkout/order/{orderId}/pay", name="sales-channel-api.checkout.order.pay", methods={"POST"})
*
* @throws AsyncPaymentProcessException
* @throws InvalidOrderException
10 changes: 5 additions & 5 deletions Checkout/Customer/CustomerEvents.php
Original file line number Diff line number Diff line change
@@ -157,25 +157,25 @@ class CustomerEvents
/**
* @Event("Shopware\Core\Framework\Event\DataMappingEvent")
*/
public const MAPPING_REGISTER_ADDRESS_BILLING = 'checkout.customer.storefront.register.billing_address';
public const MAPPING_REGISTER_ADDRESS_BILLING = 'checkout.customer.sales_channel.register.billing_address';

/**
* @Event("Shopware\Core\Framework\Event\DataMappingEvent")
*/
public const MAPPING_REGISTER_ADDRESS_SHIPPING = 'checkout.customer.storefront.register.shipping_address';
public const MAPPING_REGISTER_ADDRESS_SHIPPING = 'checkout.customer.sales_channel.register.shipping_address';

/**
* @Event("Shopware\Core\Framework\Event\DataMappingEvent")
*/
public const MAPPING_REGISTER_CUSTOMER = 'checkout.customer.storefront.register.customer';
public const MAPPING_REGISTER_CUSTOMER = 'checkout.customer.sales_channel.register.customer';

/**
* @Event("Shopware\Core\Framework\Event\DataMappingEvent")
*/
public const MAPPING_CUSTOMER_PROFILE_SAVE = 'checkout.customer.storefront.profile.update';
public const MAPPING_CUSTOMER_PROFILE_SAVE = 'checkout.customer.sales_channel.profile.update';

/**
* @Event("Shopware\Core\Framework\Event\DataMappingEvent")
*/
public const MAPPING_ADDRESS_CREATE = 'checkout.customer.storefront.address.create';
public const MAPPING_ADDRESS_CREATE = 'checkout.customer.sales_channel.address.create';
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php declare(strict_types=1);

namespace Shopware\Core\Checkout\Customer\Storefront;
namespace Shopware\Core\Checkout\Customer\SalesChannel;

use Shopware\Core\Checkout\Customer\CustomerDefinition;
use Shopware\Core\Checkout\Customer\CustomerEvents;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php declare(strict_types=1);

namespace Shopware\Core\Checkout\Customer\Storefront;
namespace Shopware\Core\Checkout\Customer\SalesChannel;

use Shopware\Core\Checkout\Cart\Exception\CustomerNotLoggedInException;
use Shopware\Core\Checkout\Customer\Aggregate\CustomerAddress\CustomerAddressEntity;
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php declare(strict_types=1);

namespace Shopware\Core\Checkout\Customer\Storefront;
namespace Shopware\Core\Checkout\Customer\SalesChannel;

use Shopware\Core\Checkout\Cart\Exception\CustomerNotLoggedInException;
use Shopware\Core\Checkout\Customer\Aggregate\CustomerAddress\CustomerAddressCollection;
Loading

0 comments on commit 184e978

Please sign in to comment.