-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the UploadProductVariantRequest entity along with related files
- Loading branch information
Showing
9 changed files
with
252 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Setono\SyliusPeakPlugin\Model; | ||
|
||
use Sylius\Component\Core\Model\ProductVariantInterface as BaseProductVariantInterface; | ||
|
||
interface ProductVariantInterface extends BaseProductVariantInterface | ||
{ | ||
public function getPeakUploadProductVariantRequest(): ?UploadProductVariantRequestInterface; | ||
|
||
public function setPeakUploadProductVariantRequest(?UploadProductVariantRequestInterface $uploadProductVariantRequest): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Setono\SyliusPeakPlugin\Model; | ||
|
||
use Doctrine\ORM\Mapping as ORM; | ||
|
||
trait ProductVariantTrait | ||
{ | ||
/** @ORM\OneToOne(mappedBy="productVariant", targetEntity="Setono\SyliusPeakPlugin\Model\UploadProductVariantRequestInterface", cascade={"persist"}, orphanRemoval=true) */ | ||
#[ORM\OneToOne(mappedBy: 'productVariant', targetEntity: UploadProductVariantRequestInterface::class, cascade: ['persist'], orphanRemoval: true)] | ||
protected ?UploadProductVariantRequestInterface $peakUploadProductVariantRequest = null; | ||
|
||
public function getPeakUploadProductVariantRequest(): ?UploadProductVariantRequestInterface | ||
{ | ||
return $this->peakUploadProductVariantRequest; | ||
} | ||
|
||
public function setPeakUploadProductVariantRequest(?UploadProductVariantRequestInterface $uploadProductVariantRequest): void | ||
{ | ||
$this->peakUploadProductVariantRequest = $uploadProductVariantRequest; | ||
$uploadProductVariantRequest?->setProductVariant($this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Setono\SyliusPeakPlugin\Model; | ||
|
||
class UploadProductVariantRequest implements UploadProductVariantRequestInterface | ||
{ | ||
protected ?int $id = null; | ||
|
||
protected int $version = 1; | ||
|
||
protected string $state = self::STATE_PENDING; | ||
|
||
protected ?ProductVariantInterface $productVariant = null; | ||
|
||
protected ?string $request = null; | ||
|
||
protected ?string $response = null; | ||
|
||
protected ?string $error = null; | ||
|
||
protected ?int $peakProductId = null; | ||
|
||
public function getId(): ?int | ||
{ | ||
return $this->id; | ||
} | ||
|
||
public function getVersion(): int | ||
{ | ||
return $this->version; | ||
} | ||
|
||
public function setVersion(?int $version): void | ||
{ | ||
$this->version = (int) $version; | ||
} | ||
|
||
public function getState(): string | ||
{ | ||
return $this->state; | ||
} | ||
|
||
public function setState(string $state): void | ||
{ | ||
$this->state = $state; | ||
} | ||
|
||
public function getProductVariant(): ?ProductVariantInterface | ||
{ | ||
return $this->productVariant; | ||
} | ||
|
||
public function setProductVariant(?ProductVariantInterface $productVariant): void | ||
{ | ||
$this->productVariant = $productVariant; | ||
} | ||
|
||
public function getRequest(): ?string | ||
{ | ||
return $this->request; | ||
} | ||
|
||
public function setRequest(?string $request): void | ||
{ | ||
$this->request = $request; | ||
} | ||
|
||
public function getResponse(): ?string | ||
{ | ||
return $this->response; | ||
} | ||
|
||
public function setResponse(?string $response): void | ||
{ | ||
$this->response = $response; | ||
} | ||
|
||
public function getError(): ?string | ||
{ | ||
return $this->error; | ||
} | ||
|
||
public function setError(?string $error): void | ||
{ | ||
$this->error = $error; | ||
} | ||
|
||
public function getPeakProductId(): ?int | ||
{ | ||
return $this->peakProductId; | ||
} | ||
|
||
public function setPeakProductId(?int $peakProductId): void | ||
{ | ||
$this->peakProductId = $peakProductId; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Setono\SyliusPeakPlugin\Model; | ||
|
||
use Sylius\Component\Resource\Model\ResourceInterface; | ||
use Sylius\Component\Resource\Model\VersionedInterface; | ||
|
||
interface UploadProductVariantRequestInterface extends ResourceInterface, VersionedInterface | ||
{ | ||
public const STATE_PENDING = 'pending'; | ||
|
||
public const STATE_PROCESSING = 'processing'; | ||
|
||
public const STATE_UPLOADED = 'uploaded'; | ||
|
||
public const STATE_FAILED = 'failed'; | ||
|
||
public function getId(): ?int; | ||
|
||
public function getState(): string; | ||
|
||
public function setState(string $state): void; | ||
|
||
public function getProductVariant(): ?ProductVariantInterface; | ||
|
||
public function setProductVariant(?ProductVariantInterface $productVariant): void; | ||
|
||
public function getRequest(): ?string; | ||
|
||
public function setRequest(?string $request): void; | ||
|
||
public function getResponse(): ?string; | ||
|
||
public function setResponse(?string $response): void; | ||
|
||
public function getError(): ?string; | ||
|
||
public function setError(?string $error): void; | ||
|
||
/** | ||
* If the product variant was uploaded successfully, this method will return the peak internal id | ||
*/ | ||
public function getPeakProductId(): ?int; | ||
|
||
public function setPeakProductId(?int $peakProductId): void; | ||
} |
24 changes: 24 additions & 0 deletions
24
src/Resources/config/doctrine/model/UploadProductVariantRequest.orm.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<doctrine-mapping xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping" | ||
xsi:schemaLocation="http://doctrine-project.org/schemas/orm/doctrine-mapping | ||
http://doctrine-project.org/schemas/orm/doctrine-mapping.xsd"> | ||
<mapped-superclass name="Setono\SyliusPeakPlugin\Model\UploadProductVariantRequest" | ||
table="setono_sylius_peak_wms__upload_product_variant_request"> | ||
<id name="id" type="integer"> | ||
<generator strategy="AUTO"/> | ||
</id> | ||
|
||
<field name="version" type="integer" version="true"/> | ||
<field name="state" type="string"/> | ||
<field name="request" type="text" nullable="true"/> | ||
<field name="response" type="text" nullable="true"/> | ||
<field name="error" type="text" nullable="true"/> | ||
<field name="peakProductId" type="integer" nullable="true"/> | ||
|
||
<one-to-one field="productVariant" target-entity="Sylius\Component\Product\Model\ProductVariantInterface" inversed-by="peakUploadProductVariantRequest"> | ||
<join-column name="product_variant_id" referenced-column-name="id" nullable="false" unique="true" on-delete="CASCADE"/> | ||
</one-to-one> | ||
</mapped-superclass> | ||
</doctrine-mapping> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\Setono\SyliusPeakPlugin\Application\Model; | ||
|
||
use Doctrine\ORM\Mapping as ORM; | ||
use Setono\SyliusPeakPlugin\Model\ProductVariantInterface as PeakProductVariantInterface; | ||
use Setono\SyliusPeakPlugin\Model\ProductVariantTrait as PeakProductVariantTrait; | ||
use Sylius\Component\Core\Model\ProductVariant as BaseProductVariant; | ||
|
||
/** | ||
* @ORM\Entity | ||
* | ||
* @ORM\Table(name="sylius_product_variant") | ||
*/ | ||
class ProductVariant extends BaseProductVariant implements PeakProductVariantInterface | ||
{ | ||
use PeakProductVariantTrait; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters