Commit bfdf9830 authored by Chris Shantz's avatar Chris Shantz
Browse files

Merge branch '1.0.x' into 'prod/1.0.x'

1.0.x

See merge request !34
parents 6a253804 5931722c
id: uw_cbl_banner_images
label: 'Homepage banner images'
migration_group: uw
audit: true
migration_tags:
- Drupal 7
- Content
- Block
source:
plugin: uw_node_single_row
node_type: uw_home_page_banner
process:
info:
plugin: default_value
default_value: 'Homepage Banners'
pseudo_field_uw_banner_item:
plugin: sub_process
source: items
process:
paragraph:
- plugin: migration_lookup
migration: uw_para_image_banner
source: nid
no_stub: true
- plugin: skip_on_empty
method: process
field_uw_banner_item:
plugin: sub_process
source: '@pseudo_field_uw_banner_item'
process:
target_id: paragraph/0
target_revision_id: paragraph/1
destination:
plugin: entity:block_content
default_bundle: uw_cbl_banner_images
migration_dependencies:
optional:
- uw_para_image_banner
......@@ -59,6 +59,7 @@ migration_dependencies:
- uw_ct_event
- uw_ct_profile
- uw_body_sections_lb
- uw_cbl_banner_images_lb
# Embedded blocks.
- uw_cbl_copy_text
- uw_cbl_remote_video
......
id: uw_cbl_banner_images_lb
label: Banner images block to homepage layout builder
migration_group: uw
migration_tags:
- Drupal 7
- Content
- Layout Builder
source:
plugin: uw_node_single_row
node_type: uw_home_page_banner
constants:
# Homepage nid is always 1.
homepage_nid: 1
# Source for the block is always 1.
block_source_id: 1
process:
nid: constants/homepage_nid
bid:
- plugin: migration_lookup
migration: uw_cbl_banner_images
source: constants/block_source_id
no_stub: true
- plugin: skip_on_empty
method: row
section:
plugin: default_value
default_value: 1
region:
plugin: default_value
default_value: 'content'
delta:
plugin: default_value
default_value: 0
default_layout:
plugin: default_value
default_value: 'layout_onecol'
destination:
plugin: layout_builder:block
migration_dependencies:
optional:
- uw_cbl_banner_images
......@@ -48,5 +48,6 @@ destination:
default_bundle: uw_mt_file
migration_dependencies:
required:
- uw_file
- uw_user
optional:
- uw_file
......@@ -49,5 +49,6 @@ destination:
default_bundle: uw_mt_icon
migration_dependencies:
required:
- uw_file
- uw_user
optional:
- uw_file
......@@ -16,6 +16,7 @@ source:
- field_news_image
- field_image_photo
- field_event_image
- field_banner_image
- field_contact_image
- field_profile_photo
- field_uw_image_gallery_images
......@@ -55,5 +56,6 @@ destination:
default_bundle: uw_mt_image
migration_dependencies:
required:
- uw_file
- uw_user
optional:
- uw_file
......@@ -7,10 +7,11 @@ migration_tags:
- Content
- Node
source:
plugin: d7_node
plugin: uw_web_page
node_type: [uw_web_page, uw_web_form, uw_image_gallery]
batch_size: 200
process:
nid: front_nid
title: title
uid:
-
......
id: uw_para_image_banner
label: 'Image banner paragraphs'
migration_tags:
- Drupal 7
- Content
- Paragraph
migration_group: uw
source:
plugin: d7_node
node_type: uw_home_page_banner
process:
status:
plugin: skip_on_value
source: status
method: row
value: 0
field_uw_ban_image:
plugin: migration_lookup
migration: uw_mt_image
source: field_banner_image/0/fid
no_stub: true
field_uw_ban_link:
plugin: field_link
uri_scheme: https://
source: field_link
field_uw_ban_big_text: field_link/0/title
field_uw_ban_small_text: field_caption/0/value
destination:
plugin: entity_reference_revisions:paragraph
default_bundle: uw_para_image_banner
migration_dependencies:
optional:
- uw_mt_image
id: uw_menu_links
label: Menu links
migration_group: uw
migration_tags:
- Drupal 7
- Content
source:
plugin: uw_menu_link
menu_name:
- menu-audience-menu
- main-menu
constants:
bundle: menu_link_content
process:
bundle: 'constants/bundle'
title: link_title
description: description
menu_name:
plugin: static_map
source: menu_name
map:
menu-audience-menu: uw-menu-audience-menu
main-menu: main
'link/uri':
- plugin: uw_migration_lookup_path
source: link_path
- plugin: link_uri
'link/options': options
route:
plugin: route
source:
- link_path
- options
route_name: '@route/route_name'
route_parameters: '@route/route_parameters'
url: '@route/url'
options: '@route/options'
external: external
weight: weight
expanded: expanded
enabled: enabled
parent:
plugin: menu_link_parent
source:
- plid
- '@menu_name'
- parent_link_path
changed: updated
destination:
plugin: entity:menu_link_content
no_stub: true
migration_dependencies:
optional:
- uw_ct_blog
- uw_ct_catalog_item
- uw_ct_contact
- uw_ct_event
- uw_ct_news_item
- uw_ct_profile
- uw_ct_web_page
......@@ -112,9 +112,14 @@ class LayoutBuilderBlock extends DestinationBase implements ContainerFactoryPlug
// Append a component to given section/region of page layout.
$dest_section = $row->getDestinationProperty('section');
if (!empty($dest_section)) {
if (isset($dest_section)) {
// First value is entity ID, the second is section delta.
[, $section_delta] = $dest_section;
if (is_array($dest_section)) {
[, $section_delta] = $dest_section;
}
else {
$section_delta = $dest_section;
}
$section = $node->get('layout_builder__layout')->getSection($section_delta);
}
else {
......
......@@ -22,6 +22,8 @@ class UwMigrationLookupPath extends MigrationLookup {
* {@inheritdoc}
*/
public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
$value = (array) $value;
// Check if the url begins with http(s).
if (preg_match('#^http#', $value[0])) {
// Use it as is.
......
<?php
namespace Drupal\uw_migrate\Plugin\migrate\source;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\State\StateInterface;
use Drupal\migrate\Plugin\MigrationInterface;
use Drupal\menu_link_content\Plugin\migrate\source\MenuLink;
use Drupal\migrate\Row;
/**
* Drupal menu link source from database with filter by menu name.
*
* Available configuration key:
* - menu_name: (optional) One or more source menu machine names.
*
* Example:
*
* @code
* source:
* plugin: uw_menu_link
* menu_name:
* - main-menu
* - service-menu
* @endcode
*
* In this example, only menu links from the menus machine-named "main-menu" and
* "service-menu" will be migrated.
*
* @MigrateSource(
* id = "uw_menu_link",
* source_module = "menu"
* )
*
*/
class UmMenuLink extends MenuLink {
/**
* List of source menu names to migrate.
*
* @var array
*/
protected $menuNames = [];
/**
* {@inheritdoc}
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, StateInterface $state, EntityTypeManagerInterface $entity_type_manager) {
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $state, $entity_type_manager);
// Ensure that menu_names is an array.
$this->menuNames = (array) $configuration['menu_name'];
}
/**
* {@inheritdoc}
*/
public function query() {
$query = parent::query();
// If menu names were provided, modify the query with an IN clause.
if (!empty($this->menuNames)) {
$query->condition('ml.menu_name', $this->menuNames, 'IN');
}
return $query;
}
/**
* {@inheritdoc}
*/
public function prepareRow(Row $row) {
// Skip menu links from main, that are not pointing to node pages.
if ($row->getSourceProperty('menu_name') === 'main-menu' && $row->getSourceProperty('router_path') !== 'node/%') {
return FALSE;
}
return parent::prepareRow($row);
}
}
......@@ -26,7 +26,7 @@ class UwBlockquote extends UwContentComplete {
// The iterator should already contain only blockquote items.
// We just need to add quote and attribution values here.
foreach ($new_rows as $delta => &$row) {
foreach ($new_rows as &$row) {
$block_quote = $this->parser->getBlockquotes($row[$content_col]);
if (empty($block_quote)) {
continue;
......
<?php
namespace Drupal\uw_migrate\Plugin\migrate\source;
use Drupal\node\Plugin\migrate\source\d7\Node;
/**
* Source plugin for homepage banners to combine multiple nodes into 1 row.
*
* @MigrateSource(
* id = "uw_node_single_row",
* source_module = "node"
* )
*/
class UwNodeSingleRow extends Node {
/**
* {@inheritdoc}
*/
protected function initializeIterator() {
$single_row = [
[
'nid' => 1,
'items' => iterator_to_array(parent::initializeIterator()),
]
];
return new \ArrayIterator($single_row);
}
/**
* {@inheritdoc}
*/
public function count($refresh = FALSE) {
return $this->initializeIterator()->count();
}
}
<?php
namespace Drupal\uw_migrate\Plugin\migrate\source;
use Drupal\migrate\Row;
use Drupal\node\Plugin\migrate\source\d7\Node;
/**
* Assigns D7 front page node to the existing homepage.
*
* @MigrateSource(
* id = "uw_web_page",
* source_module = "system"
* )
*/
class UwWebPageNode extends Node {
/**
* Front page node id.
*
* @var string
*/
protected $frontPage;
/**
* {@inheritdoc}
*/
protected function initializeIterator() {
$front_page_path = $this->variableGet('site_frontpage', '');
if (preg_match('@node/(\d+)$@', $front_page_path, $matches)) {
$this->frontPage = end($matches);
}
return parent::initializeIterator();
}
/**
* {@inheritdoc}
*/
public function prepareRow(Row $row) {
// D8 version creates default Homepage in uw_ct_web_page_install().
// To avoid duplicate, we assign existing D7 frontpage to a new D8 page.
if ($this->frontPage == $row->getSourceProperty('nid')) {
$row->setSourceProperty('front_nid', 1);
}
return parent::prepareRow($row);
}
}
......@@ -117,7 +117,7 @@ class UwMigrateTest extends MigrateDrupal7TestBase {
}
// Check the amount of custom migrations.
$this->assertCount(70, $definitions);
$this->assertCount(74, $definitions);
// Check some random migrations.
$this->assertArrayHasKey('uw_user', $definitions);
......
......@@ -5,6 +5,7 @@ core_version_requirement: ^8 || ^9
dependencies:
- drupal:migrate_drupal
- migrate_plus:migrate_plus
- migrate_scanner:migrate_scanner
- migrate_tools:migrate_tools
- preserve_changed:preserve_changed
- paragraphs:paragraphs
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment