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