[TYPO3-mvc] How to call an extbase controller within scheduler task

Claus Due claus at wildside.dk
Fri Dec 2 12:47:46 CET 2011


Hi Sören,

CommandController is preferred since you are looking for a CLI dispatch, so in any case I would use the scheduler-integration from the link I gave rather than faking GET requests. But regarding your "real" problem - the mapping settings should be automatically passed, but if I am not mistaken you have to add the mapping information at TypoScript position:

config.tx_extbase.persistence.classes.Tx_Myext_Classname {
	tableName = …
	recordType = ...
}

This might be programatically incorrect but it works…

I have never managed to get mapping working by adding in plugin.tx_myext.persistence.classes but it works every time when added to config.tx_extbase.persistence.classes - why this is so, I'm not sure. I very rarely use this mapping method. It could be a bug or misleading default TS. In any case: if someone knows why a plugin.tx_myext.persistence.classes mapping does not work but the same mapping in config.tx_extbase.persistence.classes does, please chip in!

Cheers,
Claus

On Dec 2, 2011, at 12:32 PM, Sören Kracker wrote:

> Hi Claus,
> thanks for the hint, but I have problems with fed too.
> First of all: When I try the example Dummy noop, I get an error:
> Execution of task "Extbase CommandController Task (fed)" failed with the following message: Task failed to execute successfully. Class: Tx_Fed_Scheduler_Task
> 
> When I try my CommandController I get the same error. I debugged my code and it aborts when trying to call a repository method of a mapped class. So I've ended up with the same problem as without using fed.
> How can I pass my mapping settings?
> 
> plugin.tx_myext.persistence.classes.Tx_Myext_Domain_Model_Myname {
>    mapping {
>        tableName = tx_myotherext_domain_model_myname
>        recordType = Tx_Myext_Domain_Model_Myname
>    }
> }
> 
> Greetings,
> 
> Sören
> 
> Am 02.12.2011 10:12, schrieb Claus Due:
>> Hi Sören,
>> 
>> Better yet:
>> 
>> Use a CommandController and this feature:
>> 
>> https://review.typo3.org/#change,6932
>> 
>> Extension FED provides this feature now. The change request has also been made for Extbase itself and should be compatible, so you can start out by using the feature in FED and then moving to Extbase once a version including that feature is released.
>> 
>> This should be much, much more flexible than overriding $_GET (seriously bad idea).
>> 
>> Kind regards,
>> Claus
>> 
>> 
>> On Dec 1, 2011, at 5:27 PM, Sören Kracker wrote:
>> 
>>> Hi,
>>> I need to call a controller of my extbase extension using a task of TYPO3 scheduler.
>>> I always get following error (manually called in backend with admin user):
>>> The default controller can not be determined. Please check for Tx_Extbase_Utility_Extension::configurePlugin() in your ext_localconf.php.
>>> 
>>> My configurePlugin:
>>> 
>>> Tx_Extbase_Utility_Extension::configurePlugin(
>>>    $_EXTKEY,
>>>    'Myplugin',
>>>    array(
>>>        'Mycontroller' =>  'list, import, show, new, create, edit, update, delete',
>>>    ),
>>>    // non-cacheable actions
>>>    array(
>>>        'Mycontroller' =>  'create, update, delete, import',
>>>    )
>>> );
>>> 
>>> 
>>> Here's the scheduler class:
>>> 
>>> class Tx_Myext_Utility_Scheduler extends tx_scheduler_Task {
>>>    public function execute() {
>>>        try {
>>>            t3lib_div::devlog('--- working ---', 'myext', 0);
>>>            $configuration = array(
>>>                'extensionName' =>  'Myext',
>>>                'pluginName' =>  'Myplugin',
>>>                'controller' =>  'Mycontroller',
>>>                'action' =>  'import',
>>>                'switchableControllerActions' =>  array(
>>>                    'Mycontroller' =>  array(
>>>                        'actions' =>  'import'
>>>                    )
>>>                )
>>>            );
>>>            $bootstrap = t3lib_div::makeInstance('Tx_Extbase_Core_Bootstrap');
>>>            $bootstrap->run('', $configuration);
>>>            return TRUE;
>>>        }
>>>        catch(Exception $e) {
>>>            t3lib_div::devlog('--- error ---'.$e->getMessage(), 'myext', 0);
>>>            return FALSE;
>>>        }
>>>    }
>>> }
>>> 
>>> I'm not sure if my bootstrap-call is correct. Maybe somebody got a working example how to do this?!
>>> 
>>> Greetings,
>>> 
>>> Sören
>>> _______________________________________________
>>> TYPO3-project-typo3v4mvc mailing list
>>> TYPO3-project-typo3v4mvc at lists.typo3.org
>>> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc
>> _______________________________________________
>> TYPO3-project-typo3v4mvc mailing list
>> TYPO3-project-typo3v4mvc at lists.typo3.org
>> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc
> _______________________________________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc



More information about the TYPO3-project-typo3v4mvc mailing list