Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
TYPO3 Extbase-依赖项注入在服务类中工作吗?_Typo3_Extbase_Typo3 7.6.x - Fatal编程技术网

TYPO3 Extbase-依赖项注入在服务类中工作吗?

TYPO3 Extbase-依赖项注入在服务类中工作吗?,typo3,extbase,typo3-7.6.x,Typo3,Extbase,Typo3 7.6.x,我正在使用auth类型的服务添加基于API的登录。 我试图通过@inject向Extbase的FrontendUserRepository添加一个用户。 但这不起作用 我是做错了什么,还是现在使用依赖注入还为时过早 注:我知道我可以通过以下方式使用存储库: $objectManager = GeneralUtility::makeInstance('TYPO3\CMS\Extbase\Object\ObjectManager'); $this->frontendUserRepository

我正在使用auth类型的服务添加基于API的登录。 我试图通过
@inject
向Extbase的FrontendUserRepository添加一个用户。 但这不起作用

我是做错了什么,还是现在使用依赖注入还为时过早

注:我知道我可以通过以下方式使用存储库:

$objectManager = GeneralUtility::makeInstance('TYPO3\CMS\Extbase\Object\ObjectManager');
$this->frontendUserRepository = $objectManager->get('TYPO3\\CMS\\Extbase\\Domain\\Repository\\FrontendUserRepository');

带有
@Inject
注释的DI仅适用于TYPO3\CMS\Extbase\Object\ObjectManager实例加载的对象。auth服务是使用
GeneralUtility::makeInstanceService()
实例化的,后者反过来使用
GeneralUtility::makeInstance()
(请参见
TYPO3\CMS\Core\Authentication\AbstractUserAuthentication::checkAuthentication()
),因此
@Inject
注释无效。
您必须使用您自己已经提到的解决方法。

DI和
@Inject
注释仅适用于TYPO3\CMS\Extbase\Object\ObjectManager实例加载的对象。auth服务是使用
GeneralUtility::makeInstanceService()
实例化的,后者反过来使用
GeneralUtility::makeInstance()
(请参见
TYPO3\CMS\Core\Authentication\AbstractUserAuthentication::checkAuthentication()
),因此
@Inject
注释无效。 您必须使用您自己已经提到的解决方法。

[typo3 7.6] 我认为在auth服务中,所有extbase内容都没有正确加载。我在尝试在auth服务中使用extbase repos时遇到了很多错误(这些服务在控制器的上下文中运行得非常好)。我找到了一个关于可能的缺失部分初始化的链接:

[typo3 7.6]
我认为在auth服务中,所有extbase内容都没有正确加载。我在尝试在auth服务中使用extbase repos时遇到了很多错误(这些服务在控制器的上下文中运行得非常好)。我找到了一个关于可能的缺失部分初始化的链接:

你是对的。但是请看一下这篇关于这个问题的文章。
@inject
-方法可能不是最好的,即使它更短。我花了很多时间进行故障排除,只是为了满足Typo3的
@inject
要求。你是对的。但是请看一下这篇关于这个问题的文章。
@inject
-方法可能不是最好的,即使它更短。我花了很多时间进行故障排除,只是为了满足TYPO3的
@inject
要求注:在TYPO3中≧ 7.6第一行更改为
$objectManager=\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\objectManager')注:输入类型3≧ 7.6第一行更改为
$objectManager=\TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\objectManager')