TYPO3创建前端用户

时间:2018-10-18 16:42:05

标签: typo3 typo3-9.x

在我的服务班里,有

/**
 * @var \TYPO3\CMS\Extbase\Domain\Repository\FrontendUserRepository
 * @inject
 */
protected $frontendUserRepository;

/**
 * @var \TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager
 * @inject
 */
protected $persistenceManager;

在函数中:

$objectManager = GeneralUtility::makeInstance('TYPO3\CMS\Extbase\Object\ObjectManager');
$this->frontendUserRepository = $objectManager->get('TYPO3\\CMS\\Extbase\\Domain\\Repository\\FrontendUserRepository');
$frontendUser = new FrontendUser();
$frontendUser->setUsername($bla);
$frontendUser->setPassword($bliep);
$this->frontendUserRepository->add($frontendUser);
$this->persistenceManager = $objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\PersistenceManager');
$this->persistenceManager->persistAll();

然后我得到了错误

  

表'dbname.tx_extbase_domain_model_frontenduser'不存在

如何将新用户存储在“ fe_users”表中?

1 个答案:

答案 0 :(得分:2)

在TypoScript安装程序extbase配置中创建表映射:

config.tx_extbase {
    persistence {
        classes {
            TYPO3\CMS\Extbase\Domain\Model\FrontendUser {
                mapping {
                    tableName = fe_users
                }
            }
        }
    }
}