-
Notifications
You must be signed in to change notification settings - Fork 21
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
e5317ef
commit d19ccdd
Showing
29 changed files
with
317 additions
and
274 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,29 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Reconmap\Controllers\Commands; | ||
|
||
use Psr\Http\Message\ResponseInterface; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
use Reconmap\Controllers\Controller; | ||
use Reconmap\Models\CommandSchedule; | ||
use Reconmap\Models\CommandUsage; | ||
use Reconmap\Repositories\CommandScheduleRepository; | ||
use Reconmap\Repositories\CommandUsageRepository; | ||
|
||
class AddCommandUsageController extends Controller | ||
{ | ||
public function __construct(private readonly CommandUsageRepository $repository) | ||
{ | ||
} | ||
|
||
public function __invoke(ServerRequestInterface $request): ResponseInterface | ||
{ | ||
/** @var CommandUsage $commandSchedule */ | ||
$commandSchedule = $this->getJsonBodyDecodedAsClass($request, new CommandUsage()); | ||
$commandSchedule->creator_uid = $request->getAttribute('userId'); | ||
|
||
$commandSchedule->id = $this->repository->insert($commandSchedule); | ||
|
||
return $this->createStatusCreatedResponse($commandSchedule); | ||
} | ||
} |
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,24 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Reconmap\Controllers\Commands; | ||
|
||
use Psr\Http\Message\ServerRequestInterface; | ||
use Reconmap\Controllers\Controller; | ||
use Reconmap\Repositories\CommandRepository; | ||
use Reconmap\Repositories\CommandUsageRepository; | ||
|
||
class DeleteCommandUsageController extends Controller | ||
{ | ||
public function __construct(private readonly CommandUsageRepository $repository) | ||
{ | ||
} | ||
|
||
public function __invoke(ServerRequestInterface $request, array $args): array | ||
{ | ||
$commandId = intval($args['commandId']); | ||
|
||
$success = $this->repository->deleteById($commandId); | ||
|
||
return ['success' => $success]; | ||
} | ||
} |
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,28 @@ | ||
<?php declare(strict_types=1); | ||
|
||
namespace Reconmap\Controllers\Commands; | ||
|
||
use League\Route\Http\Exception\NotFoundException; | ||
use Psr\Http\Message\ServerRequestInterface; | ||
use Reconmap\Controllers\Controller; | ||
use Reconmap\Repositories\CommandRepository; | ||
use Reconmap\Repositories\CommandUsageRepository; | ||
|
||
class GetCommandUsageController extends Controller | ||
{ | ||
public function __construct(private readonly CommandUsageRepository $repository) | ||
{ | ||
} | ||
|
||
public function __invoke(ServerRequestInterface $request, array $args): array | ||
{ | ||
$commandId = (int)$args['commandId']; | ||
|
||
$command = $this->repository->findById($commandId); | ||
if (is_null($command)) { | ||
throw new NotFoundException(); | ||
} | ||
|
||
return $command; | ||
} | ||
} |
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
Oops, something went wrong.