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
786d306f
Commit
786d306f
authored
Sep 09, 2021
by
Chris Shantz
Browse files
Merge branch '1.0.x' into prod/1.0.x
parents
d6d64db8
0927ab6f
Changes
5
Hide whitespace changes
Inline
Side-by-side
migrations/uw_path_redirect.yml
View file @
786d306f
...
...
@@ -20,19 +20,21 @@ process:
plugin
:
d7_redirect_source_query
source
:
source_options
redirect_redirect/uri
:
plugin
:
uw_migration_lookup_path
source
:
-
redirect
-
redirect_options
migration
:
-
uw_ct_blog
-
uw_ct_catalog_item
-
uw_ct_contact
-
uw_ct_event
-
uw_ct_news_item
-
uw_ct_profile
-
uw_ct_web_page
no_stub
:
true
-
plugin
:
uw_migration_lookup_path
source
:
-
redirect
-
redirect_options
migration
:
-
uw_ct_blog
-
uw_ct_catalog_item
-
uw_ct_contact
-
uw_ct_event
-
uw_ct_news_item
-
uw_ct_profile
-
uw_ct_web_page
-
plugin
:
extract
index
:
-
0
language
:
plugin
:
default_value
source
:
language
...
...
migrations/uw_user.yml
View file @
786d306f
...
...
@@ -10,6 +10,8 @@ source:
plugin
:
d7_user
batch_size
:
200
process
:
field_uw_first_name
:
field_first_name
field_uw_last_name
:
field_last_name
roles
:
plugin
:
static_map
source
:
roles
...
...
src/Plugin/migrate/process/UwDomInlineImageHandler.php
View file @
786d306f
...
...
@@ -115,15 +115,45 @@ class UwDomInlineImageHandler extends DomProcessBase implements ContainerFactory
if
(
$image
instanceof
MediaInterface
)
{
// Create a new DOM element for the image in the text.
$new_node
=
$this
->
document
->
createElement
(
'drupal-media'
,
''
);
$image_classes
=
explode
(
' '
,
$html_node
->
getAttribute
(
'class'
));
// Initial media attributes.
$attributes
=
[
'data-entity-uuid'
=>
$image
->
uuid
(),
'data-entity-type'
=>
'media'
,
'alt'
=>
$html_node
->
getAttribute
(
'alt'
),
'data-width'
=>
$html_node
->
getAttribute
(
'width'
),
'data-height'
=>
$html_node
->
getAttribute
(
'height'
),
'data-align'
=>
'center'
,
];
// Determine and set image align and width settings based on the
// available CSS classes in source <img> tag.
$classes_to_attributes
=
[
'data-width'
=>
[
'image-sidebar-220px-wide'
=>
'220'
,
'image-body-500px-wide'
=>
'500'
,
'image-wide-body-750px-wide'
=>
'750'
,
],
'data-align'
=>
[
'image-left'
=>
'left'
,
'image-right'
=>
'right'
,
'image-center'
=>
'center'
,
],
];
foreach
(
$classes_to_attributes
as
$media_attribute
=>
$class_mapping
)
{
$intersect
=
array_intersect
(
$image_classes
,
array_keys
(
$class_mapping
));
foreach
(
$intersect
as
$image_class
)
{
$attributes
[
$media_attribute
]
=
$class_mapping
[
$image_class
];
}
}
// Image width and height should have higher priority.
if
(
$width
=
$html_node
->
getAttribute
(
'width'
))
{
$attributes
[
'data-width'
]
=
$width
;
}
if
(
$height
=
$html_node
->
getAttribute
(
'height'
))
{
$attributes
[
'data-height'
]
=
$height
;
}
foreach
(
$attributes
as
$attr
=>
$val
)
{
if
(
empty
(
$val
))
{
continue
;
...
...
src/Plugin/migrate/process/UwMigrationLookupPath.php
View file @
786d306f
...
...
@@ -58,7 +58,7 @@ class UwMigrationLookupPath extends UwNodeLookup {
$uri
=
'internal:/'
.
$uri
;
// If the URL is canonical, then try to lookup in the existing migrations.
if
(
preg_match
(
'/node\/(
[0-9]
+)/'
,
$uri
,
$matches
))
{
if
(
preg_match
(
'/node\/(
\d
+)/'
,
$uri
,
$matches
))
{
$entity_type
=
'node'
;
$source_nid
=
$matches
[
1
];
...
...
@@ -80,7 +80,7 @@ class UwMigrationLookupPath extends UwNodeLookup {
if
(
$url
->
isRouted
())
{
$route_name
=
$url
->
getRouteName
();
foreach
(
array_keys
(
$this
->
entityTypeManager
->
getDefinitions
())
as
$entity_type_id
)
{
if
(
$route_name
==
"entity.
$entity_type_id
.canonical"
&&
isset
(
$url
->
getRouteParameters
()[
$entity_type_id
]))
{
if
(
$route_name
==
=
"entity.
$entity_type_id
.canonical"
&&
isset
(
$url
->
getRouteParameters
()[
$entity_type_id
]))
{
$uri
=
"entity:
$entity_type_id
/"
.
$url
->
getRouteParameters
()[
$entity_type_id
];
}
}
...
...
uw_migrate.module
View file @
786d306f
...
...
@@ -11,6 +11,13 @@ use Drupal\migrate\Plugin\migrate\destination\EntityContentBase;
use
Drupal\migrate\Row
;
use
Drupal\uw_migrate
\
Plugin\migrate\destination\UwEntityContentBase
;
/**
* Implements hook_migrate_scanner_patterns_alter().
*/
function
uw_migrate_migrate_scanner_patterns_alter
(
array
&
$patterns
)
{
$patterns
[
'include'
][]
=
'#uw_#'
;
}
/**
* Implements hook_migrate_destination_info_plugins_alter().
*/
...
...
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