QfqController.php 1.75 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
<?php
/**
 * @author Rafael Ostertag <rafael.ostertag@math.uzh.ch>
 */

namespace IMATHUZH\Qfq\Controller;

use qfq;

require_once(__DIR__ . '/../../qfq/qfq/QuickFormQuery.php');
11
12
require_once(__DIR__ . '/../../qfq/qfq/exceptions/UserFormException.php');
require_once(__DIR__ . '/../../qfq/qfq/exceptions/UserReportExtension.php');
13
14
15
16
require_once(__DIR__ . '/../../qfq/qfq/exceptions/CodeException.php');
require_once(__DIR__ . '/../../qfq/qfq/exceptions/DbException.php');

class QfqController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
17

18
19
    public function showAction() {

Carsten  Rose's avatar
Carsten Rose committed
20
21
        $origErrorReporting = '';

22
23
        try {
            $contentObject = $this->configurationManager->getContentObject();
24
25
26
27
28
29

            // By T3 default 'E_NOTICE' is unset. E.g. 'Undefined Index' will throw an exception.
            // QFQ like to see those 'E_NOTICE'
            $origErrorReporting = error_reporting();
            error_reporting($origErrorReporting | E_NOTICE);

30
31
32
            $qfq = new \qfq\QuickFormQuery($contentObject->data);
            $html = $qfq->process();

33
        } catch (qfq\UserFormException $e) {
34
            $html = $e->formatMessage();
35
36
        } catch (qfq\UserReportException $e) {
            $html = $e->formatMessage();
37
38
39
40
41
42
43
44
        } catch (qfq\CodeException $e) {
            $html = $e->formatMessage();
        } catch (qfq\DbException $e) {
            $html = $e->formatMessage();
        } catch (\Exception $e) {
            $html = "Generic Exception: " . $e->getMessage();
        }

45
46
47
        // Restore has to be outside of try/catch - E_NOTICE needs to unset for further T3 handling after an QFQ Exception.
        error_reporting($origErrorReporting);

48
        $this->view->assign('qfqOutput', $html);
Carsten  Rose's avatar
Carsten Rose committed
49

50
51
52
53
        return $this->view->render();
    }

}