QfqController.php 1.92 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
require_once(__DIR__ . '/../../qfq/qfq/exceptions/UserFormException.php');
12
require_once(__DIR__ . '/../../qfq/qfq/exceptions/UserReportException.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
37
        } catch (qfq\UserReportException $e) {
            $html = $e->formatMessage();
38

39
40
        } catch (qfq\CodeException $e) {
            $html = $e->formatMessage();
41

42
43
        } catch (qfq\DbException $e) {
            $html = $e->formatMessage();
44
45
46
47
48
49
50

        } catch (qfq\ShellException $e) {
            $html = $e->formatMessage();

        } catch (qfq\DownloadException $e) {
            $html = $e->formatMessage();

51
52
53
54
        } catch (\Exception $e) {
            $html = "Generic Exception: " . $e->getMessage();
        }

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

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

60
61
62
63
        return $this->view->render();
    }

}