Commit 673491d6 authored by Damien McKenna's avatar Damien McKenna Committed by Damien McKenna
Browse files

Issue #3193523 by DamienMcKenna: Removed files accidentally committed.

parent d451f8fe
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ Metatag 8.x-1.x-dev, xxxx-xx-xx
  ::assertEqual by $this->assertEquals().
#3190808 by Wim Leers, DamienMcKenna: Do not run a "table exists" query for
  every migrated row of data (regardless of whether it's a metatag row or not!).
#3193523 by DamienMcKenna: Removed files accidentally committed.


Metatag 8.x-1.15, 2020-12-05

migrations/d7_metatag_default.yml

deleted100644 → 0
+0 −33
Original line number Diff line number Diff line
# A default migration mapping for Metatag-D7 default configuration.
#
# @see Drupal\metatag\Plugin\migrate\source\d7\MetatagDefault

id: d7_metatag_default
label: Metatag default configuration
migration_tags:
  - Drupal 7

source:
  plugin: d7_metatag_default
  source_module: metatag
  ignore_map: true
  constants:
    langcode: und
    status: true

# @todo What is the correct destination type.
destination:
  plugin: config
  # @todo This needs to be generated dynamically.
  config_name: metatag.metatag_defaults.INSTANCE

# @todo What is needed for the migration processing.
process:
  # These are simple constants that will be kept as-is.
  langcode: 'constants/langcode'
  status: 'constants/status'

  # These come from the actual records.
  id: instance
  label: instance
  tags: config
+0 −64
Original line number Diff line number Diff line
<?php

namespace Drupal\metatag\Plugin\migrate\source\d7;

use Drupal\migrate\Row;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;

/**
 * Drupal 7 Metatag configuration.
 *
 * @MigrateSource(
 *   id = "d7_metatag_default",
 *   source_module = "metatag"
 * )
 */
class MetatagDefault extends DrupalSqlBase {

  /**
   * {@inheritdoc}
   */
  public function query() {
    return $this->select('metatag_config', 'm')
      ->fields('m', ['instance', 'config']);
  }

  /**
   * {@inheritdoc}
   */
  public function fields() {
    $fields = [
      'instance' => $this->t('Configuration instance'),
      'config' => $this->t('Meta tags'),
    ];
    return $fields;
  }

  /**
   * {@inheritdoc}
   */
  public function getIds() {
    $ids['instance']['type'] = 'string';
    $ids['config']['type'] = 'string';
    return $ids;
  }

  /**
   * {@inheritdoc}
   */
  public function prepareRow(Row $row) {
    parent::prepareRow($row);

    // @todo Unserialize the 'config' value to make processing easier.
    $config = $row->getSourceProperty('config');
    try {
      $config = unserialize($config);
      $row->setSourceProperty('config_expanded', $config);
    }
    catch (\Exception $e) {
      // Log an error message about this record.
      throw new MigrateSkipRowException('Unable to unserialize record %blah');
    }
  }

}
+0 −71
Original line number Diff line number Diff line
<?php

namespace Drupal\Tests\metatag\Kernel\Migrate\d7;

use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;

/**
 * Tests Metatag-D7 configuration source plugin.
 *
 * @group metatag
 * @covers \Drupal\metatag\Plugin\migrate\source\d7\MetatagDefault
 */
class MetatagDefaultTest extends MigrateDrupal7TestBase {

  /**
   * {@inheritdoc}
   */
  public static $modules = [
    // Core modules.
    // @see testAvailableConfigEntities
    // 'comment',
    // 'content_translation',
    // 'datetime',
    // 'filter',
    // 'image',
    'language',
    // 'link',
    // 'menu_link_content',
    // 'menu_ui',
    // 'node',
    // 'taxonomy',
    // 'telephone',
    // 'text',

    // Contrib modules.
    'token',

    // This module.
    'metatag',
  ];

  /**
   * {@inheritdoc}
   */
  protected function setUp() {
    if (version_compare(\Drupal::VERSION, '8.9', '<')) {
      $this->markTestSkipped('This test requires at least Drupal 8.9');
    }
    parent::setUp();
    $this->loadFixture(__DIR__ . '/../../../../fixtures/d7_metatag.php');

    $this->installConfig(static::$modules);
    $this->installSchema('system', ['sequences']);
    $this->installEntitySchema('metatag_defaults');

    // @todo Can any of these be skipped?
    $this->executeMigrations([
      'language',
      'd7_metatag_default',
    ]);
  }

  /**
   * Test Metatag default configuration migration from Drupal 7 to 8.
   */
  public function testMetatag() {
    // @todo Load Metatag configuration entities.
    // @todo Confirm the Metatag configuration entities have the expected data.
  }

}