- Merge request !94Support bundle fields created in ContentEntityBase::bundleFieldDefinitions() → (Open) created by Unnamed author
When creating bundle fields via ContentEntityBase::bundleFieldDefinitions() it's not possible to encrypt them. I suspect the Field Encryption module assumes all bundle field have been created via the Field UI and have thus have the getThirdPartySetting() method.
1. Create a custom content entity.
2. Manually add the required Field Encryption basefield.
public static function baseFieldDefinitions(EntityTypeInterface $entity_type): array {
$fields = parent::baseFieldDefinitions($entity_type);
// Add field encryption storage field. Needed for the Field Encrypt module.
$fields[ProcessEntities::ENCRYPTED_FIELD_STORAGE_NAME] = StateManager::getEncryptedFieldStorageDefinition();
3. Create bundle field in ContentEntityBase::bundleFieldDefinitions() and set the
public static function bundleFieldDefinitions(EntityTypeInterface $entity_type, $bundle, array $base_field_definitions) {
$fields = parent::bundleFieldDefinitions($entity_type, $bundle, $base_field_definitions);
$fields['imap_password'] = BundleFieldDefinition::create('string')
->setName('imap_password')
->setTargetEntityTypeId($entity_type->id())
->setTargetBundle($bundle)
->setLabel(t('Password'))
->setRequired(TRUE)
// Make the field encrypted.
->setSetting('field_encrypt.encrypt', TRUE)
->setSetting('field_encrypt.properties', ['value']);
Create a patch that changes the loading of field settings.
-
-
-
-
Active
3.2
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.