IncrementalForm.php in Drupal 8
File
core/modules/migrate_drupal_ui/src/Form/IncrementalForm.php
View source
<?php
namespace Drupal\migrate_drupal_ui\Form;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Datetime\DateFormatterInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\State\StateInterface;
use Drupal\Core\TempStore\PrivateTempStoreFactory;
use Drupal\migrate\Plugin\MigrationPluginManagerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class IncrementalForm extends MigrateUpgradeFormBase {
protected $dateFormatter;
public function __construct(StateInterface $state, DateFormatterInterface $date_formatter, PrivateTempStoreFactory $tempstore_private, ConfigFactoryInterface $config_factory, MigrationPluginManagerInterface $migration_plugin_manager) {
parent::__construct($config_factory, $migration_plugin_manager, $state, $tempstore_private);
$this->dateFormatter = $date_formatter;
}
public static function create(ContainerInterface $container) {
return new static($container
->get('state'), $container
->get('date.formatter'), $container
->get('tempstore.private'), $container
->get('config.factory'), $container
->get('plugin.manager.migration'));
}
public function getFormId() {
return 'migrate_drupal_ui_incremental_form';
}
public function buildForm(array $form, FormStateInterface $form_state) {
$date_performed = $this->state
->get('migrate_drupal_ui.performed');
if (!$date_performed || $this->store
->get('step') != 'incremental') {
return $this
->restartUpgradeForm();
}
$form = parent::buildForm($form, $form_state);
$form['#title'] = $this
->t('Upgrade');
$form['upgrade_option_item'] = [
'#type' => 'item',
'#prefix' => $this
->t('An upgrade has already been performed on this site. To perform a new migration, create a clean and empty new install of Drupal @version. Rollbacks are not yet supported through the user interface. For more information, see the <a href=":url">upgrading handbook</a>.', [
'@version' => $this->destinationSiteVersion,
':url' => 'https://www.drupal.org/upgrade/migrate',
]),
'#description' => $this
->t('Last upgrade: @date', [
'@date' => $this->dateFormatter
->format($date_performed),
]),
];
return $form;
}
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->store
->set('step', 'credential');
$form_state
->setRedirect('migrate_drupal_ui.upgrade_credential');
}
public function getConfirmText() {
return $this
->t('Import new configuration and content from old site');
}
}