From 6fd2544b9d16fde417e72a9047c1cdb64321d431 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jer=C3=B4me=20Bakker?= Date: Tue, 23 May 2023 13:31:21 +0200 Subject: [PATCH] chore: correctly register profile manager group field type --- classes/ColdTrick/GroupTools/Bootstrap.php | 13 ------- .../GroupTools/Plugins/ProfileManager.php | 34 +++++++++++++++++++ elgg-plugin.php | 5 +++ 3 files changed, 39 insertions(+), 13 deletions(-) create mode 100644 classes/ColdTrick/GroupTools/Plugins/ProfileManager.php diff --git a/classes/ColdTrick/GroupTools/Bootstrap.php b/classes/ColdTrick/GroupTools/Bootstrap.php index 087613a..591bc79 100644 --- a/classes/ColdTrick/GroupTools/Bootstrap.php +++ b/classes/ColdTrick/GroupTools/Bootstrap.php @@ -17,17 +17,4 @@ public function load() { $events->registerHandler('route:config', 'account:register', __NAMESPACE__ . '\Router\GroupInviteRegistrationGatekeeper::register'); $events->registerHandler('route:config', 'action:register', __NAMESPACE__ . '\Router\GroupInviteRegistrationGatekeeper::register'); } - - /** - * {@inheritdoc} - */ - public function init() { - if (is_callable('profile_manager_add_custom_field_type')) { - profile_manager_add_custom_field_type('custom_group_field_types', 'group_tools_preset', elgg_echo('group_tools:profile:field:group_tools_preset'), [ - 'user_editable' => true, - 'output_as_tags' => true, - 'admin_only' => true, - ]); - } - } } diff --git a/classes/ColdTrick/GroupTools/Plugins/ProfileManager.php b/classes/ColdTrick/GroupTools/Plugins/ProfileManager.php new file mode 100644 index 0000000..945e5ee --- /dev/null +++ b/classes/ColdTrick/GroupTools/Plugins/ProfileManager.php @@ -0,0 +1,34 @@ +getValue(); + + $result[] = FieldType::factory([ + 'type' => 'group_tools_preset', + 'name' => elgg_echo('group_tools:profile:field:group_tools_preset'), + 'options' => [ + 'user_editable' => true, + 'output_as_tags' => true, + 'admin_only' => true, + ], + ]); + + return $result; + } +} diff --git a/elgg-plugin.php b/elgg-plugin.php index d398002..09fb867 100644 --- a/elgg-plugin.php +++ b/elgg-plugin.php @@ -259,6 +259,11 @@ '\ColdTrick\GroupTools\Plugins\Groups::registerGroupTools' => [], ], ], + 'types:custom_group_field' => [ + 'profile_manager' => [ + '\ColdTrick\GroupTools\Plugins\ProfileManager::registerGroupFields' => [], + ], + ], 'validate:after' => [ 'user' => [ '\ColdTrick\GroupTools\Membership::createUserEmailInvitedGroups' => [],