Skip to content

Commit

Permalink
bug #223 Making the RefundFactory implement the factory interface (ma…
Browse files Browse the repository at this point in the history
…mazu)

This PR was merged into the 1.0-dev branch.

Discussion
----------

Reason: The `RefundFactory` is used in the Resource Controller and therefore has to has to have this method, otherwise the controller can not be loaded as a service:

`
TypeError: Argument 5 passed to Sylius\Bundle\ResourceBundle\Controller\ResourceController::__construct() must implement interface Sylius\Component\Resource\Factory\FactoryInterface, instance of Sylius\RefundPlugin\Factory\RefundFactory given
`

Fixes #186 

Commits
-------

2af6869 Making the RefundFactory implement the factory interface
50fa3da Adding composer conflict to fix the pipeline
  • Loading branch information
Zales0123 authored Oct 22, 2020
2 parents e7dc511 + 50fa3da commit 0337fbb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
"Tests\\Sylius\\RefundPlugin\\": "tests/"
}
},
"conflict": {
"symplify/package-builder": "^8.3.25"
},
"scripts": {
"fix": [
"vendor/bin/ecs check src/ spec/ --fix"
Expand Down
5 changes: 5 additions & 0 deletions src/Factory/RefundFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@

final class RefundFactory implements RefundFactoryInterface
{
public function createNew(): RefundInterface
{
throw new \InvalidArgumentException('This object is not default constructable.');
}

public function createWithData(string $orderNumber, int $unitId, int $amount, RefundType $type): RefundInterface
{
return new Refund($orderNumber, $amount, $unitId, $type);
Expand Down
3 changes: 2 additions & 1 deletion src/Factory/RefundFactoryInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,11 @@

namespace Sylius\RefundPlugin\Factory;

use Sylius\Component\Resource\Factory\FactoryInterface;
use Sylius\RefundPlugin\Entity\RefundInterface;
use Sylius\RefundPlugin\Model\RefundType;

interface RefundFactoryInterface
interface RefundFactoryInterface extends FactoryInterface
{
public function createWithData(string $orderNumber, int $unitId, int $amount, RefundType $type): RefundInterface;
}

0 comments on commit 0337fbb

Please sign in to comment.