function layout_builder_update_8601

Enable Layout Builder for existing entity displays.

File

core/modules/layout_builder/layout_builder.install, line 47

Code

function layout_builder_update_8601(&$sandbox) {
    $config_factory = \Drupal::configFactory();
    if (!isset($sandbox['count'])) {
        $sandbox['ids'] = $config_factory->listAll('core.entity_view_display.');
        $sandbox['count'] = count($sandbox['ids']);
    }
    $ids = array_splice($sandbox['ids'], 0, 50);
    foreach ($ids as $id) {
        $display = $config_factory->getEditable($id);
        if ($display->get('third_party_settings.layout_builder')) {
            $display->set('third_party_settings.layout_builder.enabled', TRUE)
                ->save();
        }
    }
    $sandbox['#finished'] = empty($sandbox['ids']) ? 1 : ($sandbox['count'] - count($sandbox['ids'])) / $sandbox['count'];
}

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