Download src/Billing/Application/CommandHandlers/DeletePlanCommandHandler.php from pnacorp/AIKEEDO: direct link, hf CLI and curl.
- Browser
- Download file 1.1 kB
-
https://huggingface.co/pnacorp/AIKEEDO/resolve/main/src/Billing/Application/CommandHandlers/DeletePlanCommandHandler.php
- Command line
-
hf download hf://pnacorp/AIKEEDO/src/Billing/Application/CommandHandlers/DeletePlanCommandHandler.php
-
curl -L -o DeletePlanCommandHandler.php https://huggingface.co/pnacorp/AIKEEDO/resolve/main/src/Billing/Application/CommandHandlers/DeletePlanCommandHandler.php
1.1 kB
| declare(strict_types=1); | |
| namespace Billing\Application\CommandHandlers; | |
| use Billing\Application\Commands\DeletePlanCommand; | |
| use Billing\Domain\Events\PlanDeletedEvent; | |
| use Billing\Domain\Exceptions\PlanNotFoundException; | |
| use Billing\Domain\Repositories\PlanRepositoryInterface; | |
| use Psr\EventDispatcher\EventDispatcherInterface; | |
| class DeletePlanCommandHandler | |
| { | |
| /** | |
| * @param PlanRepositoryInterface $repo | |
| * @param EventDispatcherInterface $dispatcher | |
| * @return void | |
| */ | |
| public function __construct( | |
| private PlanRepositoryInterface $repo, | |
| private EventDispatcherInterface $dispatcher, | |
| ) { | |
| } | |
| /** | |
| * @param DeletePlanCommand $cmd | |
| * @return void | |
| * @throws PlanNotFoundException | |
| */ | |
| public function handle(DeletePlanCommand $cmd): void | |
| { | |
| $plan = $this->repo->ofId($cmd->id); | |
| // Delete the plan from the repository | |
| $this->repo->remove($plan); | |
| // Dispatch the plan deleted event | |
| $event = new PlanDeletedEvent($plan); | |
| $this->dispatcher->dispatch($event); | |
| } | |
| } | |