- actions and notifications refactor (#88)
* wip * fix * fix * fix * add test * fix * wip * fix * fix translations Co-authored-by: EwelinaLasowy <ewelina.lasowy@blumilk.pl>
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Toby\Domain\Actions\VacationRequest;
|
||||
|
||||
use Toby\Domain\VacationRequestStateManager;
|
||||
use Toby\Domain\VacationTypeConfigRetriever;
|
||||
use Toby\Eloquent\Models\User;
|
||||
use Toby\Eloquent\Models\VacationRequest;
|
||||
|
||||
class AcceptAsTechnicalAction
|
||||
{
|
||||
public function __construct(
|
||||
protected VacationRequestStateManager $stateManager,
|
||||
protected VacationTypeConfigRetriever $configRetriever,
|
||||
protected WaitForAdminApprovalAction $waitForAdminApprovalAction,
|
||||
protected ApproveAction $approveAction,
|
||||
) {}
|
||||
|
||||
public function execute(VacationRequest $vacationRequest, User $user): void
|
||||
{
|
||||
$this->stateManager->acceptAsTechnical($vacationRequest, $user);
|
||||
|
||||
if ($this->configRetriever->needsAdministrativeApproval($vacationRequest->type)) {
|
||||
$this->waitForAdminApprovalAction->execute($vacationRequest);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->approveAction->execute($vacationRequest);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user