class MigrationForm in CMS Content Sync 2.0.x
Same name and namespace in other branches
- 2.1.x src/Form/MigrationForm.php \Drupal\cms_content_sync\Form\MigrationForm
Content Sync general settings form.
Hierarchy
- class \Drupal\Core\Form\FormBase implements ContainerInjectionInterface, FormInterface uses DependencySerializationTrait, LoggerChannelTrait, MessengerTrait, RedirectDestinationTrait, StringTranslationTrait
- class \Drupal\cms_content_sync\Form\MigrationForm
Expanded class hierarchy of MigrationForm
1 string reference to 'MigrationForm'
File
- src/
Form/ MigrationForm.php, line 15
Namespace
Drupal\cms_content_sync\FormView source
class MigrationForm extends FormBase {
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'migration_form';
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
// TODO: Drupal: Recreate Content Sync user password during migration to use stronger 64 characters and also ensure that the old Sync Core can't push updates anylonger; so this must be the last step when switching over.
$settings = ContentSyncSettings::getInstance();
// Already registered if this exists.
$uuid = $settings
->getSiteUuid();
if ($uuid) {
//$form['#prefix'] = '<div style="display: none;">';
//$form['#suffix'] = '</div>';
$form['#attributes']['style'][] = 'display: none;';
$all_pools = Pool::getAll();
$pool_options = [];
foreach ($all_pools as $pool) {
$pool_options[$pool
->id()] = $pool
->label();
}
$form['export-pools'] = [
'#prefix' => '<div id="content-sync-migration-export-pools">',
'#suffix' => '</div>',
'#title' => 'Export pools',
'#type' => 'checkboxes',
'#options' => $pool_options,
];
$all_flows = Flow::getAll();
$flow_options = [];
foreach ($all_flows as $flow) {
$flow_options[$flow
->id()] = $flow
->label();
}
$form['export-flows'] = [
'#prefix' => '<div id="content-sync-migration-export-flows">',
'#suffix' => '</div>',
'#title' => 'Export flows',
'#type' => 'checkboxes',
'#options' => $flow_options,
];
$form['skip-flows-test'] = [
'#prefix' => '<div id="content-sync-migration-skip-flows-test">',
'#suffix' => '</div>',
'#title' => 'Skip flows test',
'#type' => 'checkboxes',
'#options' => $flow_options,
];
$form['skip-flows-push'] = [
'#prefix' => '<div id="content-sync-migration-skip-flows-push">',
'#suffix' => '</div>',
'#title' => 'Skip flows migration',
'#type' => 'checkboxes',
'#options' => $flow_options,
];
$form['skip-flows-pull'] = [
'#prefix' => '<div id="content-sync-migration-skip-flows-pull">',
'#suffix' => '</div>',
'#title' => 'Skip flows migration',
'#type' => 'checkboxes',
'#options' => $flow_options,
];
$form['action'] = [
'#title' => 'Action',
'#type' => 'radios',
'#options' => [
'export-pools' => 'Export Pools',
'export-flows' => 'Export Flows',
'skip-flows-test' => 'Skip Flows test',
'skip-flows-push' => 'Skip Flows push',
'skip-flows-pull' => 'Skip Flows pull',
'switch' => 'Switch',
],
];
$form['submit'] = [
'#type' => 'submit',
'#value' => 'Submit',
'#button_type' => 'primary',
];
}
else {
$url = Url::fromRoute('cms_content_sync_flow.site')
->toString();
\Drupal::messenger()
->addMessage('Please register this site first.', 'warning');
$form['redirect'] = [
'#markup' => 'This site is not registered yet. Please <a href="' . $url
->toString() . '">register first</a>.',
];
}
return $form;
}
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state) {
parent::validateForm($form, $form_state);
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
if ('export-pools' === $form_state
->getValue('action')) {
Migration::runPoolExport(array_keys(array_filter($form_state
->getValue('export-pools'))));
}
elseif ('export-flows' === $form_state
->getValue('action')) {
Migration::runFlowExport(array_keys(array_filter($form_state
->getValue('export-flows'))));
}
elseif ('skip-flows-test' === $form_state
->getValue('action')) {
Migration::skipFlowsTest(array_keys(array_filter($form_state
->getValue('skip-flows-test'))));
}
elseif ('skip-flows-push' === $form_state
->getValue('action')) {
Migration::skipFlowsPush(array_keys(array_filter($form_state
->getValue('skip-flows-push'))));
}
elseif ('skip-flows-pull' === $form_state
->getValue('action')) {
Migration::skipFlowsPull(array_keys(array_filter($form_state
->getValue('skip-flows-pull'))));
}
elseif ('switch' === $form_state
->getValue('action')) {
Migration::runSwitch();
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | ||
DependencySerializationTrait:: |
protected | property | ||
DependencySerializationTrait:: |
public | function | 2 | |
DependencySerializationTrait:: |
public | function | 2 | |
FormBase:: |
protected | property | The config factory. | 3 |
FormBase:: |
protected | property | The request stack. | 1 |
FormBase:: |
protected | property | The route match. | |
FormBase:: |
protected | function | Retrieves a configuration object. | |
FormBase:: |
protected | function | Gets the config factory for this form. | 3 |
FormBase:: |
private | function | Returns the service container. | |
FormBase:: |
public static | function |
Instantiates a new instance of this class. Overrides ContainerInjectionInterface:: |
105 |
FormBase:: |
protected | function | Gets the current user. | |
FormBase:: |
protected | function | Gets the request object. | |
FormBase:: |
protected | function | Gets the route match. | |
FormBase:: |
protected | function | Gets the logger for a specific channel. | |
FormBase:: |
protected | function | Returns a redirect response object for the specified route. | |
FormBase:: |
public | function | Resets the configuration factory. | |
FormBase:: |
public | function | Sets the config factory for this form. | |
FormBase:: |
public | function | Sets the request stack object to use. | |
LoggerChannelTrait:: |
protected | property | The logger channel factory service. | |
LoggerChannelTrait:: |
protected | function | Gets the logger for a specific channel. | |
LoggerChannelTrait:: |
public | function | Injects the logger channel factory. | |
MessengerTrait:: |
protected | property | The messenger. | 27 |
MessengerTrait:: |
public | function | Gets the messenger. | 27 |
MessengerTrait:: |
public | function | Sets the messenger. | |
MigrationForm:: |
public | function |
Form constructor. Overrides FormInterface:: |
|
MigrationForm:: |
public | function |
Returns a unique string identifying the form. Overrides FormInterface:: |
|
MigrationForm:: |
public | function |
Form submission handler. Overrides FormInterface:: |
|
MigrationForm:: |
public | function |
Form validation handler. Overrides FormBase:: |
|
RedirectDestinationTrait:: |
protected | property | The redirect destination service. | 1 |
RedirectDestinationTrait:: |
protected | function | Prepares a 'destination' URL query parameter for use with \Drupal\Core\Url. | |
RedirectDestinationTrait:: |
protected | function | Returns the redirect destination service. | |
RedirectDestinationTrait:: |
public | function | Sets the redirect destination service. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 4 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |