SHOW:
|
|
- or go back to the newest paste.
1 | class Tx_Myext_Eid_MyOwnEidScript implements t3lib_Singleton { | |
2 | ||
3 | /** | |
4 | * @var tslib_fe | |
5 | */ | |
6 | protected $tslibFe; | |
7 | ||
8 | /** | |
9 | * | |
10 | * @return string | |
11 | */ | |
12 | public function main() { | |
13 | $this->setupEnvironment(); | |
14 | // Own code here | |
15 | } | |
16 | ||
17 | /** | |
18 | * setupEnvironment | |
19 | * | |
20 | * Interacts with self::exportTslibFe. | |
21 | * | |
22 | * Workflow: | |
23 | * 1 self::setupEnvironment registers self::exportTslibFe as hook for tslib_fe | |
24 | * 2 self::setupEnvironment creates tslib_fe | |
25 | * 3 tslib_fe calls self::exportTslibFe | |
26 | * 4 self::exportTslibFe exports tslib_fe | |
27 | * 5 self::setupEnvironment has access to the now exported tslib_fe | |
28 | */ | |
29 | protected function setupEnvironment() { | |
30 | ||
31 | $GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['tslib/class.tslib_fe.php']['initFEuser'][] = '&Tx_Myext_Eid_MyOwnEidScript->exportTslibFe'; | |
32 | ||
33 | tslib_eidtools::connectDB(); | |
34 | tslib_eidtools::initFeUser(); | |
35 | ||
36 | $this->tslibFe->initUserGroups(); | |
37 | $this->tslibFe->initializeBackendUser(); | |
38 | ||
39 | } | |
40 | ||
41 | /** | |
42 | * exportTslibFe | |
43 | * | |
44 | * Workflow: | |
45 | * 1 self::setupEnvironment registers self::exportTslibFe as hook for tslib_fe | |
46 | * 2 self::setupEnvironment creates tslib_fe | |
47 | * 3 tslib_fe calls self::exportTslibFe | |
48 | * 4 self::exportTslibFe exports tslib_fe | |
49 | * 5 self::setupEnvironment has access to the now exported tslib_fe | |
50 | * | |
51 | * So this needs to be public because it gets called from tslib_fe | |
52 | * right after fe_user is present. | |
53 | * | |
54 | * @param array $params | |
55 | * @param tslib_fe $tslibFe | |
56 | * @return void | |
57 | */ | |
58 | public function exportTslibFe(array $params, tslib_fe $tslibFe) { | |
59 | $this->tslibFe = $tslibFe; | |
60 | } | |
61 | } |