1. Go to this page and download the library: Download phphd/pipeline-bundle library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
final readonly class CreateVacationRequestCommandDto
{
public function __construct(
public int $userId,
public int $vacationTypeId,
#[Assert\DateTime]
public string $startDate,
#[Assert\DateTime]
public string $endDate,
) {
}
}
#[AsMessageHandler(bus: 'command.bus')]
final readonly class ConvertVacationRequestCommandHandler
{
public function __invoke(CreateVacationRequestCommandDto $dto): CreateVacationRequestCommand
{
$employee = $this->employeeRepository->find($dto->userId);
$vacationType = $this->vacationTypeRepository->find($dto->vacationTypeId);
$vacationPeriod = VacationPeriod::fromStringDates($dto->startDate, $dto->endDate);
return new CreateVacationRequestCommand($employee, $vacationType, $vacationPeriod);
}
}
use PhPhD\Pipeline\NextForwarded;
#[NextForwarded]
final readonly class CreateVacationRequestCommand
{
public function __construct(
public Employee $employee,
public VacationType $vacationType,
public VacationPeriod $vacationPeriod,
) {
}
}
#[AsMessageHandler(bus: 'command.bus')]
final readonly class CreateVacationRequestHandler
{
public function __invoke(CreateVacationRequestCommand $command)
{
// The core business logic that deals with domain entities rather than primitives...
}
}
#[AsMessageHandler(bus: 'command.bus')]
final readonly class ConvertVacationRequestCommandHandler
{
/** @return NextForwarded<CreateVacationRequestCommand> */
public function __invoke(CreateVacationRequestCommandDto $dto): NextForwarded
{
return new NextForwarded($this->createCommandFromDto($dto));
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.