问题描述
扩展程序的ext_conf_template.txt
中有一些设置.
There are a few settings in the ext_conf_template.txt
in my extension.
我想检查这些设置之一的值,但是要检查typoscript
而不是PHP.
I want to check the value of one of these settings, but in typoscript
, not in PHP.
在PHP中,它的工作方式如下:
In PHP it works like this:
unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['myExt'])
我应该如何在打字稿中做这件事?
How should I do this in typoscript?
推荐答案
我在代码段扩展中做了类似的操作(请参阅完整的 Github上的代码),我刚刚在其中添加了自定义的TypoScript条件:
I did something similar in my code snippet extension (see complete code on Github), where I just added a custom TypoScript condition:
[DanielGoerz\FsCodeSnippet\Configuration\TypoScript\ConditionMatching\AllLanguagesCondition]
// some conditional TS
[global]
条件实现非常简单:
namespace DanielGoerz\FsCodeSnippet\Configuration\TypoScript\ConditionMatching;
use DanielGoerz\FsCodeSnippet\Utility\FsCodeSnippetConfigurationUtility;
use TYPO3\CMS\Core\Configuration\TypoScript\ConditionMatching\AbstractCondition;
class AllLanguagesCondition extends AbstractCondition
{
/**
* Check whether allLanguages is enabled
* @param array $conditionParameters
* @return bool
*/
public function matchCondition(array $conditionParameters)
{
return FsCodeSnippetConfigurationUtility::isAllLanguagesEnabled();
}
}
然后在FsCodeSnippetConfigurationUtility
中检查实际的TYPO3_CONF_VARS
值:
And the check for the actual TYPO3_CONF_VARS
value is done in FsCodeSnippetConfigurationUtility
:
namespace DanielGoerz\FsCodeSnippet\Utility;
class FsCodeSnippetConfigurationUtility
{
/**
* @return array
*/
private static function getExtensionConfiguration()
{
return unserialize($GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['fs_code_snippet']);
}
/**
* @return bool
*/
public static function isAllLanguagesEnabled()
{
$conf = self::getExtensionConfiguration();
return !empty($conf['enableAllLanguages']);
}
}
也许符合您的需求.
这篇关于如何在错字中访问ext_conf_template.txt(扩展名配置)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!