function field_layout_install

Same name in other branches
  1. 9 core/modules/field_layout/field_layout.install \field_layout_install()
  2. 8.9.x core/modules/field_layout/field_layout.install \field_layout_install()
  3. 11.x core/modules/field_layout/field_layout.install \field_layout_install()

Implements hook_install().

File

core/modules/field_layout/field_layout.install, line 17

Code

function field_layout_install() {
    // Ensure each entity display has a layout.
    $entity_save = function (EntityDisplayInterface $entity) {
        if ($entity instanceof EntityDisplayWithLayoutInterface) {
            $entity->ensureLayout()
                ->save();
        }
    };
    array_map($entity_save, EntityViewDisplay::loadMultiple());
    array_map($entity_save, EntityFormDisplay::loadMultiple());
    // Invalidate the render cache since all content will now have a layout.
    Cache::invalidateTags([
        'rendered',
    ]);
}

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