forked from PHORAX/formhandler
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDispatcher.php
More file actions
93 lines (80 loc) · 3.24 KB
/
Dispatcher.php
File metadata and controls
93 lines (80 loc) · 3.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
namespace Typoheads\Formhandler\Controller;
use Psr\Http\Message\ResponseInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use Typoheads\Formhandler\Component\Manager;
use Typoheads\Formhandler\Plugin\AbstractPlugin;
use Typoheads\Formhandler\Utility\Globals;
/* *
* This script is part of the TYPO3 project - inspiring people to share! *
* *
* TYPO3 is free software; you can redistribute it and/or modify it under *
* the terms of the GNU General Public License version 2 as published by *
* the Free Software Foundation. *
* *
* This script is distributed in the hope that it will be useful, but *
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
* TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General *
* Public License for more details. *
* */
/**
* The Dispatcher instantiates the Component Manager and delegates the process to the given controller.
*/
class Dispatcher extends AbstractPlugin
{
/**
* Compontent Manager
*
* @var Manager
*/
protected $componentManager;
/**
* The global Formhandler values
*
* @var Globals
*/
protected $globals;
/**
* The Formhandler utility functions
*
* @var \Typoheads\Formhandler\Utility\GeneralUtility
*/
protected $utilityFuncs;
public function main(array $settings): ResponseInterface
{
$this->componentManager = GeneralUtility::makeInstance(Manager::class);
$this->globals = GeneralUtility::makeInstance(Globals::class);
$this->utilityFuncs = GeneralUtility::makeInstance(\Typoheads\Formhandler\Utility\GeneralUtility::class);
//init flexform
$this->pi_initPIflexForm();
$this->pi_loadLL();
/*
* Parse values from flexform:
* - Template file
* - Translation file
* - Predefined form
* - E-mail settings
* - Required fields
* - Redirect page
*/
$templateFile = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'template_file', 'sDEF');
$langFile = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'lang_file', 'sDEF');
$predef = $this->pi_getFFvalue($this->cObj->data['pi_flexform'], 'predefined', 'sDEF');
$this->globals->setCObj($this->cObj);
$this->globals->setRequest($this->request);
$this->globals->getCObj()->setCurrentVal($predef);
$this->globals->setPredef($predef);
$controller = GeneralUtility::makeInstance(FormController::class);
if (strlen($templateFile) > 0) {
$controller->setTemplateFile($templateFile);
}
if (strlen($langFile) > 0) {
$controller->setLangFiles([$langFile]);
}
if (strlen($predef) > 0) {
$controller->setPredefined($predef);
}
$result = $controller->process($settings);
return $result;
}
}