0
votes

I try to build an importer with a scheduler task.

The task creates an object manager which creates my import service. This import service has dependencies to the repository.

I simply create instances and add them to the repository.

It works well until i tried to specify on which pid my records are supposed to be saved. I tried to configure it in setup.txt.

plugin.tx_extkey {
    view {
        templateRootPath = {$plugin.tx_extkey.view.templateRootPath}
        partialRootPath = {$plugin.tx_extkey.view.partialRootPath}
        layoutRootPath = {$plugin.tx_extkey.view.layoutRootPath}
    }
    persistence {
        storagePid = {$plugin.tx_extkey.persistence.storagePid}
        classes {
            EXTNAME\EXTNAME\Domain\Model\MODELNAME {
                newRecordStoragePid = {$plugin.tx_extkey.persistence.storagePid}
            }
        }
    }
    features {
        # uncomment the following line to enable the new Property Mapper.
        # rewrittenPropertyMapper = 1
    }
}

module.tx_extkey {
    persistence < plugin.tx_extkey.persistence
}

But that didn't work. Everything is still saved to pid 1.

Are there any pitfalls that I might have overlooked?

3
pid 1 looks like the cast from the string, rather than a page ID. Therefore I suspect that the variable is not set.pgampe
another possible reason could be the wrong plugin - "tx_extkey" is actually "tx_extkey_pluginname" - so if you use multiple plugins make sure that you configure the stuff for the right plugin (that was actually my problem ;-) ) - full documentation is here: docs.typo3.org/typo3cms/ExtbaseFluidBook/b-ExtbaseReference/…Tobias Gaertner

3 Answers

1
votes

I found an ugly way. The BackendConfigurationManager does not get the extensionName when the service is executed though the scheduler. Manually setting it in the task resolves this.

$objectManager = GeneralUtility::makeInstance('TYPO3\CMS\Extbase\Object\ObjectManager');

/** @var BackendConfigurationManager $configurationManager */
$configurationManager = $objectManager->get('TYPO3\CMS\Extbase\Configuration\BackendConfigurationManager');
$configurationManager->setConfiguration(array(
    'extensionName' => 'hnsenvionjob'
));
0
votes

I use an ImportCommandController as recommended by lorenz in In an extbase extension, how to access the persistence layer from a scheduler task? (my actual code has changed in the meantime, let me know if you want it)

and I have to set the pid manually:

$item->setPid($storagePid);

-1
votes

There is an easy trick for that

add in your ts something like that

plugin.tx_extkey.settings.storagePid = {$plugin.tx_extkey.persistence.storagePid}

That will allow you to have access to your storage pid everywhere in your code where you have access to your ts. For example in controller

$this->settings['storagePid']