media_acquiadam-8.x-1.46/src/Controller/MigrationController.php
src/Controller/MigrationController.php
<?php
namespace Drupal\media_acquiadam\Controller;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Form\FormBuilder;
use Drupal\Core\Routing\RouteMatchInterface;
use Drupal\Core\State\StateInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* A controller for welcome modal.
*/
class MigrationController extends ControllerBase {
/**
* The form builder.
*
* @var \Drupal\Core\Form\FormBuilder
*/
protected $formBuilder;
/**
* The state interface.
*
* @var \Drupal\Core\State\StateInterface
*/
protected $state;
/**
* The current route match.
*
* @var \Drupal\Core\Routing\RouteMatchInterface
*/
private $routeMatch;
/**
* The ModalFormExampleController constructor.
*
* @param \Drupal\Core\State\StateInterface $state
* The state service.
* @param \Drupal\Core\Form\FormBuilder $formBuilder
* The form builder.
* @param \Drupal\Core\Routing\RouteMatchInterface $route_match
* The current route match.
*/
public function __construct(StateInterface $state, FormBuilder $formBuilder, RouteMatchInterface $route_match) {
$this->state = $state;
$this->formBuilder = $formBuilder;
$this->routeMatch = $route_match;
}
/**
* {@inheritdoc}
*
* @param \Symfony\Component\DependencyInjection\ContainerInterface $container
* The Drupal service container.
*
* @return static
*/
public static function create(ContainerInterface $container) {
return new static(
$container->get('state'),
$container->get('form_builder'),
$container->get('current_route_match')
);
}
/**
* Callback for opening the migration form.
*/
public function openMigrationForm() {
// If migration has completed show the migration details.
if ($this->state->get('media_acquiadam.migration_process_finished', FALSE)) {
// Get the migration complete form using the form builder.
$migration_complete_form = $this->formBuilder->getForm('Drupal\media_acquiadam\Form\AcquiadamMigrationComplete');
return $migration_complete_form;
}
// Get the migration config form using the form builder.
$migration_config_form = $this->formBuilder->getForm('Drupal\media_acquiadam\Form\AcquiadamMigration');
return $migration_config_form;
}
/**
* Callback for migration form title.
*
* @return string
* The title of the migration form.
*/
public function title(): string {
// If migration has completed show the migration details.
if ($this->state->get('media_acquiadam.migration_process_finished', FALSE)) {
// Get the migration complete form using the form builder.
return $this->t('Migration from legacy to modern Acquia DAM completed');
}
// Get the migration config form using the form builder.
return $this->t('Migration from legacy to modern Acquia DAM');
}
}
