I might be missing smth., but as far as I can see there is no real option to add further filters for custom user fields:
I could
PHP:
$container['customFields.users'] = $this->fromRegistry('userFieldsInfo',
function(Container $c) { return $c['em']->getRepository('XF:UserField')->rebuildFieldCache(); },
function(array $userFieldsInfo)
{
$definitionSet = new DefinitionSet($userFieldsInfo);
$definitionSet->addFilter('registration', function(array $field)
{
return (!empty($field['show_registration']) || !empty($field['required']));
});
$definitionSet->addFilter('profile', function(array $field)
{
return !empty($field['viewable_profile']);
});
$definitionSet->addFilter('message', function(array $field)
{
return !empty($field['viewable_message']);
});
return $definitionSet;
}
);
I could
- Overwrite the whole thing which isn't a great option as it could conflict with other Add-ons
- Invoke the loading code on
app_pub_start
and add my filter afterwards which causes unconditional overhead and kinda defeats DI - Only add my filters where I know that I will need them, but this is also a bad option as I might not know all places that might access the filter and if it is not defined it will not be invoked at all