function block_content_entity_type_alter

Same name and namespace in other branches
  1. 9 core/modules/block_content/block_content.module \block_content_entity_type_alter()
  2. 8.9.x core/modules/block_content/block_content.module \block_content_entity_type_alter()
  3. 10 core/modules/block_content/block_content.module \block_content_entity_type_alter()

Implements hook_entity_type_alter().

File

core/modules/block_content/block_content.module, line 55

Code

function block_content_entity_type_alter(array &$entity_types) {
    
    /** @var \Drupal\Core\Entity\EntityTypeInterface[] $entity_types */
    // Add a translation handler for fields if the language module is enabled.
    if (\Drupal::moduleHandler()->moduleExists('language')) {
        $translation = $entity_types['block_content']->get('translation');
        $translation['block_content'] = TRUE;
        $entity_types['block_content']->set('translation', $translation);
    }
    // Swap out the default EntityChanged constraint with a custom one with
    // different logic for inline blocks.
    $constraints = $entity_types['block_content']->getConstraints();
    unset($constraints['EntityChanged']);
    $constraints['BlockContentEntityChanged'] = NULL;
    $entity_types['block_content']->setConstraints($constraints);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.