Skip to content

Commit

Permalink
Fixes after rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
GSadee committed Jul 25, 2019
1 parent 2544059 commit d080e95
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 219 deletions.
47 changes: 0 additions & 47 deletions spec/CommandProvider/ShopUserBasedCommandProviderSpec.php

This file was deleted.

48 changes: 0 additions & 48 deletions src/CommandProvider/ShopUserBasedCommandProvider.php

This file was deleted.

17 changes: 0 additions & 17 deletions src/CommandProvider/ShopUserBasedCommandProviderInterface.php

This file was deleted.

20 changes: 5 additions & 15 deletions src/Controller/Checkout/CompleteOrderAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@

use FOS\RestBundle\View\View;
use FOS\RestBundle\View\ViewHandlerInterface;
use Sylius\ShopApiPlugin\Command\Cart\AssignCustomerToCart;
use Sylius\ShopApiPlugin\Command\Cart\CompleteOrder;
use Sylius\ShopApiPlugin\CommandProvider\CommandProviderInterface;
use Sylius\ShopApiPlugin\CommandProvider\ShopUserBasedCommandProviderInterface;
use Sylius\ShopApiPlugin\Exception\WrongUserException;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
Expand All @@ -24,7 +21,7 @@ final class CompleteOrderAction
/** @var MessageBusInterface */
private $bus;

/** @var ShopUserBasedCommandProviderInterface */
/** @var CommandProviderInterface */
private $assignCustomerToCartCommandProvider;

/** @var CommandProviderInterface */
Expand All @@ -33,7 +30,7 @@ final class CompleteOrderAction
public function __construct(
ViewHandlerInterface $viewHandler,
MessageBusInterface $bus,
ShopUserBasedCommandProviderInterface $assignCustomerToCartCommandProvider,
CommandProviderInterface $assignCustomerToCartCommandProvider,
CommandProviderInterface $completeOrderCommandProvider
) {
$this->viewHandler = $viewHandler;
Expand All @@ -45,18 +42,11 @@ public function __construct(
public function __invoke(Request $request): Response
{
try {
$orderToken = $request->attributes->get('token');
$email = $request->request->get('email');

if (null !== $email) {
$this->bus->dispatch(new AssignCustomerToCart($orderToken, $email));
if (null !== $request->request->get('email')) {
$this->bus->dispatch($this->assignCustomerToCartCommandProvider->getCommand($request));
}

$this->bus->dispatch(new CompleteOrder($orderToken, $request->request->get('notes')));

// try {
// $this->bus->dispatch($this->assignCustomerToCartCommandProvider->getCommand($request, $user));
// $this->bus->dispatch($this->completeOrderCommandProvider->getCommand($request));
$this->bus->dispatch($this->completeOrderCommandProvider->getCommand($request));
} catch (HandlerFailedException $exception) {
$previousException = $exception->getPrevious();

Expand Down
13 changes: 6 additions & 7 deletions src/Request/Cart/AssignCustomerToCartRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,28 @@

namespace Sylius\ShopApiPlugin\Request\Cart;

use Sylius\Component\Core\Model\ShopUserInterface;
use Sylius\ShopApiPlugin\Command\Cart\AssignCustomerToCart;
use Sylius\ShopApiPlugin\Command\CommandInterface;
use Sylius\ShopApiPlugin\Request\ShopUserBasedRequestInterface;
use Sylius\ShopApiPlugin\Request\RequestInterface;
use Symfony\Component\HttpFoundation\Request;

class AssignCustomerToCartRequest implements ShopUserBasedRequestInterface
class AssignCustomerToCartRequest implements RequestInterface
{
/** @var string|null */
protected $token;

/** @var string|null */
protected $email;

private function __construct(Request $request, ?string $email)
private function __construct(Request $request)
{
$this->token = $request->attributes->get('token');
$this->email = $request->request->get('email', $email);
$this->email = $request->request->get('email');
}

public static function fromHttpRequestAndShopUser(Request $request, ?ShopUserInterface $user): ShopUserBasedRequestInterface
public static function fromHttpRequest(Request $request): RequestInterface
{
return new self($request, $user !== null ? $user->getEmail() : null);
return new self($request);
}

public function getCommand(): CommandInterface
Expand Down
16 changes: 0 additions & 16 deletions src/Request/ShopUserBasedRequestInterface.php

This file was deleted.

4 changes: 2 additions & 2 deletions src/Resources/config/services/command_providers/cart.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
</service>

<service
id="sylius.shop_api_plugin.command_provider.assign_customer_to_cart"
class="Sylius\ShopApiPlugin\CommandProvider\ShopUserBasedCommandProvider"
id="sylius.shop_api_plugin.command_provider.assign_customer_to_cart"
class="Sylius\ShopApiPlugin\CommandProvider\DefaultCommandProvider"
>
<argument>%sylius.shop_api.request.assign_customer_to_cart.class%</argument>
<argument type="service" id="validator" />
Expand Down
32 changes: 0 additions & 32 deletions tests/Test/TestShopUserBasedCommand.php

This file was deleted.

35 changes: 0 additions & 35 deletions tests/Test/TestShopUserBasedRequest.php

This file was deleted.

0 comments on commit d080e95

Please sign in to comment.