abstract class YamlFormHandlerBase in YAML Form 8
Provides a base class for a form handler.
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\yamlform\YamlFormHandlerBase implements YamlFormHandlerInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of YamlFormHandlerBase
See also
\Drupal\yamlform\YamlFormHandlerInterface
\Drupal\yamlform\YamlFormHandlerManager
\Drupal\yamlform\YamlFormHandlerManagerInterface
6 files declare their use of YamlFormHandlerBase
- BrokenYamlFormHandler.php in src/
Plugin/ YamlFormHandler/ BrokenYamlFormHandler.php - DebugYamlFormHandler.php in modules/
yamlform_devel/ src/ Plugin/ YamlFormHandler/ DebugYamlFormHandler.php - DebugYamlFormHandler.php in tests/
modules/ yamlform_test/ src/ Plugin/ YamlFormHandler/ DebugYamlFormHandler.php - EmailYamlFormHandler.php in src/
Plugin/ YamlFormHandler/ EmailYamlFormHandler.php - RemotePostYamlFormHandler.php in src/
Plugin/ YamlFormHandler/ RemotePostYamlFormHandler.php
File
- src/
YamlFormHandlerBase.php, line 18
Namespace
Drupal\yamlformView source
abstract class YamlFormHandlerBase extends PluginBase implements YamlFormHandlerInterface {
/**
* The form .
*
* @var \Drupal\yamlform\YamlFormInterface
*/
protected $yamlform = NULL;
/**
* The form handler ID.
*
* @var string
*/
protected $handler_id;
/**
* The form handler label.
*
* @var string
*/
protected $label;
/**
* The form handler status.
*
* @var bool
*/
protected $status = 1;
/**
* The weight of the form handler.
*
* @var int|string
*/
protected $weight = '';
/**
* A logger instance.
*
* @var \Psr\Log\LoggerInterface
*/
protected $logger;
/**
* {@inheritdoc}
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, LoggerInterface $logger) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this
->setConfiguration($configuration);
$this->logger = $logger;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('logger.factory')
->get('yamlform'));
}
/**
* Initialize form handler.
*
* @param \Drupal\yamlform\YamlFormInterface $yamlform
* A form object.
*
* @return $this
* This form handler.
*/
public function init(YamlFormInterface $yamlform) {
$this->yamlform = $yamlform;
return $this;
}
/**
* Get the form that this handler is attached to.
*
* @return \Drupal\yamlform\YamlFormInterface
* A form.
*/
public function getYamlForm() {
return $this->yamlform;
}
/**
* {@inheritdoc}
*/
public function getSummary() {
return [
'#theme' => 'yamlform_handler_' . $this->pluginId . '_summary',
'#settings' => $this->configuration,
'#handler' => [
'id' => $this->pluginDefinition['id'],
'handler_id' => $this
->getHandlerId(),
'label' => $this
->label(),
'description' => $this->pluginDefinition['description'],
],
];
}
/**
* {@inheritdoc}
*/
public function label() {
return $this
->getLabel();
}
/**
* {@inheritdoc}
*/
public function description() {
return $this->pluginDefinition['description'];
}
/**
* {@inheritdoc}
*/
public function cardinality() {
return $this->pluginDefinition['cardinality'];
}
/**
* {@inheritdoc}
*/
public function getHandlerId() {
return $this->handler_id;
}
/**
* {@inheritdoc}
*/
public function setHandlerId($handler_id) {
$this->handler_id = $handler_id;
return $this;
}
/**
* {@inheritdoc}
*/
public function setLabel($label) {
$this->label = $label;
return $this;
}
/**
* {@inheritdoc}
*/
public function getLabel() {
return $this->label ?: $this->pluginDefinition['label'];
}
/**
* {@inheritdoc}
*/
public function setStatus($status) {
$this->status = $status;
return $this;
}
/**
* {@inheritdoc}
*/
public function getStatus() {
return $this->status;
}
/**
* {@inheritdoc}
*/
public function setWeight($weight) {
$this->weight = $weight;
return $this;
}
/**
* {@inheritdoc}
*/
public function getWeight() {
return $this->weight;
}
/**
* {@inheritdoc}
*/
public function isEnabled() {
return $this->status ? TRUE : FALSE;
}
/**
* {@inheritdoc}
*/
public function isDisabled() {
return !$this
->isEnabled();
}
/**
* {@inheritdoc}
*/
public function getConfiguration() {
return [
'id' => $this
->getPluginId(),
'label' => $this
->getLabel(),
'handler_id' => $this
->getHandlerId(),
'status' => $this
->getStatus(),
'weight' => $this
->getWeight(),
'settings' => $this->configuration,
];
}
/**
* {@inheritdoc}
*/
public function setConfiguration(array $configuration) {
$configuration += [
'handler_id' => '',
'label' => '',
'status' => 1,
'weight' => '',
'settings' => [],
];
$this->configuration = $configuration['settings'] + $this
->defaultConfiguration();
$this->handler_id = $configuration['handler_id'];
$this->label = $configuration['label'];
$this->weight = $configuration['weight'];
$this->status = $configuration['status'];
return $this;
}
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
return [];
}
/**
* {@inheritdoc}
*/
public function calculateDependencies() {
return [];
}
/**
* {@inheritdoc}
*/
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
return $form;
}
/**
* {@inheritdoc}
*/
public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
}
/**
* {@inheritdoc}
*/
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
}
/**
* {@inheritdoc}
*/
public function alterElements(array &$elements, YamlFormInterface $yamlform) {
}
/**
* {@inheritdoc}
*/
public function alterForm(array &$form, FormStateInterface $form_state, YamlFormSubmissionInterface $yamlform_submission) {
}
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state, YamlFormSubmissionInterface $yamlform_submission) {
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state, YamlFormSubmissionInterface $yamlform_submission) {
}
/**
* {@inheritdoc}
*/
public function confirmForm(array &$form, FormStateInterface $form_state, YamlFormSubmissionInterface $yamlform_submission) {
}
/**
* {@inheritdoc}
*/
public function preCreate(array $values) {
}
/**
* {@inheritdoc}
*/
public function postCreate(YamlFormSubmissionInterface $yamlform_submission) {
}
/**
* {@inheritdoc}
*/
public function postLoad(YamlFormSubmissionInterface $yamlform_submission) {
}
/**
* {@inheritdoc}
*/
public function preDelete(YamlFormSubmissionInterface $yamlform_submission) {
}
/**
* {@inheritdoc}
*/
public function postDelete(YamlFormSubmissionInterface $yamlform_submission) {
}
/**
* {@inheritdoc}
*/
public function preSave(YamlFormSubmissionInterface $yamlform_submission) {
}
/**
* {@inheritdoc}
*/
public function postSave(YamlFormSubmissionInterface $yamlform_submission, $update = TRUE) {
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
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. | |
YamlFormHandlerBase:: |
protected | property | The form handler ID. | |
YamlFormHandlerBase:: |
protected | property | The form handler label. | |
YamlFormHandlerBase:: |
protected | property | A logger instance. | |
YamlFormHandlerBase:: |
protected | property | The form handler status. | |
YamlFormHandlerBase:: |
protected | property | The weight of the form handler. | |
YamlFormHandlerBase:: |
protected | property | The form . | |
YamlFormHandlerBase:: |
public | function |
Alter form submission form elements. Overrides YamlFormHandlerInterface:: |
1 |
YamlFormHandlerBase:: |
public | function |
Alter form submission form . Overrides YamlFormHandlerInterface:: |
1 |
YamlFormHandlerBase:: |
public | function |
Form constructor. Overrides PluginFormInterface:: |
3 |
YamlFormHandlerBase:: |
public | function |
Calculates dependencies for the configured plugin. Overrides DependentPluginInterface:: |
|
YamlFormHandlerBase:: |
public | function |
Returns the form handler cardinality settings. Overrides YamlFormHandlerInterface:: |
|
YamlFormHandlerBase:: |
public | function |
Confirm form submission form. Overrides YamlFormHandlerInterface:: |
1 |
YamlFormHandlerBase:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
2 |
YamlFormHandlerBase:: |
public | function |
Gets default configuration for this plugin. Overrides ConfigurablePluginInterface:: |
3 |
YamlFormHandlerBase:: |
public | function |
Returns the form handler description. Overrides YamlFormHandlerInterface:: |
|
YamlFormHandlerBase:: |
public | function |
Gets this plugin's configuration. Overrides ConfigurablePluginInterface:: |
|
YamlFormHandlerBase:: |
public | function |
Returns the unique ID representing the form handler. Overrides YamlFormHandlerInterface:: |
|
YamlFormHandlerBase:: |
public | function |
Returns the label of the form handler. Overrides YamlFormHandlerInterface:: |
|
YamlFormHandlerBase:: |
public | function |
Returns the status of the form handler. Overrides YamlFormHandlerInterface:: |
|
YamlFormHandlerBase:: |
public | function |
Returns a render array summarizing the configuration of the form handler. Overrides YamlFormHandlerInterface:: |
2 |
YamlFormHandlerBase:: |
public | function |
Returns the weight of the form handler. Overrides YamlFormHandlerInterface:: |
|
YamlFormHandlerBase:: |
public | function | Get the form that this handler is attached to. | |
YamlFormHandlerBase:: |
public | function | Initialize form handler. | |
YamlFormHandlerBase:: |
public | function |
Returns the form handler disabled indicator. Overrides YamlFormHandlerInterface:: |
|
YamlFormHandlerBase:: |
public | function |
Returns the form handler enabled indicator. Overrides YamlFormHandlerInterface:: |
1 |
YamlFormHandlerBase:: |
public | function |
Returns the form handler label. Overrides YamlFormHandlerInterface:: |
|
YamlFormHandlerBase:: |
public | function |
Acts on a form submission after it is created. Overrides YamlFormHandlerInterface:: |
1 |
YamlFormHandlerBase:: |
public | function |
Acts on deleted a form submission before the delete hook is invoked. Overrides YamlFormHandlerInterface:: |
2 |
YamlFormHandlerBase:: |
public | function |
Acts on loaded form submission. Overrides YamlFormHandlerInterface:: |
1 |
YamlFormHandlerBase:: |
public | function |
Acts on a saved form submission before the insert or update hook is invoked. Overrides YamlFormHandlerInterface:: |
3 |
YamlFormHandlerBase:: |
public | function |
Changes the values of an entity before it is created. Overrides YamlFormHandlerInterface:: |
1 |
YamlFormHandlerBase:: |
public | function |
Acts on a form submission before they are deleted and before hooks are invoked. Overrides YamlFormHandlerInterface:: |
1 |
YamlFormHandlerBase:: |
public | function |
Acts on a form submission before the presave hook is invoked. Overrides YamlFormHandlerInterface:: |
1 |
YamlFormHandlerBase:: |
public | function |
Sets the configuration for this plugin instance. Overrides ConfigurablePluginInterface:: |
|
YamlFormHandlerBase:: |
public | function |
Sets the id for this form handler. Overrides YamlFormHandlerInterface:: |
|
YamlFormHandlerBase:: |
public | function |
Sets the label for this form handler. Overrides YamlFormHandlerInterface:: |
|
YamlFormHandlerBase:: |
public | function |
Sets the status for this form handler. Overrides YamlFormHandlerInterface:: |
|
YamlFormHandlerBase:: |
public | function |
Sets the weight for this form handler. Overrides YamlFormHandlerInterface:: |
|
YamlFormHandlerBase:: |
public | function |
Form submission handler. Overrides PluginFormInterface:: |
3 |
YamlFormHandlerBase:: |
public | function |
Submit form submission form. Overrides YamlFormHandlerInterface:: |
3 |
YamlFormHandlerBase:: |
public | function |
Form validation handler. Overrides PluginFormInterface:: |
|
YamlFormHandlerBase:: |
public | function |
Validate form submission form . Overrides YamlFormHandlerInterface:: |
1 |
YamlFormHandlerBase:: |
public | function |
Constructs a \Drupal\Component\Plugin\PluginBase object. Overrides PluginBase:: |
2 |
YamlFormHandlerInterface:: |
constant | Value indicating a single plugin instances are permitted. | ||
YamlFormHandlerInterface:: |
constant | Value indicating unlimited plugin instances are permitted. | ||
YamlFormHandlerInterface:: |
constant | Value indicating form submissions are not processed (ie email or saved) by the handler. | ||
YamlFormHandlerInterface:: |
constant | Value indicating form submissions are processed (ie email or saved) by the handler. |