class IncrementalForm extends MigrateUpgradeFormBase (View source)

internal  
 

Migrate Upgrade Incremental form.

Traits

Configures the appropriate migrations for a given source Drupal database.

Provides dependency injection friendly methods for serialization.

Wrapper methods for the logger factory service.

Provides a trait for the messenger service.

Wrapper methods for the Redirect Destination.

Wrapper methods for \Drupal\Core\StringTranslation\TranslationInterface.

Properties

protected array $_serviceIds

An array of service IDs keyed by property name used for serialization.

from  DependencySerializationTrait
protected array $_entityStorages

An array of entity type IDs keyed by the property name of their storages.

from  DependencySerializationTrait
protected LoggerChannelFactoryInterface $loggerFactory

The logger channel factory service.

from  LoggerChannelTrait
protected MessengerInterface $messenger

The messenger.

from  MessengerTrait
protected RedirectDestinationInterface $redirectDestination

The redirect destination service.

from  RedirectDestinationTrait
protected TranslationInterface $stringTranslation

The string translation service.

from  StringTranslationTrait
protected RequestStack $requestStack

The request stack.

from  FormBase
protected ConfigFactoryInterface $configFactory

The config factory service.

from  MigrationConfigurationTrait
protected RouteMatchInterface $routeMatch

The route match.

from  FormBase
protected MigrationPluginManagerInterface $migrationPluginManager

The migration plugin manager service.

from  MigrationConfigurationTrait
protected StateInterface $state

The state service.

from  MigrationConfigurationTrait
protected string[] $followUpMigrationTags

The follow-up migration tags.

from  MigrationConfigurationTrait
protected PrivateTempStoreFactory $store

Private temporary storage.

from  MigrateUpgradeFormBase
protected string $destinationSiteVersion

The destination site major version.

from  MigrateUpgradeFormBase
protected DateFormatterInterface $dateFormatter

The date formatter service.

Methods

__sleep()

{@inheritdoc}

__wakeup()

{@inheritdoc}

LoggerInterface
getLogger(string $channel)

Gets the logger for a specific channel.

$this
setLoggerFactory(LoggerChannelFactoryInterface $logger_factory)

Injects the logger channel factory.

setMessenger(MessengerInterface $messenger)

Sets the messenger.

messenger()

Gets the messenger.

array
getDestinationArray()

Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url.

getRedirectDestination()

Returns the redirect destination service.

$this
setRedirectDestination(RedirectDestinationInterface $redirect_destination)

Sets the redirect destination service.

t(string $string, array $args = [], array $options = [])

Translates a string to the current language or to a given language.

formatPlural($count, $singular, $plural, array $args = [], array $options = [])

Formats a string containing a count of items.

getNumberOfPlurals($langcode = NULL)

Returns the number of plurals supported by a given language.

getStringTranslation()

Gets the string translation service.

$this
setStringTranslation(TranslationInterface $translation)

Sets the string translation service to use.

static 
create(ContainerInterface $container)

Instantiates a new instance of this class.

validateForm(array $form, FormStateInterface $form_state)

Form validation handler.

from  FormBase
config(string $name)

Retrieves a configuration object.

from  FormBase
configFactory()

Gets the config factory for this form.

from  FormBase
$this
setConfigFactory(ConfigFactoryInterface $config_factory)

Sets the config factory for this form.

from  FormBase
resetConfigFactory()

Resets the configuration factory.

from  FormBase
Request
getRequest()

Gets the request object.

from  FormBase
getRouteMatch()

Gets the route match.

from  FormBase
$this
setRequestStack(RequestStack $request_stack)

Sets the request stack object to use.

from  FormBase
currentUser()

Gets the current user.

from  FormBase
RedirectResponse
redirect(string $route_name, array $route_parameters = [], array $options = [], int $status = 302)

Returns a redirect response object for the specified route.

from  FormBase
LoggerInterface
logger(string $channel)

Gets the logger for a specific channel.

from  FormBase
getConnection(array $database)

Gets the database connection for the source Drupal database.

array
getSystemData(Connection $connection)

Gets the system data from the system table of the source Drupal database.

createDatabaseStateSettings(array $database, string $drupal_version)

Creates the necessary state entries for SqlBase::getDatabase() to work.

getMigrations(string $database_state_key, int $drupal_version)

Gets the migrations for import.

string[]
getFollowUpMigrationTags()

Returns the follow-up migration tags.

static string|false
getLegacyDrupalVersion(Connection $connection)

Determines what version of Drupal the source database contains.

getConfigFactory()

Gets the config factory service.

getState()

Gets the state service.

__construct(StateInterface $state, DateFormatterInterface $date_formatter, PrivateTempStoreFactory $tempstore_private, ConfigFactoryInterface $config_factory, MigrationPluginManagerInterface $migration_plugin_manager)

IncrementalForm constructor.

