abstract class AbstractFieldThirdPartySettingsFormEvent in Hook Event Dispatcher 3.x
Same name and namespace in other branches
- 8.2 modules/field_event_dispatcher/src/Event/Field/AbstractFieldThirdPartySettingsFormEvent.php \Drupal\field_event_dispatcher\Event\Field\AbstractFieldThirdPartySettingsFormEvent
Class AbstractFieldThirdPartySettingsFormEvent.
Hierarchy
- class \Drupal\field_event_dispatcher\Event\Field\AbstractFieldThirdPartySettingsFormEvent extends \Symfony\Component\EventDispatcher\Event implements EventInterface
Expanded class hierarchy of AbstractFieldThirdPartySettingsFormEvent
File
- modules/
field_event_dispatcher/ src/ Event/ Field/ AbstractFieldThirdPartySettingsFormEvent.php, line 14
Namespace
Drupal\field_event_dispatcher\Event\FieldView source
abstract class AbstractFieldThirdPartySettingsFormEvent extends Event implements EventInterface {
/**
* The field definition.
*
* @var \Drupal\Core\Field\FieldDefinitionInterface
*/
protected $fieldDefinition;
/**
* The (entire) configuration form array.
*
* @var array
*/
protected $form;
/**
* The form state.
*
* @var \Drupal\Core\Form\FormStateInterface
*/
protected $formState;
/**
* Third-party form elements to be added to the form.
*
* @var array
*/
protected $elements = [];
/**
* Get the field definition.
*
* @return \Drupal\Core\Field\FieldDefinitionInterface
* The field definition.
*/
public function getFieldDefintion() : FieldDefinitionInterface {
return $this->fieldDefinition;
}
/**
* Get the field definition.
*
* @deprecated in hook_event_dispatcher:2.6.0 and is removed from hook_event_dispatcher:3.0.0. Use
* getFieldDefinition() instead.
* @see https://www.drupal.org/project/hook_event_dispatcher/issues/3189252
*
* @return \Drupal\Core\Field\FieldDefinitionInterface
* The field definition.
*/
public function getFieldDefinition() : FieldDefinitionInterface {
return $this->fieldDefinition;
}
/**
* Get the (entire) configuration form array.
*
* @return array
* The entire form array.
*/
public function getForm() : array {
return $this->form;
}
/**
* Get the form state.
*
* @return \Drupal\Core\Form\FormStateInterface
* The form state.
*/
public function getFormState() : FormStateInterface {
return $this->formState;
}
/**
* Get the third-party form elements to be added to the form.
*
* @return array
* All third-party form elements that are to be added to this form.
*/
public function getElements() : array {
return $this->elements;
}
/**
* Add third-party form elements to the form.
*
* @param string $moduleName
* The machine name of the module to add the third-party form elements for.
* @param array $newElements
* An array containing the third-party form elements to add.
*
* @see \Drupal\field_event_dispatcher\EventSubscriber\Form\FormEntityViewDisplayEditAlterEventSubscriber::formAlter()
* Alters the form structure so that each module's third-party form elements
* are correctly nested only under their module machine names.
*/
public function addElements(string $moduleName, array $newElements) : void {
$this->elements = NestedArray::mergeDeep($this->elements, [
// Nest the new elements under the module's machine name for our form
// alter event subscriber.
$moduleName => $newElements,
]);
}
}