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

报告相同问题?

悬赏问题

  • ¥15 蓝桥oj3931,请问我错在哪里
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染