array
buildForm(array $form, FormStateInterface $form_state)

Form constructor.

RedirectResponse
restartUpgradeForm()

Helper to redirect to the Overview form.

string
getConfirmText()

Returns a caption for the button that confirms the action.

string
getFormId()

Returns a unique string identifying the form.

submitForm(array $form, FormStateInterface $form_state)

Form submission handler.

Details

__sleep()

{@inheritdoc}

__wakeup()

{@inheritdoc}

protected LoggerInterface getLogger(string $channel)

Gets the logger for a specific channel.

Require the use of injected services: https://www.drupal.org/node/2733703

Parameters

string $channel

The name of the channel. Can be any string, but the general practice is to use the name of the subsystem calling this.

Return Value

LoggerInterface

The logger for the given channel.

$this setLoggerFactory(LoggerChannelFactoryInterface $logger_factory)

Injects the logger channel factory.

Parameters

LoggerChannelFactoryInterface $logger_factory

The logger channel factory service.

Return Value

$this

setMessenger(MessengerInterface $messenger)

Sets the messenger.

Parameters

MessengerInterface $messenger

The messenger.

MessengerInterface messenger()

Gets the messenger.

Return Value

MessengerInterface

The messenger.

protected array getDestinationArray()

Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url.

Return Value

array

An associative array containing the key:

  • destination: The value of the current request's 'destination' query parameter, if present. This can be either a relative or absolute URL. However, for security, redirection to external URLs is not performed. If the query parameter isn't present, then the URL of the current request is returned.

See also

RedirectDestinationInterface::getAsArray

protected RedirectDestinationInterface getRedirectDestination()

Returns the redirect destination service.

Return Value

RedirectDestinationInterface

The redirect destination helper.

$this setRedirectDestination(RedirectDestinationInterface $redirect_destination)

Sets the redirect destination service.

Parameters

RedirectDestinationInterface $redirect_destination

The redirect destination service.

Return Value

$this

protected TranslatableMarkup t(string $string, array $args = [], array $options = [])

Translates a string to the current language or to a given language.

See \Drupal\Core\StringTranslation\TranslatableMarkup::__construct() for important security information and usage guidelines.

In order for strings to be localized, make them available in one of the ways supported by the

Parameters

string $string

A string containing the English text to translate.

array $args

(optional) An associative array of replacements to make after translation. Based on the first character of the key, the value is escaped and/or themed. See \Drupal\Component\Render\FormattableMarkup::placeholderFormat() for details.

array $options

(optional) An associative array of additional options, with the following elements:

  • 'langcode' (defaults to the current language): A language code, to translate to a language other than what is used to display the page.
  • 'context' (defaults to the empty context): The context the source string belongs to. See the @link i18n Internationalization topic @endlink for more information about string contexts.

Return Value

TranslatableMarkup

An object that, when cast to a string, returns the translated string.

See also

FormattableMarkup::placeholderFormat
TranslatableMarkup::__construct

protected formatPlural($count, $singular, $plural, array $args = [], array $options = [])

Formats a string containing a count of items.

Parameters

$count
$singular
$plural
array $args
array $options

See also

TranslationInterface::formatPlural

protected getNumberOfPlurals($langcode = NULL)

Returns the number of plurals supported by a given language.

Parameters

$langcode

See also

PluralFormulaInterface::getNumberOfPlurals

protected TranslationInterface getStringTranslation()

Gets the string translation service.

Return Value

TranslationInterface

The string translation service.

$this setStringTranslation(TranslationInterface $translation)

Sets the string translation service to use.

Parameters

TranslationInterface $translation

The string translation service.

Return Value

$this

static create(ContainerInterface $container)

Instantiates a new instance of this class.

This is a factory method that returns a new instance of this class. The factory should pass any needed dependencies into the constructor of this class, but not the container itself. Every call to this method must return a new instance of this class; that is, it may not implement a singleton.

Parameters

ContainerInterface $container

The service container this instance should use.

validateForm(array $form, FormStateInterface $form_state)

Form validation handler.

Parameters

array $form

An associative array containing the structure of the form.

FormStateInterface $form_state

The current state of the form.

protected ImmutableConfig config(string $name)

Retrieves a configuration object.

This is the main entry point to the configuration API. Calling

Parameters

string $name

The name of the configuration object to retrieve. The name corresponds to a configuration file. For @code \Drupal::config('book.admin') @endcode, the config object returned will contain the contents of book.admin configuration file.

Return Value

ImmutableConfig

A configuration object.

protected ConfigFactoryInterface configFactory()

Gets the config factory for this form.

When accessing configuration values, use $this->config(). Only use this when the config factory needs to be manipulated directly.

Return Value

ConfigFactoryInterface

$this setConfigFactory(ConfigFactoryInterface $config_factory)

Sets the config factory for this form.

Parameters

ConfigFactoryInterface $config_factory

The config factory.

Return Value

$this

resetConfigFactory()

Resets the configuration factory.

protected Request getRequest()

Gets the request object.

Return Value

Request

The request object.

protected RouteMatchInterface getRouteMatch()

Gets the route match.

Return Value

RouteMatchInterface

$this setRequestStack(RequestStack $request_stack)

Sets the request stack object to use.

Parameters

RequestStack $request_stack

The request stack object.

Return Value

$this

protected AccountInterface currentUser()

Gets the current user.

Return Value

AccountInterface

The current user.

protected RedirectResponse redirect(string $route_name, array $route_parameters = [], array $options = [], int $status = 302)

Returns a redirect response object for the specified route.

Parameters

string $route_name

The name of the route to which to redirect.

array $route_parameters

(optional) Parameters for the route.

array $options

(optional) An associative array of additional options.

int $status

(optional) The HTTP redirect status code for the redirect. The default is 302 Found.

Return Value

RedirectResponse

A redirect response object that may be returned by the controller.

protected LoggerInterface logger(string $channel)

Gets the logger for a specific channel.

This method exists for backward-compatibility between FormBase and LoggerChannelTrait. Use LoggerChannelTrait::getLogger() instead.

Parameters

string $channel

The name of the channel. Can be any string, but the general practice is to use the name of the subsystem calling this.

Return Value

LoggerInterface

The logger for the given channel.

protected Connection getConnection(array $database)

Gets the database connection for the source Drupal database.

Parameters

array $database

Database array representing the source Drupal database.

Return Value

Connection

The database connection for the source Drupal database.

protected array getSystemData(Connection $connection)

Gets the system data from the system table of the source Drupal database.

Parameters

Connection $connection

Database connection to the source Drupal database.

Return Value

array

The system data from the system table of the source Drupal database.

protected createDatabaseStateSettings(array $database, string $drupal_version)

Creates the necessary state entries for SqlBase::getDatabase() to work.

The state entities created here have to exist before migration plugin instances are created so that derivers such as \Drupal\taxonomy\Plugin\migrate\D6TermNodeDeriver can access the source database.

Parameters

array $database

The source database settings.

string $drupal_version

The Drupal version.

See also

SqlBase::getDatabase

protected MigrationInterface[] getMigrations(string $database_state_key, int $drupal_version)

Gets the migrations for import.

Parameters

string $database_state_key

The state key.

int $drupal_version

The version of Drupal we're getting the migrations for.

Return Value

MigrationInterface[]

The migrations for import.

protected string[] getFollowUpMigrationTags()

Returns the follow-up migration tags.

Return Value

string[]

static string|false getLegacyDrupalVersion(Connection $connection)

Determines what version of Drupal the source database contains.

Parameters

Connection $connection

The database connection object.

Return Value

string|false

A string representing the major branch of Drupal core (e.g. '6' for Drupal 6.x), or FALSE if no valid version is matched.

protected ConfigFactoryInterface getConfigFactory()

Gets the config factory service.

Return Value

ConfigFactoryInterface

The config factory service.

protected MigrationPluginManagerInterface getMigrationPluginManager()

Gets the migration plugin manager service.

Return Value

MigrationPluginManagerInterface

The migration plugin manager service.

protected StateInterface getState()

Gets the state service.

Return Value

StateInterface

The state service.

__construct(StateInterface $state, DateFormatterInterface $date_formatter, PrivateTempStoreFactory $tempstore_private, ConfigFactoryInterface $config_factory, MigrationPluginManagerInterface $migration_plugin_manager)

IncrementalForm constructor.

Parameters

StateInterface $state

The state service.

DateFormatterInterface $date_formatter

The date formatter service.

PrivateTempStoreFactory $tempstore_private

The private tempstore factory service.

ConfigFactoryInterface $config_factory

The config factory service.

MigrationPluginManagerInterface $migration_plugin_manager

The migration plugin manager service.

array buildForm(array $form, FormStateInterface $form_state)

Form constructor.

Parameters

array $form

An associative array containing the structure of the form.

FormStateInterface $form_state

The current state of the form.

Return Value

array

The form structure.

protected RedirectResponse restartUpgradeForm()

Helper to redirect to the Overview form.

Return Value

RedirectResponse

A redirect response object that may be returned by the controller.

Exceptions

TempStoreException

string getConfirmText()

Returns a caption for the button that confirms the action.

Return Value

string

The form confirmation text.

string getFormId()

Returns a unique string identifying the form.

The returned ID should be a unique string that can be a valid PHP function name, since it's used in hook implementation names such as hook_form_FORM_ID_alter().

Return Value

string

The unique string identifying the form.

submitForm(array $form, FormStateInterface $form_state)

Form submission handler.

Parameters

array $form

An associative array containing the structure of the form.

FormStateInterface $form_state

The current state of the form.