trait FormWidgetManagerTrait in Typed Data API enhancements 8
Helper to access the form widget manager service.
Hierarchy
- trait \Drupal\typed_data\Widget\FormWidgetManagerTrait
3 files declare their use of FormWidgetManagerTrait
- FormWidgetBrowserTestBase.php in tests/
src/ Functional/ TypedDataFormWidget/ FormWidgetBrowserTestBase.php - FormWidgetExampleController.php in tests/
modules/ typed_data_widget_test/ src/ FormWidgetExampleController.php - FormWidgetExampleForm.php in tests/
modules/ typed_data_widget_test/ src/ FormWidgetExampleForm.php
File
- src/
Widget/ FormWidgetManagerTrait.php, line 8
Namespace
Drupal\typed_data\WidgetView source
trait FormWidgetManagerTrait {
/**
* The widget manager.
*
* @var \Drupal\typed_data\Widget\FormWidgetManagerInterface
*/
protected $widgetManager;
/**
* Sets the widget manager.
*
* @param \Drupal\typed_data\Widget\FormWidgetManagerInterface $widgetManager
* The widget manager.
*
* @return $this
*/
public function setFormWidgetManager(FormWidgetManagerInterface $widgetManager) {
$this->widgetManager = $widgetManager;
return $this;
}
/**
* Gets the widget manager.
*
* @return \Drupal\typed_data\Widget\FormWidgetManagerInterface
* The widget manager.
*/
public function getFormWidgetManager() {
if (empty($this->widgetManager)) {
$this->widgetManager = \Drupal::service('plugin.manager.typed_data_form_widget');
}
return $this->widgetManager;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FormWidgetManagerTrait:: |
protected | property | The widget manager. | |
FormWidgetManagerTrait:: |
public | function | Gets the widget manager. | |
FormWidgetManagerTrait:: |
public | function | Sets the widget manager. |