Translations
Info
All page names need to be in English.
en da  de  fr  it  ja  km  nl  ru  zh

CommandController In Scheduler Task

From TYPO3Wiki
Jump to: navigation, search

This feature is part of Extbase 4.7.

Register commandController

A controller which processes requests from the command line. This controller is generally used for scheduler tasks.

In order to use your commandController in a scheduler task, you have to register it in your ext_localconf.php.

$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['extbase']['commandControllers'][] = 'Tx_YourExtension_Command_NameofCommandController';

Notice that all CommandControllers will be available under the "extbase / Extbase CommandController Task" menu entry at first.

20120423-jgbya6r4jhfqcaxnqpee3iugtq.jpg

Choose it and you will find your own CommandControllers.

20120423-rqi9qr38dy8nius4g9sxqsjqp6.jpg

After reloading the page, the method's arguments will be displayed as input fields so you can define their value.

20120423-f7r5jsp96s12jb6e1m38pccwn2.jpg

Use TypoScript settings in CommandController

Inject the configurationManager 4.5

/**
 * @var Tx_Extbase_Configuration_ConfigurationManagerInterface
 * @inject
 */
protected $configurationManager;

6

/**
 * @var \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface
 * @inject
 */
protected $configurationManager;

And get your configuration (does not work in __construct, because the dependency is injected after object instantiation):

$this->settings = $this->configurationManager->getConfiguration(Tx_Extbase_Configuration_ConfigurationManagerInterface::CONFIGURATION_TYPE_SETTINGS, 'extensionName', 'pluginName');

$settings = $this->configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK,, 'extensionName', 'pluginName');

In TYPO3 4.5, where you can't inject, you create the configuration manager like this:

$this->configurationManager = t3lib_div::makeInstance('Tx_Extbase_Object_ObjectManager')->get('Tx_Extbase_Configuration_ConfigurationManager')

Keep in mind that since the Scheduler is not running in frontend context, the configuration is read from module.tx_myext.settings.

in Configuration/TypoScript/setup.txt

Without configuration Manager

/**
 * Update Stuff
 * @param string $param1
 * @param string $param2
 * @param string $param3
 */
public function UpdateStuffCommand($param1 = 10, $param2 = 20, $param3 = 30) {