-
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.
Merge pull request #1 from koencaerels/development
Development
- Loading branch information
Showing
112 changed files
with
3,679 additions
and
543 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
40 changes: 40 additions & 0 deletions
40
...iKan/Application/Command/Member/MarkSubscriptionAsCanceled/MarkSubscriptionAsCanceled.php
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,40 @@ | ||
<?php | ||
|
||
namespace App\YoshiKan\Application\Command\Member\MarkSubscriptionAsCanceled; | ||
|
||
class MarkSubscriptionAsCanceled | ||
{ | ||
// ————————————————————————————————————————————————————————————————————————— | ||
// Constructor | ||
// ————————————————————————————————————————————————————————————————————————— | ||
|
||
private function __construct( | ||
protected int $id, | ||
) { | ||
} | ||
|
||
// ————————————————————————————————————————————————————————————————————————— | ||
// Hydrate from a json command | ||
// ————————————————————————————————————————————————————————————————————————— | ||
|
||
public static function make(int $subscriptionId): self | ||
{ | ||
return new self($subscriptionId); | ||
} | ||
|
||
public static function hydrateFromJson($json): self | ||
{ | ||
return new self( | ||
$json->id, | ||
); | ||
} | ||
|
||
// ————————————————————————————————————————————————————————————————————————— | ||
// Getters | ||
// ————————————————————————————————————————————————————————————————————————— | ||
|
||
public function getId(): int | ||
{ | ||
return $this->id; | ||
} | ||
} |
37 changes: 37 additions & 0 deletions
37
...plication/Command/Member/MarkSubscriptionAsCanceled/MarkSubscriptionAsCanceledHandler.php
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,37 @@ | ||
<?php | ||
|
||
namespace App\YoshiKan\Application\Command\Member\MarkSubscriptionAsCanceled; | ||
|
||
use App\YoshiKan\Domain\Model\Member\SubscriptionRepository; | ||
use App\YoshiKan\Domain\Model\Member\SubscriptionStatus; | ||
|
||
class MarkSubscriptionAsCanceledHandler | ||
{ | ||
// ————————————————————————————————————————————————————————————————————————— | ||
// Constructor | ||
// ————————————————————————————————————————————————————————————————————————— | ||
|
||
public function __construct( | ||
protected SubscriptionRepository $subscriptionRepository | ||
) { | ||
} | ||
|
||
// ————————————————————————————————————————————————————————————————————————— | ||
// Handler | ||
// ————————————————————————————————————————————————————————————————————————— | ||
|
||
public function go(MarkSubscriptionAsCanceled $command): bool | ||
{ | ||
$subscription = $this->subscriptionRepository->getById($command->getId()); | ||
$result = false; | ||
|
||
if (SubscriptionStatus::NEW === $subscription->getStatus() | ||
|| SubscriptionStatus::AWAITING_PAYMENT === $subscription->getStatus()) { | ||
$subscription->changeStatus(SubscriptionStatus::CANCELED); | ||
$this->subscriptionRepository->save($subscription); | ||
$result = true; | ||
} | ||
|
||
return $result; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...n/Application/Command/Member/MarkSubscriptionAsCanceled/mark_subscription_as_canceled.php
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,22 @@ | ||
<?php | ||
|
||
namespace App\YoshiKan\Application\Command\Member\MarkSubscriptionAsCanceled; | ||
|
||
trait mark_subscription_as_canceled | ||
{ | ||
/** | ||
* @throws \Exception | ||
*/ | ||
public function markSubscriptionAsCanceled(\stdClass $jsonCommand): bool | ||
{ | ||
$command = MarkSubscriptionAsCanceled::hydrateFromJson($jsonCommand); | ||
|
||
$this->permission->CheckRole(['ROLE_DEVELOPER', 'ROLE_ADMIN', 'ROLE_CHIEF_EDITOR']); | ||
|
||
$handler = new MarkSubscriptionAsCanceledHandler($this->subscriptionRepository); | ||
$result = $handler->go($command); | ||
$this->entityManager->flush(); | ||
|
||
return $result; | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...iKan/Application/Command/Member/MarkSubscriptionAsFinished/MarkSubscriptionAsFinished.php
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,40 @@ | ||
<?php | ||
|
||
namespace App\YoshiKan\Application\Command\Member\MarkSubscriptionAsFinished; | ||
|
||
class MarkSubscriptionAsFinished | ||
{ | ||
// ————————————————————————————————————————————————————————————————————————— | ||
// Constructor | ||
// ————————————————————————————————————————————————————————————————————————— | ||
|
||
private function __construct( | ||
protected int $id, | ||
) { | ||
} | ||
|
||
// ————————————————————————————————————————————————————————————————————————— | ||
// Hydrate from a json command | ||
// ————————————————————————————————————————————————————————————————————————— | ||
|
||
public static function make(int $subscriptionId): self | ||
{ | ||
return new self($subscriptionId); | ||
} | ||
|
||
public static function hydrateFromJson($json): self | ||
{ | ||
return new self( | ||
$json->id, | ||
); | ||
} | ||
|
||
// ————————————————————————————————————————————————————————————————————————— | ||
// Getters | ||
// ————————————————————————————————————————————————————————————————————————— | ||
|
||
public function getId(): int | ||
{ | ||
return $this->id; | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
...plication/Command/Member/MarkSubscriptionAsFinished/MarkSubscriptionAsFinishedHandler.php
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 | ||
|
||
namespace App\YoshiKan\Application\Command\Member\MarkSubscriptionAsFinished; | ||
|
||
use App\YoshiKan\Domain\Model\Member\SubscriptionRepository; | ||
use App\YoshiKan\Domain\Model\Member\SubscriptionStatus; | ||
|
||
class MarkSubscriptionAsFinishedHandler | ||
{ | ||
// ————————————————————————————————————————————————————————————————————————— | ||
// Constructor | ||
// ————————————————————————————————————————————————————————————————————————— | ||
|
||
public function __construct( | ||
protected SubscriptionRepository $subscriptionRepository | ||
) { | ||
} | ||
|
||
// ————————————————————————————————————————————————————————————————————————— | ||
// Handler | ||
// ————————————————————————————————————————————————————————————————————————— | ||
public function go(MarkSubscriptionAsFinished $command): bool | ||
{ | ||
$result = false; | ||
$subscription = $this->subscriptionRepository->getById($command->getId()); | ||
|
||
if (SubscriptionStatus::PAYED === $subscription->getStatus()) { | ||
$subscription->changeStatus(SubscriptionStatus::COMPLETE); | ||
$this->subscriptionRepository->save($subscription); | ||
$result = true; | ||
} | ||
|
||
return $result; | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...n/Application/Command/Member/MarkSubscriptionAsFinished/mark_subscription_as_finished.php
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,22 @@ | ||
<?php | ||
|
||
namespace App\YoshiKan\Application\Command\Member\MarkSubscriptionAsFinished; | ||
|
||
trait mark_subscription_as_finished | ||
{ | ||
/** | ||
* @throws \Exception | ||
*/ | ||
public function markSubscriptionAsFinished(\stdClass $jsonCommand): bool | ||
{ | ||
$command = MarkSubscriptionAsFinished::hydrateFromJson($jsonCommand); | ||
|
||
$this->permission->CheckRole(['ROLE_DEVELOPER', 'ROLE_ADMIN', 'ROLE_CHIEF_EDITOR']); | ||
|
||
$handler = new MarkSubscriptionAsFinishedHandler($this->subscriptionRepository); | ||
$result = $handler->go($command); | ||
$this->entityManager->flush(); | ||
|
||
return $result; | ||
} | ||
} |
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
Oops, something went wrong.