layout-builder.php

Same filename in other branches
  1. 9 core/modules/layout_builder/tests/fixtures/update/layout-builder.php
  2. 8.9.x core/modules/layout_builder/tests/fixtures/update/layout-builder.php
  3. 11.x core/modules/layout_builder/tests/fixtures/update/layout-builder.php

Install layout_builder module before testing update paths.

File

core/modules/layout_builder/tests/fixtures/update/layout-builder.php

View source
<?php


/**
 * @file
 * Install layout_builder module before testing update paths.
 */
use Drupal\Core\Database\Database;
$connection = Database::getConnection();
// Update core.extension.
$extensions = $connection->select('config')
    ->fields('config', [
    'data',
])
    ->condition('collection', '')
    ->condition('name', 'core.extension')
    ->execute()
    ->fetchField();
$extensions = unserialize($extensions);
$extensions['module']['layout_builder'] = 0;
$extensions['module']['layout_discovery'] = 0;
$connection->update('config')
    ->fields([
    'data' => serialize($extensions),
])
    ->condition('collection', '')
    ->condition('name', 'core.extension')
    ->execute();
// Add all layout_builder_removed_post_updates() as existing updates.
require_once __DIR__ . '/../../../../layout_builder/layout_builder.post_update.php';
require_once __DIR__ . '/../../../../layout_discovery/layout_discovery.post_update.php';
$existing_updates = $connection->select('key_value')
    ->fields('key_value', [
    'value',
])
    ->condition('collection', 'post_update')
    ->condition('name', 'existing_updates')
    ->execute()
    ->fetchField();
$existing_updates = unserialize($existing_updates);
$existing_updates = array_merge($existing_updates, array_keys(layout_builder_removed_post_updates()), array_keys(layout_discovery_removed_post_updates()));
$connection->update('key_value')
    ->fields([
    'value' => serialize($existing_updates),
])
    ->condition('collection', 'post_update')
    ->condition('name', 'existing_updates')
    ->execute();

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