[TYPO3-dev] Fake / simulate frontend environment ( TSFE )
Steffen Kamper
steffen at sk-typo3.de
Wed Nov 21 00:53:47 CET 2007
Hi Elmar,
"Elmar Hinz" <elmar07 at googlemail.com> schrieb im Newsbeitrag
news:mailman.1.1195600295.1555.typo3-dev at lists.netfielders.de...
> Hi,
>
> by request of Dmitry I start this topic as a new thread, to make it the
> more
> easy findable within the list.
>
> How to quickly fake a FE in the BE?
>
> Here is a very, very official solution from Robert, found in his extension
> t3unit, now followed by the extension phpunit:
>
> http://typo3.org/extensions/repository/view/phpunit/3.1.15/info/mod1%252Findex.php/
>
>
> /**
> * Roughly simulates the frontend although being in the backend.
> *
> * @return void
> * @todo This is a quick hack, needs proper implementation
> */
> protected function simulateFrontendEnviroment() {
>
> global $TSFE, $TYPO3_CONF_VARS;
>
> // FIXME: Currently bad workaround which only initializes a few
> things, not really what you'd call a frontend enviroment
>
> require_once(PATH_tslib.'class.tslib_fe.php');
> require_once(PATH_t3lib.'class.t3lib_page.php');
> require_once(PATH_t3lib.'class.t3lib_userauth.php');
> require_once(PATH_tslib.'class.tslib_feuserauth.php');
> require_once(PATH_t3lib.'class.t3lib_tstemplate.php');
> require_once(PATH_t3lib.'class.t3lib_cs.php');
>
> $temp_TSFEclassName = t3lib_div::makeInstanceClassName('tslib_fe');
> $TSFE = new $temp_TSFEclassName(
> $TYPO3_CONF_VARS,
> t3lib_div::_GP('id'),
> t3lib_div::_GP('type'),
> t3lib_div::_GP('no_cache'),
> t3lib_div::_GP('cHash'),
> t3lib_div::_GP('jumpurl'),
> t3lib_div::_GP('MP'),
> t3lib_div::_GP('RDCT')
> );
> $TSFE->connectToDB();
> $TSFE->config = array(); // Must be filled with actual
> config!
>
> }
>
this solution is very limited, there are missing some inits. Maybe this will
fail on some typical FE-actions.
- global $TSFE doesn't make sense for me
- // FIXME: ... comment says more than i could say.
Did you compared it with the spellcheck-method from rte?
vg Steffen
More information about the TYPO3-dev
mailing list