abstract class WebformOptionsCustomDeriverBase in Webform 6.x
Same name and namespace in other branches
- 8.5 modules/webform_options_custom/src/Plugin/Derivative/WebformOptionsCustomDeriverBase.php \Drupal\webform_options_custom\Plugin\Derivative\WebformOptionsCustomDeriverBase
Provides base class for webform custom options derivers.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\webform_options_custom\Plugin\Derivative\WebformOptionsCustomDeriverBase implements ContainerDeriverInterface uses StringTranslationTrait, WebformEntityStorageTrait
Expanded class hierarchy of WebformOptionsCustomDeriverBase
File
- modules/
webform_options_custom/ src/ Plugin/ Derivative/ WebformOptionsCustomDeriverBase.php, line 15
Namespace
Drupal\webform_options_custom\Plugin\DerivativeView source
abstract class WebformOptionsCustomDeriverBase extends DeriverBase implements ContainerDeriverInterface {
use StringTranslationTrait;
use WebformEntityStorageTrait;
/**
* The type of custom element (element or entity_reference).
*
* @var string
*/
protected $type;
/**
* Constructs new WebformReusableCompositeDeriver.
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
*/
public function __construct(EntityTypeManagerInterface $entity_type_manager) {
$this->entityTypeManager = $entity_type_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static($container
->get('entity_type.manager'));
}
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
$webform_options_custom_entities = $this
->getEntityStorage('webform_options_custom')
->loadMultiple();
foreach ($webform_options_custom_entities as $webform_options_custom_entity) {
if ($webform_options_custom_entity
->get($this->type)) {
$this->derivatives[$webform_options_custom_entity
->id()] = $base_plugin_definition;
$this->derivatives[$webform_options_custom_entity
->id()]['label'] = $webform_options_custom_entity
->label() . ($this->type === 'entity_reference' ? ' ' . $this
->t('(Entity reference)') : '');
$this->derivatives[$webform_options_custom_entity
->id()]['description'] = $webform_options_custom_entity
->get('description');
}
}
return $this->derivatives;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DeriverBase:: |
protected | property | List of derivative definitions. | 1 |
DeriverBase:: |
public | function |
Gets the definition of a derivative plugin. Overrides DeriverInterface:: |
|
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. | |
WebformEntityStorageTrait:: |
protected | property | An associate array of entity type storage aliases. | |
WebformEntityStorageTrait:: |
protected | property | The entity type manager. | 5 |
WebformEntityStorageTrait:: |
protected | function | Retrieves the entity storage. | |
WebformEntityStorageTrait:: |
protected | function | Retrieves the webform submission storage. | |
WebformEntityStorageTrait:: |
protected | function | Retrieves the webform storage. | |
WebformEntityStorageTrait:: |
public | function | Implements the magic __get() method. | |
WebformOptionsCustomDeriverBase:: |
protected | property | The type of custom element (element or entity_reference). | 2 |
WebformOptionsCustomDeriverBase:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
WebformOptionsCustomDeriverBase:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |
|
WebformOptionsCustomDeriverBase:: |
public | function | Constructs new WebformReusableCompositeDeriver. |