[TYPO3-dev] Fake / simulate frontend environment ( TSFE )
Mario Matzulla
mario.melanie at arcor.de
Wed Nov 21 17:28:14 CET 2007
Hi Elmar,
cal creates a TSFE in its api too. We copied most of the stuff from the
spellchecker (rte). But there is one drawback:
$GLOBALS['TSFE']->initFEuser();
If you are logged in to the frontend while calling this method, you get
logged out. So I decided to extend the tslib_fe class and overwrite the
according functions:
require_once (PATH_tslib.'class.tslib_fe.php');
class tx_cal_tsfe extends tslib_fe {
function tx_cal_tsfe($TYPO3_CONF_VARS, $id, $type, $no_cache='',
$cHash='', $jumpurl='',$MP='',$RDCT=''){
return $this->tslib_fe($TYPO3_CONF_VARS, $id, $type, $no_cache,
$cHash, $jumpurl,$MP,$RDCT);
}
function pageNotFoundHandler($code, $header='', $reason='') {
//do nothing
}
function pageNotFoundAndExit($reason='', $header='') {
// do nothing
}
}
Regards,
Mario
Elmar Hinz schrieb:
> 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!
>
> }
>
>
More information about the TYPO3-dev
mailing list