symfonytypo3extbasetypo3-10.x

Migrate TYPO3 Extbase task to Symfony command


I'm trying to migrate the extension pb_social to TYPO3 10 LTS but I'm stuck in the migration of the scheduler task that updates TYPO3 data from the social feeds.

I learned how to register a Symfony Console Command with the Services.yaml file so I can execute the command.

The problem is that the pb_social extension relies on Extbase same as its actual updateFeedDataCommand command.

So I tried to create a new command in the Symfony style and in its method execute() I instantiated:

$objectManager = GeneralUtility::makeInstance(ObjectManager::class);
/** @var PBSocialCommandController $controller */
$controller = $objectManager->get(PBSocialCommandController::class);

I already updated the properties of pb_social methods to use the new @TYPO3\CMS\Extbase\Annotation\Inject but still the injections seems not to work.

E.g. with:

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

$this->configurationManager is null when used.

What could be the problem?


Solution

  • Solved using Method Injection

    /**
     * @param ConfigurationManager $configurationManager
     */
    public function injectConfigurationManager(ConfigurationManager $configurationManager)
    {
        $this->configurationManager = $configurationManager;
    }