【问题标题】:Get List of TYPO3 FE_User Group获取 TYPO3 FE_User Group 列表
【发布时间】:2015-02-22 10:30:16
【问题描述】:

如何获得所有前端用户组的列表?

我试过了:

/**
 * feUserGroupRepository
 *
 * @var \TYPO3\CMS\Extbase\Domain\Repository\FrontendUserGroupRepository
 * @inject
 */
protected $feUserGroupRepository = NULL;`

然后是这个:

$usergroups = $this->feUserGroupRepository->findAll();

我收到此错误:在非对象上调用成员函数 findAll()

我试过这样:

/**
 * @var \TYPO3\CMS\Extbase\Domain\Repository\FrontendUserGroupRepository $feUserGroupRepository
 */
  $feUserGroupRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Domain\\Repository\\FrontendUserGroupRepository');
  $allUsers = $feUserGroupRepository->findAll();`

根本不工作我收到此错误消息

PHP 可捕获的致命错误:参数 1 传递给

TYPO3\CMS\Extbase\Persistence\Repository::__construct() must implement interface
TYPO3\CMS\Extbase\Object\ObjectManagerInterface, none given, called in
C:\xampp\htdocs\typo3\typo3\sysext\core\Classes\Utility\GeneralUtility.php on 
line 4431 and
defined in C:\xampp\htdocs\typo3\typo3\sysext\extbase\Classes\Persistence\Repository.php

如何获得包含所有 feusergroup 的列表?

Rcord 类型?

【问题讨论】:

  • 请先改进您的格式。

标签: typo3 extbase


【解决方案1】:

该错误表明依赖注入不起作用。请确保在对数据库中缓存的更改进行更改后刷新系统缓存,这是更改类名或需要重新构建依赖项的更改。

如果您在开发环境中运行 TYPO3,您可以在安装工具(“重要操作”)中或直接在后端刷新系统缓存。 “刷新常规缓存”不会(!)刷新基于数据库的系统缓存。

根据您运行的 TYPO3 版本,您需要将前端用户组的记录类型(“tx_extbase_type”列)设置为 FrontendUserGroup。

不鼓励使用 makeInstance 来生成存储库的实例。您应该尽可能使用依赖注入(在这种情况下是这样),或者在不可能的情况下使用 ObjectManager。

【讨论】:

  • 是的,那么这应该足够了吗? /** * feUserGroupRepository * * @var \TYPO3\CMS\Extbase\Domain\Repository\FrontendUserGroupRepository * @inject */ protected $feUserGroupRepository = NULL;` 然后这个:$usergroups = $this->feUserGroupRepository->findAll() ;我已经在一个干净的系统上尝试过,但根本不起作用……没有任何组
  • 但是您不再收到错误消息了?所以你的问题是没有设置记录类型,请参阅我的答案中的提示。
  • 我更新了我的问题并添加了截图。我昨天已经创造了记录,没有任何改变。
猜你喜欢
  • 1970-01-01
  • 2023-03-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2023-03-11
  • 1970-01-01
相关资源
最近更新 更多