HEX
Server: Apache
System: Linux v38079.2is.nl 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User: democfellows (10015)
PHP: 8.1.34
Disabled: opcache_get_status
Upload Files
File: /var/www/vhosts/creativefellows.nl/apics.creativefellows.nl/src/Action/Jobs/ViewJobAction.php
<?php

namespace App\Action\Jobs;

use App\Action\TwigAction;
use App\Domain\Page\Service\PageReader;
use App\Domain\Page\Data\PageData;
use App\Domain\Navigation\Service\NavigationReader;
use App\Domain\Language\LanguageData;
use App\Handler\DefaultErrorHandler;
use App\Domain\Jobs\Service\JobReader;	
use App\Domain\Cookie\CookieData;

use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Views\Twig;


final class ViewJobAction extends TwigAction
{	
	
	private $twig;
	private $pageReader;
	private $navigationReader;
	private $errorHandler;
	private $language;
	private $JobReader;
	protected $cookies;
	
    public function __construct(
		Twig $twig,
		PageReader $pageReader, 
		NavigationReader $navigationReader,
		LanguageData $language,
		DefaultErrorHandler $errorHandler,
		JobReader $jobReader,
		CookieData $cookies
	){
        $this->twig 			= $twig;
		$this->pageReader 		= $pageReader;
		$this->navigationReader = $navigationReader;
		$this->language 		= $language;
		$this->cookies 			= $cookies;
		$this->errorHandler 	= $errorHandler;
		$this->jobReader 		= $jobReader;
    }
	
    public function action() : Response
	{	
		

		// arguments
	    $job_id 		= $this->args['remote_id'] ?? null;
		$post_section 	= $this->args['section'] ?? null;
		$queryParams 	= $this->request->getQueryParams() ?? null;
		$utm_tags 		= [];
		
		if($queryParams)
		{
		    $utm_tags["utm_source"] 	= $queryParams["utm_source"];
		    $utm_tags["utm_medium"] 	= $queryParams["utm_medium"];
			$utm_tags["utm_campaign"] 	= $queryParams["utm_campaign"];
		    $utm_tags["utm_term"] 		= $queryParams["utm_term"];
		    $utm_tags["utm_content"] 	= $queryParams["utm_content"];
		}
		
	
		// get data of page
        $this->page = $this->pageReader->getPageData($post_section);	
		
		// get jobs by remote ID
		$job = $this->jobReader->getJobByRemoteId($job_id); 
		
		// return error page if no result in page				
		if( !$this->page->hasData() ) return $this->errorHandler->respond($this->response,$this->page,$this->navigationReader->getNavigationData($post_section));
		
					
		$data = [
			"navigation" => $this->navigationReader->getNavigationData($post_section),
			"localization" => $this->language->localizedLanguageData()->setting("labels"),
			"page" => $this->page->twigData(),
			"jobs" => $job,
			"categories" => $this->jobReader->listJobCategories(),
			"utm_tags" => urldecode(http_build_query($utm_tags)),
			"cookies" => $this->cookies,
		];
		

		return $this->twig->render($this->response, "vacature-details.twig", $data);
		
    }
		
}