-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b1362f6
commit 2e9f009
Showing
21 changed files
with
404 additions
and
167 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
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
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
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
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,35 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © OXID eSales AG. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OxidEsales\ModuleTemplate\ProductVote\DataType; | ||
|
||
readonly class VoteResult implements VoteResultInterface | ||
{ | ||
public function __construct( | ||
private string $productId, | ||
private int $voteUp, | ||
private int $voteDown, | ||
) { | ||
} | ||
|
||
public function getProductId(): string | ||
{ | ||
return $this->productId; | ||
} | ||
|
||
public function getVoteUp(): int | ||
{ | ||
return $this->voteUp; | ||
} | ||
|
||
public function getVoteDown(): int | ||
{ | ||
return $this->voteDown; | ||
} | ||
} |
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,17 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © OXID eSales AG. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OxidEsales\ModuleTemplate\ProductVote\DataType; | ||
|
||
interface VoteResultInterface | ||
{ | ||
public function getProductId(): string; | ||
public function getVoteUp(): int; | ||
public function getVoteDown(): int; | ||
} |
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 | ||
|
||
/** | ||
* Copyright © OXID eSales AG. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OxidEsales\ModuleTemplate\ProductVote\Service; | ||
|
||
use OxidEsales\Eshop\Application\Model\Article; | ||
use OxidEsales\Eshop\Application\Model\User; | ||
use OxidEsales\ModuleTemplate\ProductVote\Dao\ProductVoteDaoInterface; | ||
use OxidEsales\ModuleTemplate\ProductVote\Dao\VoteResultDaoInterface; | ||
use OxidEsales\ModuleTemplate\ProductVote\DataType\ProductVote; | ||
use OxidEsales\ModuleTemplate\ProductVote\DataType\ProductVoteInterface; | ||
use OxidEsales\ModuleTemplate\ProductVote\DataType\VoteResultInterface; | ||
|
||
readonly class VoteService implements VoteServiceInterface | ||
{ | ||
public function __construct( | ||
private ProductVoteDaoInterface $productVoteDao, | ||
private VoteResultDaoInterface $voteResultDao, | ||
) { | ||
} | ||
|
||
public function getProductVote(Article $product, User $user): ?ProductVoteInterface | ||
{ | ||
return $this->productVoteDao->getProductVote($product->getId(), $user->getId()); | ||
} | ||
|
||
public function setProductVote(Article $product, User $user, bool $vote): void | ||
{ | ||
$vote = new ProductVote($product->getId(), $user->getId(), $vote); | ||
$this->productVoteDao->setProductVote($vote); | ||
} | ||
|
||
public function resetProductVote(Article $product, User $user): void | ||
{ | ||
$this->productVoteDao->resetProductVote($product->getId(), $user->getId()); | ||
} | ||
|
||
public function getProductVoteResult(Article $product): VoteResultInterface | ||
{ | ||
return $this->voteResultDao->getProductVoteResult($product->getId()); | ||
} | ||
} |
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 @@ | ||
<?php | ||
|
||
/** | ||
* Copyright © OXID eSales AG. All rights reserved. | ||
* See LICENSE file for license details. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace OxidEsales\ModuleTemplate\ProductVote\Service; | ||
|
||
use OxidEsales\Eshop\Application\Model\Article; | ||
use OxidEsales\Eshop\Application\Model\User; | ||
use OxidEsales\ModuleTemplate\ProductVote\DataType\ProductVoteInterface; | ||
use OxidEsales\ModuleTemplate\ProductVote\DataType\VoteResultInterface; | ||
|
||
interface VoteServiceInterface | ||
{ | ||
public function getProductVote(Article $product, User $user): ?ProductVoteInterface; | ||
public function setProductVote(Article $product, User $user, bool $vote): void; | ||
public function resetProductVote(Article $product, User $user): void; | ||
|
||
public function getProductVoteResult(Article $product): VoteResultInterface; | ||
} |
Oops, something went wrong.