Created
February 1, 2017 12:37
-
-
Save cedricziel/95bd6ddbe595ead078bd0c7bc6e3dd53 to your computer and use it in GitHub Desktop.
Find all plugins of a specific type and attach fixedPostVars to them
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace My\Ext\Hooks; | |
use TYPO3\CMS\Backend\Utility\BackendUtility; | |
class RealUrlAutoconfHook { | |
/** | |
* @param array $params | |
* @param $pObj | |
* | |
* @return array | |
*/ | |
public function addRealUrlConfiguration($params, &$pObj) | |
{ | |
$params = array_merge_recursive( | |
$params['config'], | |
[ | |
'fixedPostVars' => [ | |
'findConfiguration' => [ | |
[ | |
'GETvar' => 'tx_find_find[mangled][country]', | |
'lookUpTable' => [ | |
'table' => 'static_countries', | |
'id_field' => 'uid', | |
'alias_field' => 'cn_short_de', | |
'useUniqueCache' => true, | |
'useUniqueCache_conf' => [ | |
'strtolower' => true, | |
'spaceCharacter' => '-', | |
], | |
'enable404forInvalidAlias' => true, | |
], | |
], | |
], | |
], | |
] | |
); | |
$params = $this->addFixedPostVarsForPlugins($params, $pObj); | |
return $params; | |
} | |
/** | |
* @param array $params | |
* @param $pObj | |
* | |
* @return array | |
*/ | |
protected function addFixedPostVarsForPlugins($params, &$pObj) | |
{ | |
$findPlugins = BackendUtility::getRecordsByField( | |
'tt_content', | |
'list_type', | |
'find_find', | |
'AND CType="list" ' | |
); | |
if ($findPlugins !== false) { | |
foreach ($findPlugins as $plugin) { | |
$params['fixedPostVars'][$plugin['pid']] = 'findConfiguration'; | |
} | |
} | |
return $params; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment