TYPO3 最佳实践分配 cObject 数据以查看,因为 getContentObject() 已被弃用 [英] TYPO3 Best practice assigning cObject data to view since getContentObject() is depricated

查看:38
本文介绍了TYPO3 最佳实践分配 cObject 数据以查看,因为 getContentObject() 已被弃用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道这是如何在现代扩展中解决的,但无法弄清楚.他们中的大多数只是神奇的使用例如{data.uid} 在他们的视图中没有任何 $view->assign('data',...)

I was wondering how this is solved in modern extensions, but could not figure it out. Most of them just magical using e.g. {data.uid} inside their views without any $view->assign('data',...)

在我以前的动作中,我使用过这样的东西:

In my old actions I had used something like this:

public function myAction() {
  $data = $this->configurationManager->getContentObject()->data;
  $this->view->assign('data', $data);
}

由于 getContentObject() 在 v8 中被标记为已弃用,因此应将其替换为 getContentObjectRenderer(),但 Configuration-Manager 没有这样的功能.>

Since getContentObject() is marked as deprecated in v8, it should be replaced with getContentObjectRenderer(), but the Configuration-Manager has not such a function.

推荐答案

OK 玩了一会儿,搜索了很多类,原来的解决方案似乎仍然有效,已弃用的消息应用于另一个类在这种情况下没有意义:

OK after playing around a while and searching through a lot of classes, it seems that the original solution is still valid, the deprecated message applied to another class which has no meaning in this case:

$cObjectData = $this->configurationManager->getContentObject()->data;
$view->assign('data', $cObjectData);

Extension File Scanner 被错过了它的警告,使用此解决方案的日志中没有不推荐使用的消息,......抱歉!

The Extension File Scanner was miss leading me with its warning, there is no deprecated message inside the logs using this solution,... sorry!

这篇关于TYPO3 最佳实践分配 cObject 数据以查看,因为 getContentObject() 已被弃用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