src/BackendBundle/Helper/GraphQlJobHelper.php line 81

Open in your IDE?
  1. <?php
  2. namespace App\BackendBundle\Helper;
  3. use App\Entity\JobWorkField;
  4. use DateTime;
  5. use Doctrine\ORM\EntityManagerInterface;
  6. use App\BackendBundle\Interfaces\ProfileInterface;
  7. use App\BackendBundle\Model\GraphQL\CompanyProfileSimple;
  8. use App\BackendBundle\Model\GraphQL\InterestField as InterestFieldGQL;
  9. use App\BackendBundle\Model\GraphQL\Job as JobGQL;
  10. use App\BackendBundle\Model\GraphQL\JobEducationalPath as JobEducationalPathGQL;
  11. use App\BackendBundle\Model\GraphQL\JobExpertTerm as JobExpertTermGQL;
  12. use App\BackendBundle\Model\GraphQL\JobLinkMapping as JobLinkMappingGQL;
  13. use App\BackendBundle\Model\GraphQL\JobLinkMappingCategory as JobLinkMappingCategoryGQL;
  14. use App\BackendBundle\Model\GraphQL\JobLinkMappingType as JobLinkMappingTypeGQL;
  15. use App\BackendBundle\Model\GraphQL\JobLink as JobLinkGQL;
  16. use App\BackendBundle\Model\GraphQL\JobMarketDistricts as JobMarketDistrictsGQL;
  17. use App\BackendBundle\Model\GraphQL\JobMarketDistrict as JobMarketDistrictGQL;
  18. use App\BackendBundle\Model\GraphQL\JobSimple as JobSimpleGQL;
  19. use App\BackendBundle\Model\GraphQL\JobPreview as JobPreviewGQL;
  20. use App\BackendBundle\Model\GraphQL\JobRedirect as JobRedirectGQL;
  21. use App\BackendBundle\Model\GraphQL\JobRequirement as JobRequirementGQL;
  22. use App\BackendBundle\Model\GraphQL\JobRequirementCollection as JobRequirementCollectionGQL;
  23. use App\BackendBundle\Model\GraphQL\JobRequirementType as JobRequirementTypeGQL;
  24. use App\BackendBundle\Model\GraphQL\JobRequirementTypeCollection as JobRequirementTypeCollectionGQL;
  25. use App\BackendBundle\Model\GraphQL\JobSalary as JobSalaryGQL;
  26. use App\BackendBundle\Model\GraphQL\JobSalaryEntry as JobSalaryEntryGQL;
  27. use App\BackendBundle\Model\GraphQL\JobSchool as JobSchoolGQL;
  28. use App\BackendBundle\Model\GraphQL\JobScholasticDuration as JobScholasticDurationGQL;
  29. use App\BackendBundle\Model\GraphQL\JobSchoolSubjectMapping as JobSchoolSubjectMappingGQL;
  30. use App\BackendBundle\Model\GraphQL\JobSchoolSubject as JobSchoolSubjectGQL;
  31. use App\BackendBundle\Model\GraphQL\JobSector as JobSectorGQL;
  32. use App\BackendBundle\Model\GraphQL\JobWorkField as JobWorkFieldGQL;
  33. use App\BackendBundle\Model\GraphQL\School as SchoolGQL;
  34. use App\Entity\AddressDistrict;
  35. use App\Entity\CompanyProfile;
  36. use App\Entity\CompanyLocation;
  37. use App\Entity\InterestField;
  38. use App\Entity\Job;
  39. use App\Entity\JobDailyRoutine;
  40. use App\Entity\JobEducationalPath;
  41. use App\Entity\JobLink;
  42. use App\Entity\JobLinkMapping;
  43. use App\Entity\JobLinkMappingCategory;
  44. use App\Entity\JobLinkMappingType;
  45. use App\Entity\JobMarket;
  46. use App\Entity\JobPDF;
  47. use App\Entity\JobRedirect;
  48. use App\Entity\JobRedirectType;
  49. use App\Entity\JobRequirement;
  50. use App\Entity\JobRequirementMapping;
  51. use App\Entity\JobRequirementType;
  52. use App\Entity\JobSalary;
  53. use App\Entity\JobSalaryEntry;
  54. use App\Entity\JobSalaryType;
  55. use App\Entity\JobScholasticDuration;
  56. use App\Entity\JobSchool;
  57. use App\Entity\JobSchoolSubjectMapping;
  58. use App\Entity\JobSchoolSubject;
  59. use App\Entity\School;
  60. use App\Entity\SearchTag;
  61. class GraphQlJobHelper
  62. {
  63.     private EntityManagerInterface $em;
  64.     private GraphQlCommonHelper $graphqlCommonHelper;
  65.     private JobHelper $jobHelper;
  66.     private JobMarketHelper $jobMarketHelper;
  67.     private MediaHelper $mediaHelper;
  68.     private StoryHelper $storyHelper;
  69.     private VideoHelper $videoHelper;
  70.     private $backendDomain;
  71.     public function __construct(EntityManagerInterface $emAddressHelper $addressHelperGraphQlCommonHelper $graphqlCommonHelper,
  72.                                 JobMarketHelper        $jobMarketHelperJobHelper $jobHelperMediaHelper $mediaHelperStoryHelper $storyHelper,
  73.                                 VideoHelper            $videoHelper$backendDomain)
  74.     {
  75.         $this->em $em;
  76.         $this->addressHelper $addressHelper;
  77.         $this->graphqlCommonHelper $graphqlCommonHelper;
  78.         $this->jobHelper $jobHelper;
  79.         $this->jobMarketHelper $jobMarketHelper;
  80.         $this->mediaHelper $mediaHelper;
  81.         $this->storyHelper $storyHelper;
  82.         $this->videoHelper $videoHelper;
  83.         $this->backendDomain $backendDomain;
  84.     }
  85.     public function getDateString(DateTime $dateTime null): string
  86.     {
  87.         if (empty($dateTime)) {
  88.             return '';
  89.         }
  90.         return $dateTime->format("d.m.Y");
  91.     }
  92.     public function getJobsByProfile(ProfileInterface $profile): array
  93.     {
  94.         $jobsGQL = array();
  95.         $profileJobs $profile->getJobs();
  96.         foreach ($profileJobs as $profileJob) {
  97.             $jobsGQL[] = $this->getJobGQL($profileJob);
  98.         }
  99.         return $jobsGQL;
  100.     }
  101.     public function getJobSimple(Job $jobSrc): JobSimpleGQL
  102.     {
  103.         $jobSimple = new JobSimpleGQL();
  104.         $jobSimple->setId($jobSrc->getId());
  105.         $jobSimple->setName($jobSrc->getName());
  106.         $jobSimple->setBicID($jobSrc->getBicID());
  107.         $this->addJobSimpleInterestFields($jobSrc$jobSimple);
  108.         return $jobSimple;
  109.     }
  110.     public function getJobPreview(Job $jobSrc): JobPreviewGQL
  111.     {
  112.         $jobPreview = new JobPreviewGQL();
  113.         $jobPreview->setId($jobSrc->getId());
  114.         $jobPreview->setName($jobSrc->getName());
  115.         $image $this->graphqlCommonHelper->generateThumbnails($jobSrc->getTeaserImage());
  116.         $jobPreview->setImage($image);
  117.         return $jobPreview;
  118.     }
  119.     private function addJobSimpleInterestFields(Job $jobSrcJobSimpleGQL $job): void
  120.     {
  121.         $interestFields $jobSrc->getInterestFields();
  122.         /* @var $interestField InterestField */
  123.         foreach ($interestFields as $interestField) {
  124.             $interestFieldGQL $this->getinterestFieldGQL($interestField);
  125.             $job->addInterestField($interestFieldGQL);
  126.         }
  127.     }
  128.     public function getInterestFieldGQL(InterestField $interestField): InterestFieldGQL
  129.     {
  130.         $interestFieldGQL = new InterestFieldGQL();
  131.         $interestFieldGQL->setId($interestField->getId());
  132.         $interestFieldGQL->setInterestName($interestField->getInterestName());
  133.         $interestFieldGQL->setSubHeading($interestField->getSubHeading());
  134.         return $interestFieldGQL;
  135.     }
  136.     public function getJobGQL(Job $job$setVideoUrl false): JobGQL
  137.     {
  138.         $jobGQL = new JobGQL();
  139.         $jobGQL->setId($job->getId());
  140.         $jobGQL->setBicID($job->getBicID());
  141.         $jobGQL->setName($job->getName());
  142.         $jobGQL->setDescription($job->getDescription());
  143.         $jobGQL->setBicAnforderungen($job->getBicAnforderungen());
  144.         $jobGQL->setBicAlternativen($job->getBicAlternativen());
  145.         $jobGQL->setOperationsAndTasks($job->getOperationsAndTasks());
  146.         $jobGQL->setBicAusbildungBerufschule($job->getBicAusbildungBerufschule());
  147.         $jobGQL->setBicMoeglichkeiten($job->getBicMoeglichkeiten());
  148.         $this->setScholasticDuration($job$jobGQL);
  149.         $this->addInterestFields($job$jobGQL);
  150.         $this->addJobEducationalPaths($job$jobGQL);
  151.         $this->addJobEducationCompanies($jobGQL);
  152.         $this->addJobExpertTerms($job$jobGQL);
  153.         $this->addJobImage($job$jobGQL);
  154.         $this->addJobInsights($job$jobGQL);
  155.         $this->addJobLinkMappings($job$jobGQL);
  156.         $this->addJobMarketDistricts($job$jobGQL);
  157.         $this->addJobRedirects($job$jobGQL);
  158.         $this->addJobSalary($job$jobGQL);
  159.         $this->addJobSectors($job$jobGQL);
  160.         $this->addJobSchools($job$jobGQL);
  161.         $this->addJobSchoolSubjectMappings($job$jobGQL);
  162.         $this->addJobWorkFields($job$jobGQL);
  163.         $this->addJobVideoUrl($job$jobGQL$setVideoUrl);
  164.         $this->addJobPDFUrl($job$jobGQL);
  165.         $this->addRequirementsByType($job$jobGQL);
  166.         $this->addSearchTags($job$jobGQL);
  167.         return $jobGQL;
  168.     }
  169.     private function setScholasticDuration(Job $jobSrcJobGQL $job): void
  170.     {
  171.         $scholasticDuration $jobSrc->getScholasticDuration();
  172.         if (empty($scholasticDuration)) {
  173.             return;
  174.         }
  175.         $scholasticDurationGQL $this->prepareScholasticDuration($scholasticDuration);
  176.         $job->setScholasticDuration($scholasticDurationGQL);
  177.     }
  178.     public function prepareScholasticDuration(JobScholasticDuration $scholasticDuration): JobScholasticDurationGQL
  179.     {
  180.         $scholasticDurationGQL = new JobScholasticDurationGQL();
  181.         $scholasticDurationGQL->setId($scholasticDuration->getId());
  182.         $scholasticDurationGQL->setDurationName($scholasticDuration->getDurationName());
  183.         $scholasticDurationGQL->setPosition($scholasticDuration->getPosition());
  184.         return $scholasticDurationGQL;
  185.     }
  186.     private function getVideoUrl(Job $jobSrc): ?string
  187.     {
  188.         $jobDailyRoutines $this->jobHelper->getJobDailyRoutinesByJobVisible($jobSrc);
  189.         if (count($jobDailyRoutines) == 0) {
  190.             return null;
  191.         }
  192.         /* @var $jobDailyRoutine JobDailyRoutine */
  193.         $jobDailyRoutine $jobDailyRoutines[0];
  194.         return $jobDailyRoutine->getVideoUrl();
  195.     }
  196.     public function getJobReduced(Job $jobSrc): JobGQL
  197.     {
  198.         $job = new JobGQL();
  199.         $job->setId($jobSrc->getId());
  200.         $job->setBicID($jobSrc->getBicID());
  201.         $job->setName($jobSrc->getName());
  202.         return $job;
  203.     }
  204.     private function addInterestFields(Job $jobSrcJobGQL $job): void
  205.     {
  206.         $interestFields $jobSrc->getInterestFields();
  207.         /* @var $interestFielSrc InterestField */
  208.         foreach ($interestFields as $interestFieldSrc) {
  209.             $interestFieldGQL $this->prepareInterestField($interestFieldSrc);
  210.             $job->addInterestField($interestFieldGQL);
  211.         }
  212.     }
  213.     public function prepareInterestField(InterestField $interestField): InterestFieldGQL
  214.     {
  215.         $interestFieldGQL = new InterestFieldGQL();
  216.         $interestFieldGQL->setId($interestField->getId());
  217.         $interestFieldGQL->setInterestName($interestField->getInterestName());
  218.         return $interestFieldGQL;
  219.     }
  220.     private function addJobEducationalPaths(Job $jobSrcJobGQL $job): void
  221.     {
  222.         $educationalPaths $jobSrc->getJobEducationalPaths();
  223.         foreach ($educationalPaths as $educationalPath) {
  224.             $jobEducationalPathGQL $this->prepareJobEducationalPath($educationalPath);
  225.             $job->addJobEducationalPath($jobEducationalPathGQL);
  226.         }
  227.     }
  228.     public function prepareJobEducationalPath(JobEducationalPath $jobEducationalPath): JobEducationalPathGQL
  229.     {
  230.         $jobEducationalPathGQL = new JobEducationalPathGQL();
  231.         $jobEducationalPathGQL->setId($jobEducationalPath->getId());
  232.         $jobEducationalPathGQL->setName($jobEducationalPath->getName());
  233.         $jobEducationalPathGQL->setBicID($jobEducationalPath->getBicID());
  234.         $jobEducationalPathGQL->setDescription($jobEducationalPath->getDescription());
  235.         return $jobEducationalPathGQL;
  236.     }
  237.     private function addJobExpertTerms(Job $jobSrcJobGQL $job): void
  238.     {
  239.         $expertTerms $jobSrc->getJobExpertTerms();
  240.         foreach ($expertTerms as $expertTermSrc) {
  241.             $expertTerm = new JobExpertTermGQL();
  242.             $expertTerm->setExpertTermData($expertTermSrc);
  243.             $job->addExpertTerm($expertTerm);
  244.         }
  245.     }
  246.     private function addJobRedirects(Job $jobJobGQL $jobGQL): void
  247.     {
  248.         $jobRedirects $job->getJobRedirects();
  249.         /* @var $jobRedirect JobRedirect */
  250.         foreach ($jobRedirects as $jobRedirect) {
  251.             $jobRedirectGQL $this->prepareJobRedirectGQL($jobRedirect);
  252.             if (empty($jobRedirectGQL)) {
  253.                 continue;
  254.             }
  255.             $jobGQL->addJobRedirect($jobRedirectGQL);
  256.         }
  257.     }
  258.     public function prepareJobRedirectGQL(JobRedirect $jobRedirect): ?JobRedirectGQL
  259.     {
  260.         /* @var $job Job */
  261.         $job $jobRedirect->getDestJob();
  262.         if (empty($job)) {
  263.             return null;
  264.         }
  265.         $bicID $job->getBicID();
  266.         if (empty($bicID)) {
  267.             return null;
  268.         }
  269.         $jobRedirectGQL = new JobRedirectGQL();
  270.         $jobRedirectGQL->setBicID($bicID);
  271.         $jobRedirectGQL->setJobName($job->getName());
  272.         $strType $this->getJobRedirectTypeString($jobRedirect);
  273.         $jobRedirectGQL->setRedirectType($strType);
  274.         return $jobRedirectGQL;
  275.     }
  276.     private function getJobRedirectTypeString(JobRedirect $redirect): string
  277.     {
  278.         /* @var $type JobRedirectType */
  279.         $type $redirect->getJobRedirectType();
  280.         return $type->getTypeName();
  281.     }
  282.     private function addJobSalary(Job $jobSrcJobGQL $job): void
  283.     {
  284.         /* @var $jobSalary JobSalary */
  285.         $jobSalary $jobSrc->getSalary();
  286.         if (empty($jobSalary)) {
  287.             return;
  288.         }
  289.         $jobSalaryGQL $this->prepareJobSalary($jobSalary);
  290.         $job->setJobSalary($jobSalaryGQL);
  291.     }
  292.     public function prepareJobSalary(JobSalary $jobSalary): ?JobSalaryGQL
  293.     {
  294.         $jobSalaryGQL = new JobSalaryGQL();
  295.         $jobSalaryGQL->setId($jobSalary->getId());
  296.         $jobLehrlingseinkommen $jobSalary->getJobLehrlingseinkommenMapping();
  297.         if (!empty($jobLehrlingseinkommen)) {
  298.             $jobSalaryGQL->setLehrlingseinkommenUrl($jobLehrlingseinkommen->getSiteJobUrl());
  299.         }
  300.         $jobAmsMapping $jobSalary->getJobAmsMapping();
  301.         if (!empty($jobAmsMapping)) {
  302.             $jobSalaryGQL->setAmsUrl($jobAmsMapping->getAmsUrl());
  303.         }
  304.         $jobSalaryGQL->getCreatedAt($jobSalary->getCreatedAt()->format('d.m.Y'));
  305.         $this->addJobSalaryEntries($jobSalary$jobSalaryGQL);
  306.         return $jobSalaryGQL;
  307.     }
  308.     private function addJobSalaryEntries(JobSalary $jobSalaryJobSalaryGQL $jobSalaryGQL): void
  309.     {
  310.         $entries $jobSalary->getEntries();
  311.         /* @var $entry JobSalaryEntry */
  312.         foreach ($entries as $entry) {
  313.             $entryGQL = new JobSalaryEntryGQL();
  314.             $entryGQL->setId($entry->getId());
  315.             $strSalaryFrom $this->getSalaryString($entry->getSalaryFrom());
  316.             $entryGQL->setSalaryFrom($strSalaryFrom);
  317.             $strSalaryTo $this->getSalaryString($entry->getSalaryTo());
  318.             $entryGQL->setSalaryTo($strSalaryTo);
  319.             $entryGQL->setCreatedAt($entry->getCreatedAt()->format('d.m.Y'));
  320.             $salaryType $entry->getSalaryType();
  321.             $salaryTypeGQL $this->getJobSalaryTypeString($salaryType);
  322.             $entryGQL->setSalaryType($salaryTypeGQL);
  323.             $this->setJobSalaryEntryValue($jobSalaryGQL$entry);
  324.             $jobSalaryGQL->addEntry($entryGQL);
  325.         }
  326.     }
  327.     private function getSalaryString($dbString)
  328.     {
  329.         if ($dbString == 'null') {
  330.             return null;
  331.         }
  332.         return $dbString;
  333.     }
  334.     private function getJobSalaryTypeString(JobSalaryType $salaryType): string
  335.     {
  336.         $typeID $salaryType->getId();
  337.         switch ($typeID) {
  338.             case 1:
  339.                 return "YROA1";
  340.             case 2:
  341.                 return "YROA2";
  342.             case 3:
  343.                 return "YROA3";
  344.             case 4:
  345.                 return "YROA4";
  346.             case 5:
  347.                 return "ENTRY";
  348.         }
  349.         return "";
  350.     }
  351.     private function setJobSalaryEntryValue(JobSalaryGQL $jobSalaryGQLJobSalaryEntry $entry): void
  352.     {
  353.         /* @var $salaryType JobSalaryType */
  354.         $salaryType $entry->getSalaryType();
  355.         if ($salaryType->getId() != 5) {
  356.             return;
  357.         }
  358.         $jobSalaryGQL->setEntryValue($entry->getSalaryFrom());
  359.     }
  360.     private function addJobSectors(Job $jobSrcJobGQL $job): void
  361.     {
  362.         $sectors $jobSrc->getJobSectors();
  363.         foreach ($sectors as $sector) {
  364.             $jobSector = new JobSectorGQL();
  365.             $jobSector->setJobSectorData($sector);
  366.             $job->addJobSector($jobSector);
  367.         }
  368.     }
  369.     private function addJobSchools(Job $jobSrcJobGQL $job): void
  370.     {
  371.         $jobSchools $jobSrc->getJobSchools();
  372.         /* @var $jobSchool JobSchool */
  373.         foreach ($jobSchools as $jobSchool) {
  374.             $jobSchoolGQL = new JobSchoolGQL();
  375.             $jobSchoolGQL->setId($jobSchool->getId());
  376.             $school $jobSchool->getSchool();
  377.             $schoolGQL $this->graphqlCommonHelper->prepareSchool($school);
  378.             $jobSchoolGQL->setSchool($schoolGQL);
  379.             $job->addJobSchool($jobSchoolGQL);
  380.         }
  381.     }
  382.     private function addJobSchoolSubjectMappings(Job $jobSrcJobGQL $job): void
  383.     {
  384.         $jobSubjectMappings $jobSrc->getSchoolSubjectMappings();
  385.         /* @var $jobSubjectMappingSrc JobSchoolSubjectMapping */
  386.         foreach ($jobSubjectMappings as $jobSubjectMappingSrc) {
  387.             $jobSubjectMapping $this->prepareJobSchoolSubjectMapping($jobSubjectMappingSrc);
  388.             $job->addSchoolSubjectMapping($jobSubjectMapping);
  389.         }
  390.     }
  391.     public function prepareJobSchoolSubjectMapping(JobSchoolSubjectMapping $subjectMappingSrc): JobSchoolSubjectMappingGQL
  392.     {
  393.         $jobSubjectMapping = new JobSchoolSubjectMappingGQL();
  394.         $jobSubjectMapping->setId($subjectMappingSrc->getId());
  395.         $jobSchoolSubject $this->getJobSchoolSubject($subjectMappingSrc->getJobSchoolSubject());
  396.         $jobSubjectMapping->setJobSchoolSubject($jobSchoolSubject);
  397.         return $jobSubjectMapping;
  398.     }
  399.     public function getJobSchoolSubject(JobSchoolSubject $subjectSrc): JobSchoolSubjectGQL
  400.     {
  401.         $jobSchoolSubject = new JobSchoolSubjectGQL();
  402.         $jobSchoolSubject->setId($subjectSrc->getId());
  403.         $jobSchoolSubject->setSubjectName($subjectSrc->getSubjectName());
  404.         $jobSchoolSubject->setAbbreviation($subjectSrc->getAbbreviation());
  405.         return $jobSchoolSubject;
  406.     }
  407.     private function addJobWorkFields(Job $jobSrcJobGQL $job): void
  408.     {
  409.         $workFields $jobSrc->getJobWorkFields();
  410.         foreach ($workFields as $workField) {
  411.             $jobWorkFieldGQL $this->prepareJobWorkField($workField);
  412.             $job->addJobWorkField($jobWorkFieldGQL);
  413.         }
  414.     }
  415.     public function prepareJobWorkField(JobWorkField $jobWorkField): JobWorkFieldGQL
  416.     {
  417.         $jobWorkFieldGQL = new JobWorkFieldGQL();
  418.         $jobWorkFieldGQL->setId($jobWorkField->getId());
  419.         $jobWorkFieldGQL->setName($jobWorkField->getName());
  420.         $jobWorkFieldGQL->setBicID($jobWorkField->getBicID());
  421.         $jobWorkFieldGQL->setDescription($jobWorkField->getDescription());
  422.         return $jobWorkFieldGQL;
  423.     }
  424.     private function addRequirementsByType(Job $jobSrcJobGQL $job): void
  425.     {
  426.         $requirementMappings $jobSrc->getJobRequirementMappings();
  427.         if (empty($requirementMappings)) {
  428.             return;
  429.         }
  430.         $jobRequirementCollection $this->prepareJobRequirementCollection($requirementMappings->toArray());
  431.         $job->setRequirementsByType($jobRequirementCollection);
  432.     }
  433.     public function prepareJobRequirementCollection(array $requirementMappings): JobRequirementCollectionGQL
  434.     {
  435.         $jobRequirementCollection = new JobRequirementCollectionGQL();
  436.         /* @var $requirementMapping JobRequirementMapping */
  437.         foreach ($requirementMappings as $requirementMapping) {
  438.             $jobRequirementSrc $requirementMapping->getJobRequirement();
  439.             $requirementType $this->getJobRequirementTypeByRequirement($jobRequirementSrc);
  440.             $requirementTypeID $requirementType->getId();
  441.             $requirementTypeCollection $jobRequirementCollection->getRequirementTypeCollectionByID($requirementTypeID);
  442.             if (empty($requirementTypeCollection)) {
  443.                 $requirementTypeCollection = new JobRequirementTypeCollectionGQL();
  444.                 $requirementTypeCollection->setRequirementType($requirementType);
  445.                 $jobRequirementCollection->addRequirementType($requirementTypeID$requirementTypeCollection);
  446.             }
  447.             $jobRequirement $this->getJobRequirement($jobRequirementSrc);
  448.             $requirementTypeCollection->addRequirement($jobRequirement);
  449.         }
  450.         return $jobRequirementCollection;
  451.     }
  452.     private function addSearchTags(Job $jobSrcJobGQL $job): void
  453.     {
  454.         $searchTags $jobSrc->getSearchTags();
  455.         if (empty($searchTags)) {
  456.             return;
  457.         }
  458.         /* @var $searchTag SearchTag */
  459.         foreach ($searchTags as $searchTag) {
  460.             $tagName $searchTag->getName();
  461.             $job->addSearchTag($tagName);
  462.         }
  463.     }
  464.     private function addJobImage(Job $jobSrcJobGQL $job): void
  465.     {
  466.         $image $this->graphqlCommonHelper->generateThumbnails($jobSrc->getTeaserImage());
  467.         $job->setImage($image);
  468.     }
  469.     private function addJobMarketDistricts(Job $jobSrcJobGQL $job): void
  470.     {
  471.         $jobMarketDistricts $this->getJobMarketDistricts($jobSrc);
  472.         $job->setJobMarketDistricts($jobMarketDistricts);
  473.     }
  474.     private function addJobVideoUrl(Job $jobSrcJobGQL $job$setVideoUrl): void
  475.     {
  476.         if (!$setVideoUrl) {
  477.             return;
  478.         }
  479.         $videoUrl $this->getVideoUrl($jobSrc);
  480.         $job->setVideoUrl($videoUrl);
  481.     }
  482.     private function addJobPDFUrl(Job $jobSrcJobGQL $job): void
  483.     {
  484.         /* @var $jobPDF JobPDF */
  485.         $jobPDF $jobSrc->getJobPDF();
  486.         if (empty($jobPDF)) {
  487.             return;
  488.         }
  489.         $webPath $jobPDF->getWebPath();
  490.         $pdfUrl $this->backendDomain "$webPath";
  491.         $job->setPdfUrl($pdfUrl);
  492.     }
  493.     private function addJobInsights(Job $jobSrcJobGQL $job): void
  494.     {
  495.         $jobDailyRoutines $this->jobHelper->getJobDailyRoutinesByJobVisible($jobSrc);
  496.         foreach ($jobDailyRoutines as $jobDailyRoutine) {
  497.             $story $this->storyHelper->getStoryByDailyRoutine($jobDailyRoutine);
  498.             if (empty($story)) {
  499.                 continue;
  500.             }
  501.             $job->addInsight($story);
  502.         }
  503.     }
  504.     private function addJobLinkMappings(Job $jobSrcJobGQL $job): void
  505.     {
  506.         $linkMappings $jobSrc->getJobLinkMappings();
  507.         /* @var $linkMapping JobLinkMapping */
  508.         foreach ($linkMappings as $linkMapping) {
  509.             $linkMappingGQL $this->prepareJobLinkMapping($linkMapping);
  510.             $job->addJobLinkMapping($linkMappingGQL);
  511.         }
  512.     }
  513.     public function prepareJobLinkMapping(JobLinkMapping $linkMapping): JobLinkMappingGQL
  514.     {
  515.         $jobLinkMapping = new JobLinkMappingGQL();
  516.         $jobLinkMapping->setId($linkMapping->getId());
  517.         $jobLink $this->getJobLink($linkMapping);
  518.         $jobLinkMapping->setJobLink($jobLink);
  519.         $jobLinkMappingCategory $this->getJobLinkCategory($linkMapping);
  520.         $jobLinkMapping->setJobLinkMappingCategory($jobLinkMappingCategory);
  521.         $jobLinkMappingType $this->getJobLinkMappingType($linkMapping);
  522.         $jobLinkMapping->setJobLinkMappingType($jobLinkMappingType);
  523.         return $jobLinkMapping;
  524.     }
  525.     private function getJobLink(JobLinkMapping $linkMapping): JobLinkGQL
  526.     {
  527.         /* @var $jobLinkSrc JobLink */
  528.         $jobLinkSrc $linkMapping->getJobLink();
  529.         $jobLink = new JobLinkGQL();
  530.         $jobLink->setId($jobLinkSrc->getId());
  531.         $jobLink->setTitle($jobLinkSrc->getTitle());
  532.         $jobLink->setTitleFrontend($jobLinkSrc->getTitleFrontend());
  533.         $jobLink->setTitleBackend($jobLinkSrc->getTitleBackend());
  534.         $jobLink->setUrl($jobLinkSrc->getUrl());
  535.         return $jobLink;
  536.     }
  537.     private function getJobLinkCategory(JobLinkMapping $linkMapping)
  538.     {
  539.         /* @var $category JobLinkMappingCategory */
  540.         $category $linkMapping->getJobLinkMappingCategory();
  541.         $categoryGQL = new JobLinkMappingCategoryGQL();
  542.         $categoryGQL->setId($category->getId());
  543.         $categoryGQL->setName($category->getName());
  544.         return $categoryGQL;
  545.     }
  546.     private function getJobLinkMappingType(JobLinkMapping $linkMapping)
  547.     {
  548.         /* @var $type JobLinkMappingType */
  549.         $type $linkMapping->getJobLinkMappingType();
  550.         $linkType = new JobLinkMappingTypeGQL();
  551.         $linkType->setId($type->getId());
  552.         $linkType->setName($type->getName());
  553.         return $linkType;
  554.     }
  555.     private function getJobMarketDistricts(Job $jobSrc)
  556.     {
  557.         $jobMarketDistricts = new JobMarketDistrictsGQL();
  558.         $this->getJobMarketDistrictCompanies($jobMarketDistricts$jobSrc);
  559.         $this->getJobMarketDistrictJobs($jobMarketDistricts$jobSrc);
  560.         return $jobMarketDistricts;
  561.     }
  562.     private function getJobMarketDistrictCompanies(JobMarketDistrictsGQL $jobMarketDistrictsJob $jobSrc)
  563.     {
  564.         $companyProfiles $this->jobHelper->getJobTrainingCompanies($jobSrc);
  565.         /* @var $companyProfile CompanyProfile */
  566.         foreach ($companyProfiles as $companyProfile) {
  567.             $this->getJobMarketDistrictCompany($jobMarketDistricts$companyProfile);
  568.         }
  569.     }
  570.     private function getJobMarketDistrictCompany(JobMarketDistrictsGQL $jobMarketDistrictsCompanyProfile $companyProfile)
  571.     {
  572.         $companyProfileSimple $this->getCompanyProfileSimple($companyProfile);
  573.         $locations $companyProfile->getLocations();
  574.         /* @var $location CompanyLocation */
  575.         foreach ($locations as $location) {
  576.             $addressDistrict $this->getCompanyLocationAddressDistrict($location);
  577.             if (empty($addressDistrict)) {
  578.                 continue;
  579.             }
  580.             $this->checkJobMarketDistrict($jobMarketDistricts$addressDistrict);
  581.             /* @var $jobMarketDistrict JobMarketDistrictGQL */
  582.             $jobMarketDistrict $jobMarketDistricts->getDistrict($addressDistrict);
  583.             $jobMarketDistrict->addTrainingCompany($companyProfileSimple);
  584.         }
  585.     }
  586.     private function getJobMarketDistrictJobs(JobMarketDistrictsGQL $jobMarketDistrictsJob $jobSrc)
  587.     {
  588.         $jobMarkets $this->jobMarketHelper->getActiveJobOffersByJob($jobSrc);
  589.         if (empty($jobMarkets)) {
  590.             return;
  591.         }
  592.         /* @var $jobMarket JobMarket */
  593.         foreach ($jobMarkets as $jobMarket) {
  594.             $addressDistricts $this->getJobMarketAddressDistricts($jobMarket);
  595.             if (empty($addressDistricts)) {
  596.                 continue;
  597.             }
  598.             foreach ($addressDistricts as $addressDistrict) {
  599.                 $this->checkJobMarketDistrict($jobMarketDistricts$addressDistrict);
  600.                 /* @var $jobMarketDistrict JobMarketDistrictGQL */
  601.                 $jobMarketDistrict $jobMarketDistricts->getDistrict($addressDistrict);
  602.                 $companyProfileSimple $this->getCompanyProfileSimple($jobMarket->getCompanyProfile());
  603.                 $jobMarketDistrict->addJobMarketEntry($companyProfileSimple);
  604.             }
  605.         }
  606.     }
  607.     private function checkJobMarketDistrict(JobMarketDistrictsGQL $jobMarketDistrictsAddressDistrict $addressDistrict)
  608.     {
  609.         if ($jobMarketDistricts->hasDistrict($addressDistrict)) {
  610.             return;
  611.         }
  612.         $jobMarketDistrict = new JobMarketDistrictGQL();
  613.         $jobMarketDistrict->setDistrictID($addressDistrict->getId());
  614.         $jobMarketDistrict->setDistrictName($addressDistrict->getName());
  615.         $jobMarketDistricts->addDistrict($addressDistrict$jobMarketDistrict);
  616.     }
  617.     public function getCompanyProfileSimple(CompanyProfile $companyProfileSrc null)
  618.     {
  619.         if (empty($companyProfileSrc)) {
  620.             return null;
  621.         }
  622.         $companyProfileSimple = new CompanyProfileSimple();
  623.         $companyProfileSimple->setId($companyProfileSrc->getId());
  624.         $companyProfileSimple->setUuid($companyProfileSrc->getUuid());
  625.         $companyProfileSimple->setName($companyProfileSrc->getName());
  626.         return $companyProfileSimple;
  627.     }
  628.     private function getCompanyLocationAddressDistrict(CompanyLocation $location)
  629.     {
  630.         $address $location->getAddress();
  631.         if (empty($address)) {
  632.             return null;
  633.         }
  634.         return $this->addressHelper->getAddressDistrict($address);
  635.     }
  636.     private function getJobMarketAddressDistricts(JobMarket $jobMarket)
  637.     {
  638.         $addresses $jobMarket->getAddresses();
  639.         if (empty($addresses)) {
  640.             return null;
  641.         }
  642.         $districts = array();
  643.         foreach ($addresses as $address) {
  644.             $district $this->addressHelper->getAddressDistrict($address);
  645.             $districts[] = $district;
  646.         }
  647.         return $districts;
  648.     }
  649.     private function addJobEducationCompanies(JobGQL $job)
  650.     {
  651.         $companyProfiles $this->jobHelper->getCompanyProfilesByJobID($job->getId());
  652.         foreach ($companyProfiles as $companyProfile) {
  653.             $companyProfileSimple $this->getCompanyProfileSimple($companyProfile);
  654.             $job->addJobEducationCompany($companyProfileSimple);
  655.         }
  656.     }
  657.     public function getJobRequirement(JobRequirement $jobRequirementSrc)
  658.     {
  659.         $jobRequirement = new JobRequirementGQL();
  660.         $jobRequirement->setId($jobRequirementSrc->getId());
  661.         $jobRequirement->setBicID($jobRequirementSrc->getBicID());
  662.         $jobRequirement->setRequirementName($jobRequirementSrc->getRequirementName());
  663.         $jobRequirement->setDescription($jobRequirementSrc->getDescription());
  664.         return $jobRequirement;
  665.     }
  666.     public function getJobRequirementTypeByRequirement(JobRequirement $jobRequirementSrc)
  667.     {
  668.         /* @var $requirementTypeSrc JobRequirementType */
  669.         $requirementTypeSrc $jobRequirementSrc->getJobRequirementType();
  670.         $requirementTypeGQL = new JobRequirementTypeGQL();
  671.         $requirementTypeGQL->setId($requirementTypeSrc->getId());
  672.         $requirementTypeGQL->setBicID($requirementTypeSrc->getBicID());
  673.         $requirementTypeGQL->setTypeName($requirementTypeSrc->getTypeName());
  674.         $requirementTypeGQL->setShortName($requirementTypeSrc->getShortName());
  675.         return $requirementTypeGQL;
  676.     }
  677.     public function getJobRequirementType(JobRequirementType $jobRequirementType)
  678.     {
  679.         $requirementTypeGQL = new JobRequirementTypeGQL();
  680.         $requirementTypeGQL->setId($jobRequirementType->getId());
  681.         $requirementTypeGQL->setBicID($jobRequirementType->getBicID());
  682.         $requirementTypeGQL->setTypeName($jobRequirementType->getTypeName());
  683.         $requirementTypeGQL->setShortName($jobRequirementType->getShortName());
  684.         return $requirementTypeGQL;
  685.     }
  686. }