Backend\Modules\Error\Actions\Index::parse PHP Method

parse() protected method

Parse the correct messages into the template
protected parse ( )
    protected function parse()
    {
        parent::parse();
        // grab the error-type from the parameters
        $errorType = $this->getParameter('type');
        // set correct headers
        switch ($errorType) {
            case 'module-not-allowed':
            case 'action-not-allowed':
                $this->statusCode = Response::HTTP_FORBIDDEN;
                break;
            case 'not-found':
                $this->statusCode = Response::HTTP_NOT_FOUND;
                break;
            default:
                $this->statusCode = Response::HTTP_BAD_REQUEST;
                break;
        }
        // querystring provided?
        if ($this->getParameter('querystring') !== null) {
            // split into file and parameters
            $chunks = explode('?', $this->getParameter('querystring'));
            // get extension
            $extension = pathinfo($chunks[0], PATHINFO_EXTENSION);
            // if the file has an extension it is a non-existing-file
            if ($extension != '' && $extension != $chunks[0]) {
                // give a nice error, so we can detect which file is missing
                throw new ExitException('File not found', 'Requested file (' . htmlspecialchars($this->getParameter('querystring')) . ') not found.', Response::HTTP_NOT_FOUND);
            }
        }
        // assign the correct message into the template
        $this->tpl->assign('message', BL::err(\SpoonFilter::toCamelCase(htmlspecialchars($errorType), '-')));
    }