class PardotFormMappingForm in Pardot Integration 2.x
Class PardotFormMappingForm.
Hierarchy
- class \Drupal\Core\Form\FormBase implements ContainerInjectionInterface, FormInterface uses DependencySerializationTrait, LoggerChannelTrait, MessengerTrait, RedirectDestinationTrait, StringTranslationTrait
- class \Drupal\pardot\Form\PardotFormMappingForm
Expanded class hierarchy of PardotFormMappingForm
1 file declares its use of PardotFormMappingForm
- PardotFormMappingController.php in src/
Controller/ PardotFormMappingController.php
2 string references to 'PardotFormMappingForm'
File
- src/
Form/ PardotFormMappingForm.php, line 13
Namespace
Drupal\pardot\FormView source
class PardotFormMappingForm extends FormBase {
/**
* Drupal\pardot\Plugin\FormMapHandlerPluginManager definition.
*
* @var \Drupal\pardot\Plugin\FormMapHandlerPluginManager
*/
protected $pluginManagerFormMapHandlerPlugin;
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container) {
$instance = parent::create($container);
$instance->pluginManagerFormMapHandlerPlugin = $container
->get('plugin.manager.form_map_handler_plugin');
return $instance;
}
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'pardot_form_mapping_form';
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$formMapPluginManager = $this->pluginManagerFormMapHandlerPlugin;
$entity = func_get_args()[2];
$form_map_plugin_instance_id = func_get_args()[3] ?? '';
if ($entity && $form_map_plugin_instance_id) {
$form_state
->set('entity', $entity);
$form_state
->set('form_map_plugin_instance_id', $form_map_plugin_instance_id);
$plugin = $formMapPluginManager
->createInstance($form_map_plugin_instance_id);
$settings = [
$entity
->getEntityTypeId() => $entity
->id(),
'entity_id' => $entity
->id(),
];
if ($plugin_settings = $entity
->getThirdPartySetting('pardot', 'pardot_form_mapping_plugin', FALSE)) {
$settings['settings'] = $plugin_settings['settings'];
}
$plugin
->setConfiguration($settings);
$form['pardot_form_mapping'] = PluginSubFormHelpers::buildPluginForm($plugin, $form, $form_state, [
'pardot_form_mapping',
]);
}
$form['submit'] = [
'#type' => 'submit',
'#value' => $this
->t('Submit'),
];
return $form;
}
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state) {
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
// Display result.
$values = $form_state
->getValues();
$pardot_form_mapping = $values['pardot_form_mapping'] ?? FALSE;
$entity = $form_state
->get('entity');
$form_map_plugin_instance_id = $form_state
->get('form_map_plugin_instance_id');
if ($pardot_form_mapping && $form_map_plugin_instance_id && $entity) {
$plugin = $this->pluginManagerFormMapHandlerPlugin;
$plugin = $plugin
->createInstance($form_map_plugin_instance_id);
$plugin = PluginSubFormHelpers::pluginSubmit($plugin, $form, $form_state, [
'pardot_form_mapping',
]);
$entity
->setThirdPartySetting('pardot', 'pardot_form_mapping_plugin', $plugin
->getConfiguration());
$entity
->save();
}
}
}
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:: |
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. | |
PardotFormMappingForm:: |
protected | property | Drupal\pardot\Plugin\FormMapHandlerPluginManager definition. | |
PardotFormMappingForm:: |
public | function |
Form constructor. Overrides FormInterface:: |
|
PardotFormMappingForm:: |
public static | function |
Instantiates a new instance of this class. Overrides FormBase:: |
|
PardotFormMappingForm:: |
public | function |
Returns a unique string identifying the form. Overrides FormInterface:: |
|
PardotFormMappingForm:: |
public | function |
Form submission handler. Overrides FormInterface:: |
|
PardotFormMappingForm:: |
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. |