[TYPO3-mvc] Using extbase in cron scripts / scheduler tasks

Steffen Ritter info at rs-websystems.de
Wed Sep 1 17:29:16 CEST 2010


Am 01.09.2010 17:22, schrieb Axel Böswetter:
> So my solution for this problem is, that my scheduler extends the
> extbase dispatcher. Now you are able to call the
> initializeConfigurationManagerAndFrameworkConfiguration() method of the
> dispatcher.

Hey I did something similiar, but I had to use frontend-url generation 
in fluid to... so i went a step further.

I have an owen dispatcher which "tears up" the framework "and shuts it 
down" at the end. In fact I initialize parts of the TSFE so that I have 
full access to TypoScript and Linking Configuration.

I just instanciate the dispatcher
call tearUp

do my scheduler processing (including fluid template rendering (emails))

call tearDown

and good is it. I currently hardcoded my root page uid, but that easily 
could be done as a scheduler extra field.

class Tx_Rsmysherpasprojects_Service_Scheduler_ExtbaseMods_Dispatcher 
extends Tx_Extbase_Dispatcher {

	public function dispatchFrameworkForScheduler() {
		$GLOBALS['TT'] = new t3lib_timeTrackNull;
		$GLOBALS['TSFE'] = t3lib_div::makeInstance('tslib_fe', 
$GLOBALS['TYPO3_CONF_VARS'], 2, 0);
		$GLOBALS['TSFE']->sys_page = t3lib_div::makeInstance('t3lib_pageSelect');
		$GLOBALS['TSFE']->sys_page->init(TRUE);
		$GLOBALS['TSFE']->initTemplate();
		$GLOBALS['TSFE']->rootLine = 
$GLOBALS['TSFE']->sys_page->getRootLine(2, '');
		$GLOBALS['TSFE']->getConfigArray();


		$dummyConfiguration = array(
			'userFunc' => 'tx_extbase_dispatcher->dispatch',
			'pluginName' => 'pi1',
			'extensionName' => 'Rsmysherpasprojects',
			'controller' => 'Project',
			'action' => 'index',
			'switchableControllerActions.' => array(),
			'settings' => '< plugin.tx_rsmysherpasprojects.settings',
			'persistence' => '< plugin.tx_rsmysherpasprojects.persistence',
			'view' => '< plugin.tx_rsmysherpasprojects.view',
		);

	 
$this->initializeConfigurationManagerAndFrameworkConfiguration($dummyConfiguration);
		$requestBuilder = 
t3lib_div::makeInstance('Tx_Extbase_MVC_Web_RequestBuilder');
		$request = 
$requestBuilder->initialize(self::$extbaseFrameworkConfiguration);
		self::getPersistenceManager();
		self::$configurationManager->loadTypoScriptSetup();
	}

	public function tearDownFramework() {
		self::getPersistenceManager()->persistAll();
		self::$reflectionService->shutdown();
		unset($GLOBALS['TSFE']);
		unset($GLOBALS['TT']);
	}
}


More information about the TYPO3-project-typo3v4mvc mailing list