userId; $user = $this->userRepo->find($userId); if ($user === null) { throw new DomainException("User with id: $userId doesnt exist"); } $textId = $request->textId; $text = $this->textRepo->find($textId); $nodesOfText = $this->nodeRepo->findByTextId($textId); $plan = $this->planRepo->create(new CreatePlanDto( name: $request->name, user: $user, )); foreach ($nodesOfText as $node) { $this->createScheduledNode->execute( new CreateScheduledNodeRequest( date: new DateTimeImmutable(), planId: $plan->getId(), ) ); } return $plan; } }