Skip to content

Commit b87ad45

Browse files
only set path base field if entity type is enabled (#518)
1 parent 811968b commit b87ad45

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/Entity/CivicrmEntity.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,11 +151,15 @@ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
151151
}
152152
$module_handler = \Drupal::getContainer()->get('module_handler');
153153
if ($module_handler->moduleExists('path')) {
154-
$fields['path'] = BaseFieldDefinition::create('path')
155-
->setLabel(t('URL alias'))
156-
->setDisplayOptions('form', ['type' => 'path', 'weight' => 30])
157-
->setDisplayConfigurable('form', TRUE)
158-
->setComputed(TRUE);
154+
$config = \Drupal::config('civicrm_entity.settings');
155+
$enabled_entity_types = $config->get('enabled_entity_types') ?: [];
156+
if (in_array($entity_type->id(), $enabled_entity_types)) {
157+
$fields['path'] = BaseFieldDefinition::create('path')
158+
->setLabel(t('URL alias'))
159+
->setDisplayOptions('form', ['type' => 'path', 'weight' => 30])
160+
->setDisplayConfigurable('form', TRUE)
161+
->setComputed(TRUE);
162+
}
159163
}
160164
return $fields;
161165
}

0 commit comments

Comments
 (0)