【问题标题】:The call to other actions does not work correctly with TYPO3 ExtbaseTYPO3 Extbase 无法正常调用其他操作
【发布时间】:2017-07-28 00:23:47
【问题描述】:

我有一个控制器,它通过一个操作调用 SocialProfile,以获取 Twitter、Facebook 或 Google+ 的个人资料并保存每个 SocialProfile 对象。这个动作的结尾调用了编辑动作,目的是最终用户添加类别组(不是 TYPO3 类别),问题是第二个动作不能正常工作。

我一直使用这条指令来调用editAction末尾的createAction

$this->redirect('edit', null, null, array('profileid' => "{$profileid}"),11);

现在是editAction

public function editAction( $socialProfile = NULL)
    {
        $arguments = $this->request->getArguments();
        var_dump($arguments);
        $groups = Enum\GruposContenidos::categoryGroupList();
        $this->view->assign('categoryGroups', $groups);
        $this->view->assign('socialProfile', $socialProfile);
    }

错误是下一个

没有为 Vendor\Extension\Controller\SocialProfileController->edit 设置必需的参数“socialProfile”。异常代码:1298012500

我在 URL 中发现 editAction 方法运行但未显示 var_dump。我按照 TYPO3 (https://wiki.typo3.org/Exception/Flow/1298012500) 中的错误代码进行了很多更改,但都不起作用。

调用此类操作的正确方法是什么,或者是否可以使用redirect 发送参数之类的方法?

editAction 在通过 Fluid 从操作列表中调用时效果很好,并且可以更改类别值。

TYPO3 7.6 和 PHP 5.6 正在开发中。

【问题讨论】:

    标签: php typo3 extbase typo3-7.6.x


    【解决方案1】:

    您是否尝试过 $this->redirect('edit', null, null, array('socialProfile' => $socialProfile),11); 并传递整个 SocialProfile 对象而不是其 ID?一般需要两个名字匹配。

    【讨论】:

    • 当我尝试传递 SocialProfile 对象 Could not serialize Domain Object .... It is neither an Entity with identity properties set, nor a Value Object. exception code:1260881688 时,我遇到了另一个问题,问题是我没有 UID。我将尝试在存储库中使用persistAll。关于名字,两个名字没必要匹配,因为结构是`'key'=>value`,有时候我更喜欢用不同的名字,比如分隔Fluid而不是Extbase。
    • 也许你可以试试$this->forward(),这样你就不需要坚持$socialProfile,而你的editAction()仍然可以使用它。对于名称,我的意思是 key 应该与您的操作中的参数名称匹配,例如 array('socialProfile' => $SocialProfile)public function editAction( $socialProfile = NULL),还是我错了?
    【解决方案2】:

    您可以在 initializeEditAction 中使用 var_dump。

    请尝试:

    $this->redirect('edit', null, null, array('profileid' => $profileid),11);
    

    你能告诉我来自editAction的注释,然后卸载并安装一次扩展。注释和方法参数是硬缓存的。该操作不应触发异常,如果您允许,像您一样,该参数可能为空,那么恐怕 extbase 由于某些缓存原因没有注意到这一点。

    对不起,我不能评论我没有足够的声誉:(

    【讨论】:

    • 我现在删除了注释以删除此约束,但我有扩展生成器为editAction 生成的注释。你们两个给我使用UID的想法,我试试看。
    猜你喜欢
    • 2016-12-16
    • 1970-01-01
    • 2013-11-22
    • 1970-01-01
    • 2018-03-15
    • 1970-01-01
    • 1970-01-01
    • 2015-06-06
    • 1970-01-01
    相关资源
    最近更新 更多