Можно ли расширить конфигурацию realurl в моем собственном расширении? Я попробовал следующее, но это не работает:
//ext_localconf.php of my extension
$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['_DEFAULT']['postVarSets']['_DEFAULT'] = array_merge($GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['realurl']['_DEFAULT']['postVarSets']['_DEFAULT'],
[
'gallery' => [
[
'GETvar' => 'tx_myext_p1gallery',
'lookUpTable' => [
'table' => 'tx_myext_domain_model_gallery',
'id_field' => 'uid',
'alias_field' => 'title',
'maxLength' => 120,
'useUniqueCache' => 1,
'addWhereClause' => ' AND NOT deleted',
'enable404forInvalidAlias' => 1,
'autoUpdate' => 1,
'expireDays' => 5,
'useUniqueCache_conf' => [
'spaceCharacter' => '_'
]
]
],
],
'controller' => [
[
'GETvar' => 'tx_myext_p1gallery[action]',
'noMatch' => 'bypass',
],
[
'GETvar' => 'tx_myext_p1gallery[controller]',
'noMatch' => 'bypass',
],
[
'GETvar' => 'tx_myext_p1gallery[backId]',
'noMatch' => 'bypass',
],
],
]
);
Если я использую тот же код в моем realurl_conf.php, то он работает.
Ваша модификация, вероятно, слишком поздняя, чтобы ее рассмотрел realurl.
Realurl выполняется очень рано в процессе ответа. Возможно, ваше расширение не будет выполнено до тех пор.
так как файл realurl_config находится под вашим контролем (типично: расширение сайта), и это только PHP, вы также можете включить свою модификацию расширения из «оригинала» realurl_conf.php
,
if (file_exists('typo3conf/ext/my_extension/Configuration/realurl_additional_conf.php')) {
include_once('typo3conf/ext/my_extension/Configuration/realurl_additional_conf.php');
}
Для этой цели в RealURL есть хук autoconf.
В вашем ext_localconf.php
Вы должны поставить:
if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('realurl')) {
$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['ext/realurl/class.tx_realurl_autoconfgen.php']['extensionConfiguration']['my_extkey'] = \Vendor\Ext\Hooks\RealUrlAutoConfiguration::class . '->addConfig';
}
ваш класс может выглядеть так:
<?php
namespace Vendor\Ext\Hooks;
class RealUrlAutoConfiguration
{
/**
* Generates additional RealURL configuration and merges it with provided configuration
*
* @param array $params Default configuration
*
* @return array Updated configuration
*/
public function addConfig($params)
{
return array_merge_recursive($params['config'], [
'postVarSets' => [
'_DEFAULT' => [
'gallery' => [
[
'GETvar' => 'tx_myext_p1gallery',
'lookUpTable' => [
'table' => 'tx_myext_domain_model_gallery',
'id_field' => 'uid',
'alias_field' => 'title',
'maxLength' => 120,
'useUniqueCache' => 1,
'addWhereClause' => ' AND NOT deleted',
'enable404forInvalidAlias' => 1,
'autoUpdate' => 1,
'expireDays' => 5,
'useUniqueCache_conf' => [
'spaceCharacter' => '_'
]
]
],
],
'controller' => [
[
'GETvar' => 'tx_myext_p1gallery[action]',
'noMatch' => 'bypass',
],
[
'GETvar' => 'tx_myext_p1gallery[controller]',
'noMatch' => 'bypass',
],
[
'GETvar' => 'tx_myext_p1gallery[backId]',
'noMatch' => 'bypass',
],
],
]
]
]);
}
}
Это работает только в том случае, если в конфигурации расширений RealURL активирован autoconf (в диспетчере расширений)