throw on missing user in get todays schedule
This commit is contained in:
parent
dd217e4142
commit
c0f35c88b7
1 changed files with 7 additions and 0 deletions
|
|
@ -7,6 +7,7 @@ use App\ScheduledNode\ScheduledNode;
|
||||||
use App\ScheduledNode\ScheduledNodeRepository;
|
use App\ScheduledNode\ScheduledNodeRepository;
|
||||||
use App\User\UserRepository;
|
use App\User\UserRepository;
|
||||||
use DateTimeImmutable;
|
use DateTimeImmutable;
|
||||||
|
use DomainException;
|
||||||
|
|
||||||
class GetTodaysSchedule
|
class GetTodaysSchedule
|
||||||
{
|
{
|
||||||
|
|
@ -19,6 +20,7 @@ class GetTodaysSchedule
|
||||||
* @return ScheduledNode[]
|
* @return ScheduledNode[]
|
||||||
*
|
*
|
||||||
* @throws BadRequestException
|
* @throws BadRequestException
|
||||||
|
* @throws DomainException
|
||||||
*/
|
*/
|
||||||
public function execute(GetTodaysScheduleRequest $request): array
|
public function execute(GetTodaysScheduleRequest $request): array
|
||||||
{
|
{
|
||||||
|
|
@ -31,6 +33,11 @@ class GetTodaysSchedule
|
||||||
$date = new DateTimeImmutable($request->date);
|
$date = new DateTimeImmutable($request->date);
|
||||||
$userId = $request->userId;
|
$userId = $request->userId;
|
||||||
$user = $this->userRepo->find($userId);
|
$user = $this->userRepo->find($userId);
|
||||||
|
if ($user === null) {
|
||||||
|
throw new DomainException(
|
||||||
|
"User with id: $userId doesnt exist"
|
||||||
|
);
|
||||||
|
}
|
||||||
$scheduledNodes = $this->scheduledNodeRepo->findByUser($user);
|
$scheduledNodes = $this->scheduledNodeRepo->findByUser($user);
|
||||||
|
|
||||||
return array_filter(
|
return array_filter(
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue