[TYPO3-mvc] Using repositories in eID script

Pankaj Lele pankaj at lelesys.com
Sat Mar 19 06:16:41 CET 2011


Hello!

I have following code which runs perfectly in an eID script to access 
database records through persistence repositories for AJAX requests.

Just to get an idea if this is too much hacking?


require_once(PATH_t3lib.'class.t3lib_page.php');
/* this is needed to have extbase properly pass through 
Tx_Extbase_Persistence_Mapper_DataMapFactory::includeTca().
*/
$GLOBALS['TSFE'] = t3lib_div::makeInstance('tslib_fe', 
$GLOBALS['TYPO3_CONF_VARS'], 0, 0);
$GLOBALS['TSFE']->sys_page = t3lib_div::makeInstance('t3lib_pageSelect');
// get instance of object manager
$objectManger = t3lib_div::makeInstance('Tx_Extbase_Object_ObjectManager');
// example
$myRepo = $objectManger->get('Tx_MyExt_Domain_Repository_myRepository');
// do whatever with $myRepo

// save changes back to tables. needed only when you are expecting 
something to be saved back to db table. No need for read only access
$objectManger->get('Tx_Extbase_Persistence_Manager')->persistAll();

BTW, this can be helpful to others who are interested in using eID for AJAX.

Thanks

-- 

With best regards,
Pankaj Lele
---------------------------

CTO & Executive Director
Lelesys Infotech Pvt. Ltd.
Pune/Goa, India

Web: http://www.lelesys.com

[Certified TYPO3 Integrator]


More information about the TYPO3-project-typo3v4mvc mailing list