src/Controller/TemplateController.php
public function viewAction()
    {
        $id = $this->params()->fromQuery('id');
        $channel = $this->params()->fromRoute('channel', 'default');
        $response = $this->getResponse();
        /* @var \Jobs\Entity\Job $job */
        try {
            $job = $this->initializeJob()->get($this->params(), true);
        } catch (NotFoundException $e) {
            $response->setStatusCode(Response::STATUS_CODE_404);
            return [
                'message' => sprintf($this->translator->translate('Job with id "%s" not found'), $id)
            ];
        }
        
        $mvcEvent             = $this->getEvent();
        $applicationViewModel = $mvcEvent->getViewModel();

        /* @var \Auth\Entity\User $user */
        $user = $this->auth()->getUser();

        /* @var \Zend\View\Model\ViewModel $model */
        $model = $this->viewModelTemplateFilter->getModel($job);

        if (
            Status::ACTIVE == $job->getStatus() or
            Status::WAITING_FOR_APPROVAL == $job->getStatus() or
            $job->getPermissions()->isGranted($user, PermissionsInterface::PERMISSION_VIEW) or
            $this->auth()->isAdmin()
        ) {
            $applicationViewModel->setTemplate('iframe/iFrameInjection');
        } elseif (Status::EXPIRED == $job->getStatus() or  Status::INACTIVE == $job->getStatus()) {
            $response->setStatusCode(Response::STATUS_CODE_410);
            $model->setTemplate('jobs/error/expired');
            $model->setVariables(
                [
                    'job'=>$job,
                    'message', 'the job posting you were trying to open, was inactivated or has expired'
                ]
            );
        } else {
            // there is a special handling for 404 in ZF2
            $response->setStatusCode(Response::STATUS_CODE_404);
            $model->setVariable('message', 'job is not available');
        }
        return $model;
    }
public function viewAction()
    {
        $id = $this->params()->fromQuery('id');
        $channel = $this->params()->fromRoute('channel', 'default');
        $response = $this->getResponse();
        /* @var \Jobs\Entity\Job $job */
        try {
            $job = $this->initializeJob()->get($this->params(), true);
        } catch (NotFoundException $e) {
            $response->setStatusCode(Response::STATUS_CODE_404);
            return [
                'message' => sprintf($this->translator->translate('Job with id "%s" not found'), $id)
            ];
        }
        
        $mvcEvent             = $this->getEvent();
        $applicationViewModel = $mvcEvent->getViewModel();

        /* @var \Auth\Entity\User $user */
        $user = $this->auth()->getUser();

        /* @var \Zend\View\Model\ViewModel $model */
        $model = $this->viewModelTemplateFilter->getModel($job);

        if (
            Status::ACTIVE == $job->getStatus() or
            Status::WAITING_FOR_APPROVAL == $job->getStatus() or
            $job->getPermissions()->isGranted($user, PermissionsInterface::PERMISSION_VIEW) or
            $this->auth()->isAdmin()
        ) {
            $applicationViewModel->setTemplate('iframe/iFrameInjection');
        } elseif (Status::EXPIRED == $job->getStatus() or  Status::INACTIVE == $job->getStatus()) {
            $response->setStatusCode(Response::STATUS_CODE_410);
            $model->setTemplate('jobs/error/expired');
            $model->setVariables(
                [
                    'job'=>$job,
                    'message', 'the job posting you were trying to open, was inactivated or has expired'
                ]
            );
        } else {
            // there is a special handling for 404 in ZF2
            $response->setStatusCode(Response::STATUS_CODE_404);
            $model->setVariable('message', 'job is not available');
        }
        return $model;
    }
public function viewAction ( ) { $ id = $ this -> params ( ) -> fromQuery ( 'id' ) ; $ channel = $ this -> params ( ) -> fromRoute ( 'channel' , 'default' ) ; $ response = $ this -> getResponse ( ) ; /* @var \Jobs\Entity\Job $job */ try { $ job = $ this -> initializeJob ( ) -> get ( $ this -> params ( ) , true ) ; } catch ( NotFoundException $ e ) { $ response -> setStatusCode ( Response :: STATUS_CODE_404 ) ; return [ 'message' => sprintf ( $ this -> translator -> translate ( 'Job with id "%s" not found' ) , $ id ) ] ; } $ mvcEvent = $ this -> getEvent ( ) ; $ applicationViewModel = $ mvcEvent -> getViewModel ( ) ; /* @var \Auth\Entity\User $user */ $ user = $ this -> auth ( ) -> getUser ( ) ; /* @var \Zend\View\Model\ViewModel $model */ $ model = $ this -> viewModelTemplateFilter -> getModel ( $ job ) ; if ( Status :: ACTIVE == $ job -> getStatus ( ) or Status :: WAITING_FOR_APPROVAL == $ job -> getStatus ( ) or $ job -> getPermissions ( ) -> isGranted ( $ user , PermissionsInterface :: PERMISSION_VIEW ) or $ this -> auth ( ) -> isAdmin ( ) ) { $ applicationViewModel -> setTemplate ( 'iframe/iFrameInjection' ) ; } elseif ( Status :: EXPIRED == $ job -> getStatus ( ) or Status :: INACTIVE == $ job -> getStatus ( ) ) { $ response -> setStatusCode ( Response :: STATUS_CODE_410 ) ; $ model -> setTemplate ( 'jobs/error/expired' ) ; $ model -> setVariables ( [ 'job' => $ job , 'message' , 'the job posting you were trying to open, was inactivated or has expired' ] ) ; } else { // there is a special handling for 404 in ZF2 $ response -> setStatusCode ( Response :: STATUS_CODE_404 ) ; $ model -> setVariable ( 'message' , 'job is not available' ) ; } return $ model ; }
Handles the job opening template in preview mode

@return ViewModel
@throws \RuntimeException
Handles the job opening template in preview mode