src/Controller/IndexController.php
public function indexAction()
    {
        /* @var $request \Zend\Http\Request */
        $request     = $this->getRequest();
        $queryParams = $request->getQuery();
        $params      = $queryParams->get('params', []);
        $jsonFormat  = 'json' == $queryParams->get('format');
        $isRecruiter = $this->acl()->isRole(User::ROLE_RECRUITER);

        if (!$jsonFormat && !$request->isXmlHttpRequest()) {
            $session       = new Session('Jobs\Index');
            $sessionKey    = $this->auth()->isLoggedIn() ? 'userParams' : 'guestParams';
            $sessionParams = $session[$sessionKey];

            if ($sessionParams) {
                $params = array_merge($sessionParams, $params);
            } elseif ($isRecruiter) {
                $params['by'] = 'me';
            }

            $session[$sessionKey] = $params;
            $queryParams->set('params', $params);

            $this->searchForm->bind($queryParams);
        }

        if (!isset($params['sort'])) {
            $params['sort'] = '-date';
        }

        $paginator = $this->paginator('Jobs/Job', $params);

        $return = [
            'by'   => $queryParams->get('by', 'all'),
            'jobs' => $paginator,
        ];
        if (isset($this->searchForm)) {
            $return['filterForm'] = $this->searchForm;
        }

        $model = new ViewModel();
        $model->setVariables($return);
        $model->setTemplate('jobs/index/index');
        return $model;
    }
public function indexAction()
    {
        /* @var $request \Zend\Http\Request */
        $request     = $this->getRequest();
        $queryParams = $request->getQuery();
        $params      = $queryParams->get('params', []);
        $jsonFormat  = 'json' == $queryParams->get('format');
        $isRecruiter = $this->acl()->isRole(User::ROLE_RECRUITER);

        if (!$jsonFormat && !$request->isXmlHttpRequest()) {
            $session       = new Session('Jobs\Index');
            $sessionKey    = $this->auth()->isLoggedIn() ? 'userParams' : 'guestParams';
            $sessionParams = $session[$sessionKey];

            if ($sessionParams) {
                $params = array_merge($sessionParams, $params);
            } elseif ($isRecruiter) {
                $params['by'] = 'me';
            }

            $session[$sessionKey] = $params;
            $queryParams->set('params', $params);

            $this->searchForm->bind($queryParams);
        }

        if (!isset($params['sort'])) {
            $params['sort'] = '-date';
        }

        $paginator = $this->paginator('Jobs/Job', $params);

        $return = [
            'by'   => $queryParams->get('by', 'all'),
            'jobs' => $paginator,
        ];
        if (isset($this->searchForm)) {
            $return['filterForm'] = $this->searchForm;
        }

        $model = new ViewModel();
        $model->setVariables($return);
        $model->setTemplate('jobs/index/index');
        return $model;
    }
public function indexAction ( ) { /* @var $request \Zend\Http\Request */ $ request = $ this -> getRequest ( ) ; $ queryParams = $ request -> getQuery ( ) ; $ params = $ queryParams -> get ( 'params' , [ ] ) ; $ jsonFormat = 'json' == $ queryParams -> get ( 'format' ) ; $ isRecruiter = $ this -> acl ( ) -> isRole ( User :: ROLE_RECRUITER ) ; if ( ! $ jsonFormat && ! $ request -> isXmlHttpRequest ( ) ) { $ session = new Session ( 'Jobs\Index' ) ; $ sessionKey = $ this -> auth ( ) -> isLoggedIn ( ) ? 'userParams' : 'guestParams' ; $ sessionParams = $ session [ $ sessionKey ] ; if ( $ sessionParams ) { $ params = array_merge ( $ sessionParams , $ params ) ; } elseif ( $ isRecruiter ) { $ params [ 'by' ] = 'me' ; } $ session [ $ sessionKey ] = $ params ; $ queryParams -> set ( 'params' , $ params ) ; $ this -> searchForm -> bind ( $ queryParams ) ; } if ( ! isset ( $ params [ 'sort' ] ) ) { $ params [ 'sort' ] = '-date' ; } $ paginator = $ this -> paginator ( 'Jobs/Job' , $ params ) ; $ return = [ 'by' => $ queryParams -> get ( 'by' , 'all' ) , 'jobs' => $ paginator , ] ; if ( isset ( $ this -> searchForm ) ) { $ return [ 'filterForm' ] = $ this -> searchForm ; } $ model = new ViewModel ( ) ; $ model -> setVariables ( $ return ) ; $ model -> setTemplate ( 'jobs/index/index' ) ; return $ model ; }
List job postings

@return ViewModel
List job postings