Skip to content

Commit

Permalink
only set path base field if entity type is enabled (#518)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackrabbithanna authored Jan 29, 2025
1 parent 811968b commit b87ad45
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/Entity/CivicrmEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -151,11 +151,15 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
}
$module_handler = \Drupal::getContainer()->get('module_handler');
if ($module_handler->moduleExists('path')) {
$fields['path'] = BaseFieldDefinition::create('path')
->setLabel(t('URL alias'))
->setDisplayOptions('form', ['type' => 'path', 'weight' => 30])
->setDisplayConfigurable('form', TRUE)
->setComputed(TRUE);
$config = \Drupal::config('civicrm_entity.settings');
$enabled_entity_types = $config->get('enabled_entity_types') ?: [];
if (in_array($entity_type->id(), $enabled_entity_types)) {
$fields['path'] = BaseFieldDefinition::create('path')
->setLabel(t('URL alias'))
->setDisplayOptions('form', ['type' => 'path', 'weight' => 30])
->setDisplayConfigurable('form', TRUE)
->setComputed(TRUE);
}
}
return $fields;
}
Expand Down

0 comments on commit b87ad45

Please sign in to comment.