typo3extbasetypo3-7.6.xtypo3-7.x

Set sys_language_uid in an extbase command controller


I have a command controller (an importer) run by scheduler, which should persist data as such:

foreach ($items as $item){
  // store it
  $entry = $this->objectManager->get('STUBR\Importer\Domain\Model\Item');
  $entry->setTitle($item['Title']);
  $entry->setData(json_encode($item));
  // manually set the storage page (defined in scheduler form)
  $entry->setPid($itemStoragePid); // works
  // manually set the language (defined in scheduler form)
  // EDIT
  // $entry->setSysLanguageUid = -1; // had typo
  $entry->set_languageUid(-1); // works
  // END EDIT
  $this->itemRepository->add($entry);
}

While neither pid nor sys_language_uid are set in the model, setPid behaves as expected, but setSysLanguageUid does not.

I'm aware that something is or was not quite right with setSysLanguageUid() in extbase (https://forge.typo3.org/issues/45873), although I wasn't able to grasp the problem entirely.

How do I manually store into the sys_language_uid column?

PS: I've tried Extbase Model: setSysLanguageUid not working but probably I missed something


Solution

  • It's solved, I had a typo above

    Solution from @Chi at https://stackoverflow.com/a/33798615/160968

    /**
     * languageUid
     * @var int
     */
    protected $languageUid;
    
    /**
     * @param int $languageUid
     * @return void
     */
    public function setLanguageUid($languageUid) {
        $this->languageUid = $languageUid;
    }
    
    /**
     * @return int
     */
    public function getLanguageUid() {
        return $this->languageUid;
    }
    

    And then $entry->setLanguageUid(-1);