feat: add filtering of applications
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
namespace App\Service\Common;
|
||||
|
||||
use App\Entity\JobProfile;
|
||||
use App\Model\AbstractFilterDto;
|
||||
use App\Model\ApplicationFilterDto;
|
||||
|
||||
class ApplicationFilterHandler extends AbstractFilterHandler
|
||||
{
|
||||
protected string $namespace = 'filter:application';
|
||||
|
||||
public function getFilterSettings(): ApplicationFilterDto
|
||||
{
|
||||
if (null === $data = $this->getSession()->get($this->namespace)) {
|
||||
return new ApplicationFilterDto();
|
||||
}
|
||||
|
||||
$filterDto = new ApplicationFilterDto();
|
||||
|
||||
if (isset($data['id'])) {
|
||||
$filterDto->setId($data['id']);
|
||||
}
|
||||
if (isset($data['date_from'])) {
|
||||
$filterDto->setDateFrom($data['date_from']);
|
||||
}
|
||||
if (isset($data['date_to'])) {
|
||||
$filterDto->setDateTo($data['date_to']);
|
||||
}
|
||||
if (isset($data['job_profiles']) && 0 < count($data['job_profiles'])) {
|
||||
$jobProfiles = $this
|
||||
->entityManager
|
||||
->getRepository(JobProfile::class)
|
||||
->findBy(['id' => $data['job_profiles']])
|
||||
;
|
||||
$filterDto->setJobProfiles($jobProfiles);
|
||||
}
|
||||
if (isset($data['hotels']) && 0 < count($data['hotels'])) {
|
||||
$filterDto->setHotels($data['hotels']);
|
||||
}
|
||||
if (isset($data['duration']) && 0 < (int) $data['duration']) {
|
||||
$filterDto->setDuration($data['duration']);
|
||||
}
|
||||
if (isset($data['status'])) {
|
||||
$filterDto->setStatus($data['status']);
|
||||
}
|
||||
if (isset($data['include_past'])) {
|
||||
$filterDto->setIncludePast((bool) $data['include_past']);
|
||||
}
|
||||
|
||||
return $filterDto;
|
||||
}
|
||||
|
||||
protected function saveFilterSettings(AbstractFilterDto $filterDto): void
|
||||
{
|
||||
/** @var ApplicationFilterDto $filterDto */
|
||||
$this->getSession()->set($this->namespace, [
|
||||
'id' => $filterDto->getId(),
|
||||
'date_from' => $filterDto->getDateFrom(),
|
||||
'date_to' => $filterDto->getDateTo(),
|
||||
'job_profiles' => array_map(function (JobProfile $jobProfile) {
|
||||
return $jobProfile->getId();
|
||||
}, $filterDto->getJobProfiles()),
|
||||
'hotels' => $filterDto->getHotels(),
|
||||
'duration' => $filterDto->getDuration(),
|
||||
'status' => $filterDto->getStatus(),
|
||||
'include_past' => $filterDto->isIncludePast(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user