reelworx/t3-fakefrontend
最新稳定版本:v4.0.0
Composer 安装命令:
composer require reelworx/t3-fakefrontend
包简介
A library for TYPO3 extensions to initialize a 'fake frontend' environment. Mainly for CLI/BE purposes.
README 文档
README
This library for TYPO3 extensions provides a utility to bootstrap a fake frontend environment (TSFE and other things) to be used when doing frontend related stuff from within other contexts like the backend or CLI.
When to use this library?
This library comes in handy if you need to generate absolute frontend links for site from within non-frontend context.
Examples:
- If you generate mails from within a scheduler task, which should include links to frontend. You can the usual Fluid viewhelpers, once the "fake frontend" is established.
- If you generate frontend links in a backend module.
Usage
// quickest usage
$fakeFrontend = new \FakeFrontendService();
$fakeFrontend->executeInFEContext($pageUid, function () {
// do some work
});
// *If you need to do some more stuff manually, here is the longer version:*
// Note: This populates the globals TSFE, TYPO3_REQUEST and $_SERVER['HTTP_HOST']
// It is advisable to reset/unset those again, when not needed anymore.
// Especially in BE context this can cause unexpected side effects.
// create a fully initialized TSFE for given page uid
$fakeFrontend = new \FakeFrontendService();
$valid = $fakeFrontend->buildFakeFE($pageUid);
if ($valid) {
//
// ... do the work
//
$fakeFrontend->resetGlobals();
} else {
// resetGlobals() is done internally already
throw new \RuntimeException('Building fake FE failed', 0, $fakeFrontend->lastError);
}
A specific $GLOBALS['TSFE']->absRefPrefix can be enforced by configuring config.cliDomain in the template of the page.
The value auto means to use GeneralUtility::getIndpEnv('TYPO3_SITE_PATH') as absRefPrefix.
统计信息
- 总下载量: 9.85k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 1
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2022-01-29