问题
I have a little question:
How do I connect an eid script in my extension with the MySQL database? What is the best practise to do so?
回答1:
This should be a good point to start:
<?php
/**
* @var $TSFE \TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
*/
$TSFE = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController', $TYPO3_CONF_VARS, 0, 0);
\TYPO3\CMS\Frontend\Utility\EidUtility::initLanguage();
// Get FE User Information
$TSFE->initFEuser();
// Important: no Cache for Ajax stuff
$TSFE->set_no_cache();
$TSFE->checkAlternativeIdMethods();
$TSFE->determineId();
$TSFE->initTemplate();
$TSFE->getConfigArray();
\TYPO3\CMS\Core\Core\Bootstrap::getInstance()->loadConfigurationAndInitialize();
$TSFE->cObj = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer');
$TSFE->settingLanguage();
$TSFE->settingLocale();
/**
* Initialize Database
*/
\TYPO3\CMS\Frontend\Utility\EidUtility::connectDB();
?>
The eID file must be registered in ext_localconf.php
as follows:
$GLOBALS['TYPO3_CONF_VARS']['FE']['eID_include']['sha1Converter'] = 'EXT:myext/Classes/Eid/myEidFile.php';
If you want to use eID to work with Extbase, you should read this post as it is not suggested to use eID for applications where a lot of database requests are necessary.
来源:https://stackoverflow.com/questions/27989408/connect-to-database-with-eid