Skip to content

Commit

Permalink
Support for basefield overrides (#496)
Browse files Browse the repository at this point in the history
* Override bundle when base_field_override_ui exists.

* Let basefield overrides handle field definitions.

---------

Co-authored-by: Arnold French <[email protected]>
  • Loading branch information
puresyntax71 and Arnold French authored Aug 9, 2024
1 parent ccc3d74 commit 2bfacc1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion civicrm_entity.module
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ function civicrm_entity_entity_bundle_field_info(EntityTypeInterface $entity_typ
// Ensure all fields have a definition.
if ($entity_type->get('civicrm_entity_ui_exposed') && $entity_type->hasKey('bundle')) {
foreach ($base_field_definitions as $field_name => $definition) {
if (isset($result[$field_name])) {
if (isset($result[$field_name]) || isset($definition)) {
continue;
}
$field = BaseFieldOverride::createFromBaseFieldDefinition($base_field_definitions[$field_name], $bundle);
Expand Down
18 changes: 18 additions & 0 deletions src/Routing/RouteSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,24 @@ protected function alterRoutes(RouteCollection $collection) {
];
}

if ($this->moduleHandler->moduleExists('base_field_override_ui')) {
$field_ui_routes["entity.base_field_override.{$entity_type_id}_base_field_override_add_form"] = [
'bundle' => $entity_type_id,
];

$field_ui_routes["entity.base_field_override.{$entity_type_id}_base_field_override_add_form"] = [
'bundle' => $entity_type_id,
];

$field_ui_routes["entity.base_field_override.{$entity_type_id}_base_field_override_edit_form"] = [
'bundle' => $entity_type_id,
];

$field_ui_routes["entity.base_field_override.{$entity_type_id}.base_field_override_ui_fields"] = [
'bundle' => $entity_type_id,
];
}

foreach ($field_ui_routes as $route_name => $defaults) {
$route = $collection->get($route_name);

Expand Down

0 comments on commit 2bfacc1

Please sign in to comment.