only in patch2: unchanged: --- a/core/modules/link/src/Plugin/migrate/cckfield/LinkField.php +++ b/core/modules/link/src/Plugin/migrate/field/d6/LinkField.php @@ -1,12 +1,12 @@ 'link', @@ -37,9 +37,9 @@ public function getFieldFormatterMap() { /** * {@inheritdoc} */ - public function processCckFieldValues(MigrationInterface $migration, $field_name, $data) { + public function processFieldValues(MigrationInterface $migration, $field_name, $data) { $process = [ - 'plugin' => 'd6_cck_link', + 'plugin' => 'd6_field_link', 'source' => $field_name, ]; $migration->mergeProcessOfProperty($field_name, $process); only in patch2: unchanged: --- a/core/modules/link/src/Plugin/migrate/cckfield/d7/LinkField.php +++ b/core/modules/link/src/Plugin/migrate/field/d7/LinkField.php @@ -1,12 +1,12 @@ migration = $migration; - } - - /** - * {@inheritdoc} - */ - public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) { - return new static( - $configuration, - $plugin_id, - $plugin_definition, - $migration - ); - } - - /** - * Turn a Drupal 6 URI into a Drupal 8-compatible format. - * - * @param string $uri - * The 'url' value from Drupal 6. - * - * @return string - * The Drupal 8-compatible URI. - * - * @see \Drupal\link\Plugin\Field\FieldWidget\LinkWidget::getUserEnteredStringAsUri() - */ - protected function canonicalizeUri($uri) { - // If we already have a scheme, we're fine. - if (empty($uri) || !is_null(parse_url($uri, PHP_URL_SCHEME))) { - return $uri; - } - - // Remove the component of the URL. - if (strpos($uri, '') === 0) { - $uri = substr($uri, strlen('')); - } - - // Add the internal: scheme and ensure a leading slash. - return 'internal:/' . ltrim($uri, '/'); - } - - /** - * {@inheritdoc} - */ - public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { - $attributes = unserialize($value['attributes']); - // Drupal 6 link attributes might be double serialized. - if (!is_array($attributes)) { - $attributes = unserialize($attributes); - } - - if (!$attributes) { - $attributes = []; - } - - // Massage the values into the correct form for the link. - $route['uri'] = $this->canonicalizeUri($value['url']); - $route['options']['attributes'] = $attributes; - $route['title'] = $value['title']; - return $route; - } - -} +class CckLink extends FieldLink { } only in patch2: unchanged: --- /dev/null +++ b/core/modules/link/src/Plugin/migrate/process/d6/FieldLink.php @@ -0,0 +1,86 @@ +migration = $migration; + } + + /** + * {@inheritdoc} + */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) { + return new static( + $configuration, + $plugin_id, + $plugin_definition, + $migration + ); + } + + /** + * Turn a Drupal 6 URI into a Drupal 8-compatible format. + * + * @param string $uri + * The 'url' value from Drupal 6. + * + * @return string + * The Drupal 8-compatible URI. + * + * @see \Drupal\link\Plugin\Field\FieldWidget\LinkWidget::getUserEnteredStringAsUri() + */ + protected function canonicalizeUri($uri) { + // If we already have a scheme, we're fine. + if (empty($uri) || !is_null(parse_url($uri, PHP_URL_SCHEME))) { + return $uri; + } + + // Remove the component of the URL. + if (strpos($uri, '') === 0) { + $uri = substr($uri, strlen('')); + } + + // Add the internal: scheme and ensure a leading slash. + return 'internal:/' . ltrim($uri, '/'); + } + + /** + * {@inheritdoc} + */ + public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { + $attributes = unserialize($value['attributes']); + // Drupal 6 link attributes might be double serialized. + if (!is_array($attributes)) { + $attributes = unserialize($attributes); + } + + if (!$attributes) { + $attributes = []; + } + + // Massage the values into the correct form for the link. + $route['uri'] = $this->canonicalizeUri($value['url']); + $route['options']['attributes'] = $attributes; + $route['title'] = $value['title']; + return $route; + } + +} only in patch2: unchanged: --- a/core/modules/link/tests/src/Unit/Plugin/migrate/process/d6/CckLinkTest.php +++ b/core/modules/link/tests/src/Unit/Plugin/migrate/process/d6/FieldLinkTest.php @@ -2,21 +2,21 @@ namespace Drupal\Tests\link\Unit\Plugin\migrate\process\d6; -use Drupal\link\Plugin\migrate\process\d6\CckLink; +use Drupal\link\Plugin\migrate\process\d6\FieldLink; use Drupal\Tests\UnitTestCase; /** * @group Link */ -class CckLinkTest extends UnitTestCase { +class FieldLinkTest extends UnitTestCase { /** - * Test the url transformations in the CckLink process plugin. + * Test the url transformations in the FieldLink process plugin. * * @dataProvider canonicalizeUriDataProvider */ public function testCanonicalizeUri($url, $expected) { - $link_plugin = new CckLink([], '', [], $this->getMock('\Drupal\migrate\Plugin\MigrationInterface')); + $link_plugin = new FieldLink([], '', [], $this->getMock('\Drupal\migrate\Plugin\MigrationInterface')); $transformed = $link_plugin->transform([ 'url' => $url, 'title' => '',