[TYPO3-english] Command Controller: I can't execute a command that uses class repositories of my extension

Mikel lists at con-version.com
Tue Nov 7 14:18:17 CET 2017


This TypoScrips won’t help, as you don’t have a module nor a plugin (module = backend module, plugin = frontend plugin).

But I don’t get it right now. Can you please focus? :-)

As far as I know, DependencyInjection does not work in the tasks. You have to build the instances in the constructor of your task.

Can you do the following:
1. Register your task in ext_localconf.php (see code below)
2. Extend the AbstractTask
3. Place the execute task
4. Build your instance of your repo directly within this method (or in the constructor, but without using dependency injection)
5. Fetch a single record by an existing UID
6. var_dump the result and trigger the task manually via the scheduler

Examples (this code is tested and works in 8.7.8)

1. 

$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['scheduler']['tasks'][\Conversion\ConversionWebsite\Tasks\TestTask::class] = array(
   'extension' => $_EXTKEY,
   'title' => 'Foobar Test'
);
2. 3. 4. 5.

class TestTask extends AbstractTask
{

   public function execute() {
      $objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
      $apprep = $objectManager->get(\Conversion\ConversionWebsite\Domain\Repository\CustomerRepository::class);

      DebuggerUtility::var_dump($apprep->findByUid(1));

   }

}



More information about the TYPO3-english mailing list