Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
WCMS
uw_migrate
Commits
2df8c03a
Commit
2df8c03a
authored
Jul 08, 2021
by
Chris Shantz
Browse files
Merge branch '1.0.x' into prod/1.0.x
parents
1f0b5183
c09f5ff1
Changes
20
Hide whitespace changes
Inline
Side-by-side
migrations/layout_builder/uw_body_lb.yml
View file @
2df8c03a
...
...
@@ -59,7 +59,6 @@ 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
...
...
migrations/layout_builder/uw_body_sections_lb.yml
View file @
2df8c03a
...
...
@@ -37,6 +37,7 @@ process:
message
:
'
Destination
node
was
not
found.'
layout
:
layout
layout_settings
:
layout_settings
section
:
delta
destination
:
plugin
:
layout_builder:section
migration_dependencies
:
...
...
migrations/layout_builder/uw_cbl_banner_images_lb.yml
View file @
2df8c03a
...
...
@@ -27,7 +27,7 @@ process:
default_value
:
0
region
:
plugin
:
default_value
default_value
:
'
conten
t'
default_value
:
'
firs
t'
delta
:
plugin
:
default_value
default_value
:
0
...
...
@@ -38,4 +38,5 @@ destination:
plugin
:
layout_builder:block
migration_dependencies
:
optional
:
-
uw_body_lb
-
uw_cbl_banner_images
migrations/node/uw_ct_blog.yml
View file @
2df8c03a
...
...
@@ -31,12 +31,23 @@ process:
migration
:
uw_mt_image
source
:
field_event_image/0/fid
no_stub
:
true
field_uw_blog_listing_page_image
:
plugin
:
migration_lookup
migration
:
uw_mt_image
source
:
field_event_image/0/fid
no_stub
:
true
field_author
:
field_author/0/title
field_uw_blog_summary/value
:
body/0/summary
field_uw_blog_summary/value
:
plugin
:
callback
callable
:
uw_migrate_summary
source
:
body
field_uw_blog_summary/format
:
plugin
:
uw_formats
source
:
body/0/format
field_uw_meta_description
:
body/0/summary
field_uw_meta_description
:
plugin
:
callback
callable
:
uw_migrate_summary
source
:
body
uid
:
-
plugin
:
migration_lookup
...
...
migrations/node/uw_ct_catalog_item.yml
View file @
2df8c03a
...
...
@@ -36,6 +36,11 @@ process:
migration
:
uw_taxonomy_term
source
:
field_catalog_audience
no_stub
:
true
field_uw_catalog_summary/value
:
field_catalog_summary/0/value
field_uw_catalog_summary/format
:
plugin
:
uw_formats
source
:
field_catalog_summary/0/format
field_uw_meta_description
:
field_catalog_summary/0/value
title
:
title
uid
:
-
...
...
migrations/node/uw_ct_contact.yml
View file @
2df8c03a
...
...
@@ -29,6 +29,11 @@ process:
field_uw_ct_contact_phone
:
field_contact_phone/0/value
field_uw_ct_contact_location
:
field_contact_location/0/value
field_uw_ct_contact_contact_for
:
field_contact_reason/0/value
field_uw_meta_image
:
plugin
:
migration_lookup
migration
:
uw_mt_image
source
:
field_contact_image/0/fid
no_stub
:
true
field_uw_ct_contact_image
:
plugin
:
migration_lookup
migration
:
uw_mt_image
...
...
@@ -43,6 +48,7 @@ process:
plugin
:
field_link
uri_scheme
:
https://
source
:
field_contact_website_url
field_uw_meta_description
:
field_contact_title/0/value
uid
:
-
plugin
:
migration_lookup
...
...
migrations/node/uw_ct_event.yml
View file @
2df8c03a
...
...
@@ -45,11 +45,22 @@ process:
migration
:
uw_mt_image
source
:
field_event_image/0/fid
no_stub
:
true
field_uw_event_summary/value
:
body/0/summary
field_uw_event_listing_page_img
:
plugin
:
migration_lookup
migration
:
uw_mt_image
source
:
field_event_image/0/fid
no_stub
:
true
field_uw_event_summary/value
:
plugin
:
callback
callable
:
uw_migrate_summary
source
:
body
field_uw_event_summary/format
:
plugin
:
uw_formats
source
:
body/0/format
field_uw_meta_description
:
body/0/summary
field_uw_meta_description
:
plugin
:
callback
callable
:
uw_migrate_summary
source
:
body
uid
:
-
plugin
:
migration_lookup
...
...
migrations/node/uw_ct_news_item.yml
View file @
2df8c03a
...
...
@@ -26,11 +26,22 @@ process:
migration
:
uw_mt_image
source
:
field_news_image/0/fid
no_stub
:
true
field_uw_news_summary/value
:
body/0/summary
field_uw_news_listing_page_image
:
plugin
:
migration_lookup
migration
:
uw_mt_image
source
:
field_news_image/0/fid
no_stub
:
true
field_uw_news_summary/value
:
plugin
:
callback
callable
:
uw_migrate_summary
source
:
body
field_uw_news_summary/format
:
plugin
:
uw_formats
source
:
body/0/format
field_uw_meta_description
:
body/0/summary
field_uw_meta_description
:
plugin
:
callback
callable
:
uw_migrate_summary
source
:
body
uid
:
-
plugin
:
migration_lookup
...
...
migrations/node/uw_ct_profile.yml
View file @
2df8c03a
...
...
@@ -19,6 +19,11 @@ process:
migration
:
uw_mt_image
source
:
field_profile_photo/0/fid
no_stub
:
true
field_uw_meta_image
:
plugin
:
migration_lookup
migration
:
uw_mt_image
source
:
field_profile_photo/0/fid
no_stub
:
true
field_uw_ct_profile_contact
:
plugin
:
migration_lookup
migration
:
uw_ct_contact
...
...
@@ -29,6 +34,17 @@ process:
migration
:
uw_taxonomy_term
source
:
field_profile_type
no_stub
:
true
field_uw_profile_summary/value
:
plugin
:
callback
callable
:
uw_migrate_summary
source
:
body
field_uw_profile_summary/format
:
plugin
:
uw_formats
source
:
body/0/format
field_uw_meta_description
:
plugin
:
callback
callable
:
uw_migrate_summary
source
:
body
uid
:
-
plugin
:
migration_lookup
...
...
migrations/node/uw_ct_sidebar.yml
View file @
2df8c03a
...
...
@@ -9,6 +9,7 @@ migration_tags:
source
:
plugin
:
uw_node
node_type
:
[
uw_web_page
,
uw_web_form
,
uw_catalog_item
,
uw_service
]
include_page_width
:
true
batch_size
:
200
process
:
sidebar_exists
:
...
...
@@ -18,6 +19,11 @@ process:
-
field_sidebar_content/0/value
-
field_related_link
message
:
'
Fields
field_sidebar_content
and
field_related_link
are
empty.'
wide_page_width
:
plugin
:
skip_on_value
source
:
wide_page_width
method
:
row
value
:
1
title
:
title
uid
:
-
...
...
@@ -33,6 +39,7 @@ process:
migration
:
-
uw_ct_web_page
source
:
nid
no_stub
:
true
langcode
:
plugin
:
default_value
source
:
language
...
...
migrations/node/uw_ct_web_page.yml
View file @
2df8c03a
...
...
@@ -27,7 +27,10 @@ process:
migration
:
uw_mt_image
source
:
field_event_image/0/fid
no_stub
:
true
field_uw_meta_description
:
body/0/summary
field_uw_meta_description
:
plugin
:
callback
callable
:
uw_migrate_summary
source
:
body
langcode
:
plugin
:
default_value
source
:
language
...
...
src/Plugin/migrate/destination/LayoutBuilderBlock.php
View file @
2df8c03a
...
...
@@ -151,6 +151,7 @@ class LayoutBuilderBlock extends DestinationBase implements ContainerFactoryPlug
$section
->
appendComponent
(
$component
);
}
$node
->
changed
->
preserve
=
TRUE
;
$node
->
save
();
return
[
$node
->
id
(),
$uuid
];
}
...
...
src/Plugin/migrate/destination/LayoutBuilderSection.php
View file @
2df8c03a
...
...
@@ -86,10 +86,17 @@ class LayoutBuilderSection extends DestinationBase implements ContainerFactoryPl
$layout
=
$node
->
get
(
'layout_builder__layout'
);
$section
=
new
Section
(
$row
->
getDestinationProperty
(
'layout'
),
$row
->
getDestinationProperty
(
'layout_settings'
));
$layout
->
appendSection
(
$section
);
$node
->
save
();
$delta
=
$row
->
getDestinationProperty
(
'section'
);
if
(
isset
(
$delta
))
{
$layout
->
insertSection
(
$delta
,
$section
);
}
else
{
$layout
->
appendSection
(
$section
);
$delta
=
$layout
->
count
()
-
1
;
}
$delta
=
$layout
->
count
()
-
1
;
$node
->
changed
->
preserve
=
TRUE
;
$node
->
save
();
return
[
$node
->
id
(),
$delta
];
}
...
...
src/Plugin/migrate/process/UwSmartDate.php
View file @
2df8c03a
...
...
@@ -66,6 +66,13 @@ class UwSmartDate extends ProcessPluginBase {
'repeat-advanced'
=>
$rule
->
getParametersArray
(),
];
// Duplicate interval value as parent array key because this is where
// smart_date expects it to be since:
// https://www.drupal.org/project/smart_date/issues/3176366
if
(
isset
(
$new_item
[
'repeat-advanced'
][
'interval'
]))
{
$new_item
[
'interval'
]
=
$new_item
[
'repeat-advanced'
][
'interval'
];
}
if
(
!
empty
(
$rule_values
[
'limit'
]))
{
[
$limit_type
,
$limit_value
]
=
explode
(
'='
,
$rule_values
[
'limit'
]);
$new_item
[
'repeat-end'
]
=
$limit_type
;
...
...
src/Plugin/migrate/source/UwNode.php
View file @
2df8c03a
...
...
@@ -2,6 +2,7 @@
namespace
Drupal\uw_migrate\Plugin\migrate\source
;
use
Drupal\migrate\Row
;
use
Drupal\node\Plugin\migrate\source\d7\Node
;
/**
...
...
@@ -24,4 +25,32 @@ class UwNode extends Node {
return
$query
;
}
/**
* {@inheritdoc}
*/
public
function
prepareRow
(
Row
$row
)
{
if
(
$this
->
configuration
[
'include_page_width'
])
{
$nid
=
$row
->
getSourceProperty
(
'nid'
);
$row
->
setSourceProperty
(
'wide_page_width'
,
$this
->
getPageSettings
(
$nid
));
}
return
parent
::
prepareRow
(
$row
);
}
/**
* Loads node page settings from "uw_page_settings_node" table.
*
* @param $nid
* Node ID.
*/
protected
function
getPageSettings
(
$nid
)
{
$result
=
$this
->
select
(
'uw_page_settings_node'
,
'ps'
)
->
fields
(
'ps'
)
->
condition
(
'nid'
,
$nid
)
->
orderBy
(
'ps.vid'
,
'DESC'
)
->
range
(
0
,
1
)
->
execute
()
->
fetchField
(
2
);
return
isset
(
$result
)
?
(
int
)
$result
:
0
;
}
}
src/Plugin/migrate/source/UwWebform.php
View file @
2df8c03a
...
...
@@ -428,6 +428,22 @@ class UwWebform extends D7Webform {
}
}
// Attach captcha if it was enabled on the source form.
if
(
$this
->
moduleExists
(
'captcha'
))
{
$form_id
=
"webform_client_form_
{
$nid
}
"
;
$captcha_type
=
$this
->
select
(
'captcha_points'
,
'cp'
)
->
fields
(
'cp'
,
[
'captcha_type'
])
->
condition
(
'cp.form_id'
,
$form_id
)
->
execute
()
->
fetchField
();
if
(
$captcha_type
===
'default'
)
{
$build
[
'captcha'
]
=
[
'#type'
=>
'captcha'
,
];
}
}
$output
=
WebformYaml
::
encode
(
$build
);
return
[
'elements'
=>
$output
,
'xref'
=>
$xref
];
}
...
...
src/UwContentParser.php
View file @
2df8c03a
...
...
@@ -248,6 +248,11 @@ class UwContentParser {
// For Facebook, add either url or page as ref_id property.
if
(
$properties
[
'html_tag'
]
===
'ckfacebook'
)
{
$properties
[
'ref_id'
]
=
$properties
[
'fb_url'
]
??
$properties
[
'fb_page'
];
// Make sure widget type is not empty.
if
(
empty
(
$properties
[
'fb_feed_type'
]))
{
$properties
[
'fb_feed_type'
]
=
empty
(
$properties
[
'fb_url'
])
?
'timeline'
:
'singlepost'
;
}
}
elseif
(
$properties
[
'html_tag'
]
===
'cktwitter'
)
{
$properties
[
'tweet'
]
=
$properties
[
'tweet'
]
??
''
;
...
...
@@ -284,7 +289,17 @@ class UwContentParser {
protected
function
clean
(
$content
)
{
// Remove special characters.
$content
=
preg_replace
(
"/&#?[a-z0-9]
{
2,8
}
;/i"
,
''
,
$content
);
return
trim
(
strip_tags
(
$content
,
'<a><img><iframe>'
));
$allowed_tags
=
array_merge
([
'a'
,
'img'
,
'iframe'
],
array_keys
(
$this
->
getTagsMapping
()));
// Allow embedding tags.
$allowed_tags_list
=
array_map
(
function
(
$item
)
{
return
"<
$item
>"
;
},
$allowed_tags
);
return
trim
(
strip_tags
(
$content
,
implode
(
''
,
$allowed_tags_list
)));
}
/**
...
...
tests/src/Kernel/process/UwSmartDateTest.php
View file @
2df8c03a
...
...
@@ -140,6 +140,7 @@ class UwSmartDateTest extends KernelTestBase {
'byhour'
=>
[],
'byminute'
=>
[],
],
'interval'
=>
1
,
'repeat-end'
=>
'COUNT'
,
'repeat-end-count'
=>
'2'
,
'repeat-end-date'
=>
''
,
...
...
@@ -161,6 +162,7 @@ class UwSmartDateTest extends KernelTestBase {
'byhour'
=>
[],
'byminute'
=>
[],
],
'interval'
=>
1
,
'repeat-end'
=>
'COUNT'
,
'repeat-end-count'
=>
'2'
,
'repeat-end-date'
=>
''
,
...
...
@@ -196,6 +198,7 @@ RDATE:20120320T040000Z,20120417T040000Z,20120524T040000Z,20120621T040000Z',
'byhour'
=>
[],
'byminute'
=>
[],
],
'interval'
=>
4
,
'repeat-end'
=>
'UNTIL'
,
'repeat-end-count'
=>
''
,
'repeat-end-date'
=>
'20120622T035959Z'
,
...
...
@@ -217,6 +220,7 @@ RDATE:20120320T040000Z,20120417T040000Z,20120524T040000Z,20120621T040000Z',
'byhour'
=>
[],
'byminute'
=>
[],
],
'interval'
=>
4
,
'repeat-end'
=>
'UNTIL'
,
'repeat-end-count'
=>
''
,
'repeat-end-date'
=>
'20120622T035959Z'
,
...
...
@@ -238,6 +242,7 @@ RDATE:20120320T040000Z,20120417T040000Z,20120524T040000Z,20120621T040000Z',
'byhour'
=>
[],
'byminute'
=>
[],
],
'interval'
=>
4
,
'repeat-end'
=>
'UNTIL'
,
'repeat-end-count'
=>
''
,
'repeat-end-date'
=>
'20120622T035959Z'
,
...
...
@@ -259,6 +264,7 @@ RDATE:20120320T040000Z,20120417T040000Z,20120524T040000Z,20120621T040000Z',
'byhour'
=>
[],
'byminute'
=>
[],
],
'interval'
=>
4
,
'repeat-end'
=>
'UNTIL'
,
'repeat-end-count'
=>
''
,
'repeat-end-date'
=>
'20120622T035959Z'
,
...
...
uw_migrate.info.yml
View file @
2df8c03a
...
...
@@ -4,6 +4,7 @@ type: module
core_version_requirement
:
^8 || ^9
dependencies
:
-
drupal:migrate_drupal
-
drupal:views
-
migrate_plus:migrate_plus
-
migrate_scanner:migrate_scanner
-
migrate_tools:migrate_tools
...
...
uw_migrate.module
View file @
2df8c03a
...
...
@@ -5,11 +5,13 @@
* UW migrate module.
*/
use
Drupal\
migrate\Plugin\migrate\destination\EntityContentBase
;
use
Drupal\
Component\Utility\Html
;
use
Drupal\migrate\Plugin\MigrateSourceInterface
;
use
Drupal\migrate\Plugin\MigrationInterface
;
use
Drupal\migrate\Plugin\migrate\destination\EntityContentBase
;
use
Drupal\migrate\Row
;
use
Drupal\uw_migrate
\
Plugin\migrate\destination\UwEntityContentBase
;
use
Drupal\views\Plugin\views\field\FieldPluginBase
;
/**
* Implements hook_migrate_destination_info_plugins_alter().
...
...
@@ -147,3 +149,18 @@ function uw_migrate_empty($value) {
function
uw_migrate_get_component_delta
(
array
$value
)
{
return
$value
[
0
]
?
$value
[
1
]
:
NULL
;
}
/**
* Strips HTML tags and trims "Body" text to ~150 characters.
*/
function
uw_migrate_summary
(
$value
)
{
$summary
=
$value
[
'summary'
]
??
''
;
if
(
empty
(
$summary
))
{
$summary
=
FieldPluginBase
::
trimText
([
'max_length'
=>
150
,
'word_boundary'
=>
TRUE
,
'ellipsis'
=>
TRUE
,
],
Html
::
decodeEntities
(
trim
(
strip_tags
(
$value
[
'value'
]))));
}
return
$summary
;
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment