Chris@14: getThirdPartySettings('field_layout'); Chris@14: if (isset($field_layout['id'])) { Chris@14: $field_layout += ['settings' => []]; Chris@17: $display Chris@17: ->enableLayoutBuilder() Chris@17: ->appendSection(new Section($field_layout['id'], $field_layout['settings'])) Chris@17: ->save(); Chris@17: $display_changed = TRUE; Chris@14: } Chris@14: } Chris@14: Chris@14: // Clear the rendered cache to ensure the new layout builder flow is used. Chris@14: // While in many cases the above change will not affect the rendered output, Chris@14: // the cacheability metadata will have changed and should be processed to Chris@14: // prepare for future changes. Chris@17: if ($display_changed) { Chris@17: Cache::invalidateTags(['rendered']); Chris@17: } Chris@14: } Chris@17: Chris@17: /** Chris@17: * Enable Layout Builder for existing entity displays. Chris@17: */ Chris@17: function layout_builder_update_8601(&$sandbox) { Chris@17: $config_factory = \Drupal::configFactory(); Chris@17: Chris@17: if (!isset($sandbox['count'])) { Chris@17: $sandbox['ids'] = $config_factory->listAll('core.entity_view_display.'); Chris@17: $sandbox['count'] = count($sandbox['ids']); Chris@17: } Chris@17: Chris@17: $ids = array_splice($sandbox['ids'], 0, 50); Chris@17: foreach ($ids as $id) { Chris@17: $display = $config_factory->getEditable($id); Chris@17: if ($display->get('third_party_settings.layout_builder')) { Chris@17: $display Chris@17: ->set('third_party_settings.layout_builder.enabled', TRUE) Chris@17: ->save(); Chris@17: } Chris@17: } Chris@17: Chris@17: $sandbox['#finished'] = empty($sandbox['ids']) ? 1 : ($sandbox['count'] - count($sandbox['ids'])) / $sandbox['count']; Chris@17: } Chris@17: Chris@17: /** Chris@17: * Implements hook_schema(). Chris@17: */ Chris@17: function layout_builder_schema() { Chris@17: $schema['inline_block_usage'] = [ Chris@17: 'description' => 'Track where a block_content entity is used.', Chris@17: 'fields' => [ Chris@17: 'block_content_id' => [ Chris@17: 'description' => 'The block_content entity ID.', Chris@17: 'type' => 'int', Chris@17: 'unsigned' => TRUE, Chris@17: 'not null' => TRUE, Chris@17: ], Chris@17: 'layout_entity_type' => [ Chris@17: 'description' => 'The entity type of the parent entity.', Chris@17: 'type' => 'varchar_ascii', Chris@17: 'length' => EntityTypeInterface::ID_MAX_LENGTH, Chris@17: 'not null' => FALSE, Chris@17: 'default' => '', Chris@17: ], Chris@17: 'layout_entity_id' => [ Chris@17: 'description' => 'The ID of the parent entity.', Chris@17: 'type' => 'varchar_ascii', Chris@17: 'length' => 128, Chris@17: 'not null' => FALSE, Chris@17: 'default' => 0, Chris@17: ], Chris@17: ], Chris@17: 'primary key' => ['block_content_id'], Chris@17: 'indexes' => [ Chris@17: 'type_id' => ['layout_entity_type', 'layout_entity_id'], Chris@17: ], Chris@17: ]; Chris@17: return $schema; Chris@17: } Chris@17: Chris@17: /** Chris@17: * Create the 'inline_block_usage' table. Chris@17: */ Chris@17: function layout_builder_update_8602() { Chris@17: $inline_block_usage = [ Chris@17: 'description' => 'Track where a block_content entity is used.', Chris@17: 'fields' => [ Chris@17: 'block_content_id' => [ Chris@17: 'description' => 'The block_content entity ID.', Chris@17: 'type' => 'int', Chris@17: 'unsigned' => TRUE, Chris@17: 'not null' => TRUE, Chris@17: ], Chris@17: 'layout_entity_type' => [ Chris@17: 'description' => 'The entity type of the parent entity.', Chris@17: 'type' => 'varchar_ascii', Chris@17: 'length' => EntityTypeInterface::ID_MAX_LENGTH, Chris@17: 'not null' => FALSE, Chris@17: 'default' => '', Chris@17: ], Chris@17: 'layout_entity_id' => [ Chris@17: 'description' => 'The ID of the parent entity.', Chris@17: 'type' => 'varchar_ascii', Chris@17: 'length' => 128, Chris@17: 'not null' => FALSE, Chris@17: 'default' => 0, Chris@17: ], Chris@17: ], Chris@17: 'primary key' => ['block_content_id'], Chris@17: 'indexes' => [ Chris@17: 'type_id' => ['layout_entity_type', 'layout_entity_id'], Chris@17: ], Chris@17: ]; Chris@17: Database::getConnection()->schema()->createTable('inline_block_usage', $inline_block_usage); Chris@17: }