[TYPO3-mvc] Using extbase in cron scripts / scheduler tasks
Axel Böswetter
evilbmp at gmail.com
Tue Apr 19 15:58:25 CEST 2011
Hi,
new year and new extbase - same "problem". I just wanted to ask, if the dispatcher
rework of extbase v1.3 changed the way of implementing scheduler/ cron tasks?
As the dispatcher class is now deprecated, do I have to extend the bootstrap
class instead of?
So, is there anything new to note or just implement it the known way by extending
the dispatcher class?
Greets,
Axel Böswetter
> Hi Franz,
>
> I found your post with instantiating a dispatcher first - seems to
> work,
> but only limited. I have a customized user model extending the
> frontend user
> model of extbase.
> By simply instantiating a fake dispatcher, the framework configuration
> won't
> get initialized (e.g. typoscript persistence settings).
> So the mapping between my user model and the fe_users table is not
> known
> to the framework at that time.
> I tried a little with the dispatch() method of the dispatcher class,
> but there too much stuff is processed, which I don't need right now...
> In addition calling the dispatch() method results in executing of a
> given/ existing controller action of my extbase-based extension, which
> can be avoided by putting a fake action for the scheduler in the
> respective controller class. But that's really complicated.
>
> 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.
>
> Example code:
>
> class Tx_Extkey_Tasks_MyTaskLogic extends Tx_Extbase_Dispatcher {
>
> public function execute(&$pObj) {
> $configuration = array(
> 'settings' => '< plugin.tx_extkey.settings',
> 'persistence' => '< plugin.tx_extkey.persistence',
> 'view' => '< plugin.tx_extkey.view',
> '_LOCAL_LANG' => '< plugin.tx_extkey._LOCAL_LANG'
> );
>
> $this->initializeConfigurationManagerAndFrameworkConfiguration($config
> uration);
>
> self::$extbaseFrameworkConfiguration['persistence']['storagePid']
> = '10'; // storage pid of user records
> $this->userRepository =
> t3lib_div::makeInstance('Tx_Extkey_Domain_Repository_UserRepository');
>
> $this->feUserObj =
> $this->userRepository->findByUid((int)$this->feUserUid);
>
> debug($this->feUserObj);
>
> return TRUE;
> }
> }
>
> As my original scheduler task class already extends the
> tx_scheduler_Task class, you have to outsource the business logic to
> another class - as already mentioned in the scheduler documentation
> regarding searialized objects and out of sync errors (see: Working
> with serialized objects).
>
> Hopefully, this will help somebody in the future.
>
> Regards,
> Axel Böswetter
>> Hey,
>>
>>> as the topic says, is there a way to use the extbase framework
>>> within
>>> cron scripts respectivly scheduler tasks? What has to be
>>> instantiated
>>> to
>>> do so? In my special case I already have an extbase-based extension.
>>> Now
>>> I want to implement a scheduler task and want to make use of the
>>> persistence functionality of extbase, which means using the
>>> repository
>>> objects of my existing extension.
>>> Is this already possible? How?
>> You need a fake Dispatcher for that - for details please search the
>> list, it's been asked and answered already (IIRC even with "cron" or
>> "scheduler" in the topic title).
>>
More information about the TYPO3-project-typo3v4mvc
mailing list