Url aliases migration part1.
Right now it straight migrate the aliases but the idea is that instead of migrate the aliases migrate them as redirects only if the new site url does not match with the old one.
This commit is contained in:
parent
a9c98518f3
commit
937d6f775d
2 changed files with 104 additions and 0 deletions
|
@ -0,0 +1,64 @@
|
|||
langcode: en
|
||||
status: true
|
||||
dependencies: { }
|
||||
id: upgrade_d7_url_alias
|
||||
class: Drupal\migrate\Plugin\Migration
|
||||
field_plugin_method: null
|
||||
cck_plugin_method: null
|
||||
migration_tags:
|
||||
- 'Drupal 7'
|
||||
- Content
|
||||
migration_group: migrate_drupal_7_geo
|
||||
label: 'URL aliases'
|
||||
source:
|
||||
plugin: d7_url_alias
|
||||
constants:
|
||||
slash: /
|
||||
process:
|
||||
source:
|
||||
-
|
||||
plugin: concat
|
||||
source:
|
||||
- constants/slash
|
||||
- source
|
||||
alias:
|
||||
-
|
||||
plugin: skip_on_match
|
||||
source: alias
|
||||
method: row
|
||||
# Content that wasn't migrated so the alias won't be migrate either.
|
||||
value:
|
||||
- 'event/' # Content type Event
|
||||
- 'issue/' # Taxonomy vocabulary Issue
|
||||
- 'regular-contributors/' # Regular contributors
|
||||
- 'geo-volume-2/'
|
||||
- 'geo-volume-3/'
|
||||
- 'geo-volume-1/'
|
||||
- 'ad-groups'
|
||||
-
|
||||
plugin: concat
|
||||
source:
|
||||
- constants/slash
|
||||
- alias
|
||||
langcode:
|
||||
-
|
||||
plugin: get
|
||||
source: language
|
||||
# node_translation:
|
||||
# -
|
||||
# plugin: explode
|
||||
# source: source
|
||||
# delimiter: /
|
||||
# -
|
||||
# plugin: extract
|
||||
# default: INVALID_NID
|
||||
# index:
|
||||
# - 1
|
||||
# -
|
||||
# plugin: migration_lookup
|
||||
# migration: { }
|
||||
destination:
|
||||
plugin: url_alias
|
||||
migration_dependencies:
|
||||
required: { }
|
||||
optional: { }
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\geo_upgrade\Plugin\migrate\process;
|
||||
|
||||
use Drupal\migrate_plus\Plugin\migrate\process\SkipOnValue;
|
||||
|
||||
/**
|
||||
* If the source evaluates to a configured value, skip processing or whole row.
|
||||
*
|
||||
* @MigrateProcessPlugin(
|
||||
* id = "skip_on_match"
|
||||
* )
|
||||
* Similar to SkipOnValue but this just compare if part of the string match.
|
||||
*
|
||||
* @see \Drupal\migrate_plus\Plugin\migrate\process\SkipOnValue
|
||||
*/
|
||||
class SkipOnMatch extends SkipOnValue {
|
||||
|
||||
/**
|
||||
* Compare values to see if they are equal.
|
||||
*
|
||||
* @param mixed $value
|
||||
* Actual value.
|
||||
* @param mixed $skipValue
|
||||
* Value to compare against.
|
||||
* @param bool $equal
|
||||
* Compare as equal or not equal.
|
||||
*
|
||||
* @return bool
|
||||
* True if the compare successfully, FALSE otherwise.
|
||||
*/
|
||||
protected function compareValue($value, $skipValue, $equal = TRUE) {
|
||||
if ($equal) {
|
||||
return strpos((string) $value, (string) $skipValue) !== FALSE;
|
||||
}
|
||||
|
||||
return strpos((string) $value, (string) $skipValue) === FALSE;
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Reference in a new issue