public function getList()
    {
        $pageType = $this->params('pageType', PageTypes::NORMAL);
        $pageId = $this->params('pageId', null);

        /** @var \Rcm\Validator\Page $validator */
        $validator = clone($this->getServiceLocator()->get(\Rcm\Validator\Page::class));
        $validator->setPageType($pageType);

        $return = [
            'valid' => true
        ];

        if (!$validator->isValid($pageId)) {
            $return['valid'] = false;
            $return['error'] = $validator->getMessages();

            /** @var \Zend\Http\Response $response */
            $response = $this->response;

            $errorCodes = array_keys($return['error']);

            foreach ($errorCodes as &$errorCode) {
                if ($errorCode == $validator::PAGE_EXISTS) {
                    $response->setStatusCode(409);
                    break;
                } elseif ($errorCode == $validator::PAGE_NAME) {
                    $response->setStatusCode(417);
                }
            }
        }

        return new JsonModel($return);
    }
public function getList()
    {
        $pageType = $this->params('pageType', PageTypes::NORMAL);
        $pageId = $this->params('pageId', null);

        /** @var \Rcm\Validator\Page $validator */
        $validator = clone($this->getServiceLocator()->get(\Rcm\Validator\Page::class));
        $validator->setPageType($pageType);

        $return = [
            'valid' => true
        ];

        if (!$validator->isValid($pageId)) {
            $return['valid'] = false;
            $return['error'] = $validator->getMessages();

            /** @var \Zend\Http\Response $response */
            $response = $this->response;

            $errorCodes = array_keys($return['error']);

            foreach ($errorCodes as &$errorCode) {
                if ($errorCode == $validator::PAGE_EXISTS) {
                    $response->setStatusCode(409);
                    break;
                } elseif ($errorCode == $validator::PAGE_NAME) {
                    $response->setStatusCode(417);
                }
            }
        }

        return new JsonModel($return);
    }
public function getList ( ) { $ pageType = $ this -> params ( 'pageType' , PageTypes :: NORMAL ) ; $ pageId = $ this -> params ( 'pageId' , null ) ; /** @var \Rcm\Validator\Page $validator */ $ validator = clone ( $ this -> getServiceLocator ( ) -> get ( \ Rcm \ Validator \ Page :: class ) ) ; $ validator -> setPageType ( $ pageType ) ; $ return = [ 'valid' => true ] ; if ( ! $ validator -> isValid ( $ pageId ) ) { $ return [ 'valid' ] = false ; $ return [ 'error' ] = $ validator -> getMessages ( ) ; /** @var \Zend\Http\Response $response */ $ response = $ this -> response ; $ errorCodes = array_keys ( $ return [ 'error' ] ) ; foreach ( $ errorCodes as & $ errorCode ) { if ( $ errorCode == $ validator :: PAGE_EXISTS ) { $ response -> setStatusCode ( 409 ) ; break ; } elseif ( $ errorCode == $ validator :: PAGE_NAME ) { $ response -> setStatusCode ( 417 ) ; } } } return new JsonModel ( $ return ) ; }
Check the page is valid and return a json response

@return JsonModel
Check the page is valid and return a json response