reverted: --- b/core/modules/migrate_drupal/src/Plugin/migrate/process/d6/TimeZone.php +++ /dev/null @@ -1,40 +0,0 @@ -config('system.date'); $this->assertIdentical(4, $config->get('first_day')); $this->assertIdentical(FALSE, $config->get('timezone.user.configurable')); $this->assertIdentical("Europe/Paris", $config->get('timezone.default')); diff -u b/core/modules/user/src/Plugin/migrate/process/d6/UserUpdate7002.php b/core/modules/user/src/Plugin/migrate/process/d6/UserUpdate7002.php --- b/core/modules/user/src/Plugin/migrate/process/d6/UserUpdate7002.php +++ b/core/modules/user/src/Plugin/migrate/process/d6/UserUpdate7002.php @@ -10,6 +10,9 @@ use Drupal\migrate\MigrateExecutableInterface; use Drupal\migrate\ProcessPluginBase; use Drupal\migrate\Row; +use Drupal\Core\Config\Config; +use Drupal\Core\Plugin\ContainerFactoryPluginInterface; +use Symfony\Component\DependencyInjection\ContainerInterface; /** * Converts user time zones from time zone offsets to time zone names. @@ -18,7 +21,7 @@ * id = "user_update_7002" * ) */ -class UserUpdate7002 extends ProcessPluginBase { +class UserUpdate7002 extends ProcessPluginBase implements ContainerFactoryPluginInterface { /** * System timezones. @@ -28,10 +31,25 @@ protected static $timezones; /** + * Contains the configuration object factory. + * + * @var \Drupal\Core\Config\ConfigFactoryInterface + */ + protected $configFactory; + + /** + * Contains the system.theme configuration object. + * + * @var \Drupal\Core\Config\Config + */ + protected $dateConfig; + + /** * {@inheritdoc} */ - public function __construct(array $configuration, $plugin_id, array $plugin_definition) { + public function __construct(array $configuration, $plugin_id, array $plugin_definition, Config $date_config) { parent::__construct($configuration, $plugin_id, $plugin_definition); + $this->dateConfig = $date_config; if (!isset(static::$timezones)) { static::$timezones = system_time_zones(); } @@ -40,6 +58,18 @@ /** * {@inheritdoc} */ + public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) { + $x = 100; + return new static( + $configuration, + $plugin_id, + $plugin_definition, + $container->get('config.factory')->get('system.date') + ); + } + /** + * {@inheritdoc} + */ public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) { $timezone = NULL; @@ -55,7 +85,7 @@ } if ($timezone === NULL) { - $timezone = \Drupal::config('system.date')->get('timezone.default'); + $timezone = $this->dateConfig->get('timezone.default'); } return $timezone; } only in patch2: unchanged: --- /dev/null +++ b/core/modules/system/src/Plugin/migrate/process/d6/TimeZone.php @@ -0,0 +1,38 @@ + 'test', + // Leave it empty for now. + 'idlist' => array(), + // This needs to be the identifier of the actual key: cid for comment, nid + // for node and so on. + 'source' => array( + 'plugin' => 'd6_menu', + ), + ); + + // We need to set up the database contents; it's easier to do that below. + + protected $expectedResults = array( + array( + 'menu_name' => 'menu-name-1', + 'title' => 'menu custom value 1', + 'description' => 'menu custom description value 1', + ), + array( + 'menu_name' => 'menu-name-2', + 'title' => 'menu custom value 2', + 'description' => 'menu custom description value 2', + ), + ); + + /** + * {@inheritdoc} + */ + protected function setUp() { + // This array stores the database. + foreach ($this->expectedResults as $k => $row) { + $this->databaseContents['menu_custom'][$k] = $row; + } + parent::setUp(); + } + +}