Set sys_language_uid in an extbase command controller

。_饼干妹妹 提交于 2019-12-11 05:07:09

问题


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


回答1:


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);



来源:https://stackoverflow.com/questions/37706042/set-sys-language-uid-in-an-extbase-command-controller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!