doyp9057 2017-10-05 13:03
浏览 37
已采纳

typo3后端扩展的createAction不会保留数据

I'm in a migration process from typo3 6.2.31 to 7.6.23

I have the following function:

public function createAction(\TYPO3\Institutsvideoverwaltung\Domain\Model\Category $newCategory) {
    $contentCat = $this->request->getArgument('newCategory');
    if ($contentCat['isRoot'] == '1') {
        $this->categoryRepository->add($newCategory);
        $this->addFlashMessage($newCategory->getName(), 'Kategorie erfolgreich angelegt!', \TYPO3\CMS\Core\Messaging\AbstractMessage::OK);
    } else {
        if (!empty($_POST['tx_institutsvideoverwaltung_auditgarant_institutsvideoverwaltungvideoverwaltungbackend']['catAllocationUIDs'])) {
            $catAllocationUIDs = $this->request->getArgument('catAllocationUIDs');
            foreach ($catAllocationUIDs as $catAllocationUID) {
                $category = $this->categoryRepository->findByUid($catAllocationUID);
                $category->addChildCategory($newCategory);
                $this->categoryRepository->update($category);
            }
            $this->addFlashMessage($newCategory->getName(), 'Kategorie erfolgreich angelegt!', \TYPO3\CMS\Core\Messaging\AbstractMessage::OK);
        } else {
            $this->addFlashMessage('Das Objekt wurde nicht angelegt, da keine Zuordnung erfolgt ist. Wenn es sich um kein Wurzelelement handelt, nehmen Sie zumindest eine Zuordnung vor.', '', \TYPO3\CMS\Core\Messaging\AbstractMessage::ERROR);
        }
    }
    /*  }*/
    $this->redirect('list');
}

It says all works fine, but it does not persist data. What could be the problem?

When I add manually a record to databse it is not shown as well :(

Update Out Var_dump enter image description here

  • 写回答

2条回答 默认 最新

  • doushang9172 2017-10-06 17:39
    关注

    After some TeamViewer investigations we found the problem located in the the Model and in the TCA.

    The Model had the attribute protected $uid = '' . Of course the UID cannot be a string and should not be declared as this. However, the debug in the createAction said the object is a "persisted entity" and so the Persistence Manager thought there is nothing to do. After removing the $uid from the model and updating to TCA to become 7 LTS compatible, the problem was solved.

    I guess its not a problem to declare the $uid as an integer in the model but as a string it was just too much for the system. Amazing that this worked in TYPO3 6 LTS...

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?