Skip to content
Snippets Groups Projects

Fixed the field entity ui issues

Files
2
@@ -7,6 +7,7 @@ use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Session\AccountProxyInterface;
use Drupal\Core\StringTranslation\TranslationInterface;
use Drupal\Core\Url;
use Drupal\field_ui\Hook\FieldUiHooks;
use Drupal\group\Entity\GroupInterface;
use Drupal\group\Entity\GroupTypeInterface;
use Drupal\group\Plugin\Group\Relation\GroupRelationTypeManagerInterface;
@@ -71,11 +72,19 @@ class OperationProvider implements OperationProviderInterface {
];
}
// This could be in its own decorator, but then it would live in a module
// of its own purely for field_ui support. So let's keep it here.
// Use a safer alternative to field_ui_entity_operation()
if ($this->moduleHandler->moduleExists('field_ui')) {
$relationship_type = $this->entityTypeManager()->getStorage('group_relationship_type')->load($relationship_type_id);
$operations += field_ui_entity_operation($relationship_type);
if ($relationship_type) {
// Try using the right method for adding the Field UI entity operations.
$operations += match (TRUE) {
// Drupal version >= 11.1.x.
method_exists(FieldUiHooks::class, 'entityOperation') => (new FieldUiHooks())->entityOperation($relationship_type),
// Drupal version < 11.1.x.
function_exists('field_ui_entity_operation') => field_ui_entity_operation($relationship_type),
default => [],
};
}
}
}
elseif ($ui_allowed) {
Loading