abstract class DynamicField in Display Suite 8.4
Same name and namespace in other branches
- 8.2 src/Plugin/Derivative/DynamicField.php \Drupal\ds\Plugin\Derivative\DynamicField
- 8.3 src/Plugin/Derivative/DynamicField.php \Drupal\ds\Plugin\Derivative\DynamicField
Retrieves dynamic field plugin definitions.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\ds\Plugin\Derivative\DynamicField
Expanded class hierarchy of DynamicField
File
- src/
Plugin/ Derivative/ DynamicField.php, line 11
Namespace
Drupal\ds\Plugin\DerivativeView source
abstract class DynamicField extends DeriverBase {
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
$custom_fields = \Drupal::configFactory()
->listAll('ds.field.');
foreach ($custom_fields as $config) {
$field = \Drupal::config($config)
->get();
if ($field['type'] == $this
->getType()) {
foreach ($field['entities'] as $entity_type) {
$key = $this
->getKey($entity_type, $field);
$this->derivatives[$key] = $base_plugin_definition;
$this->derivatives[$key] += [
'title' => \Drupal::translation()
->translate(Html::escape($field['label'])),
'properties' => $field['properties'],
'entity_type' => $entity_type,
];
if (!empty($field['ui_limit'])) {
$this->derivatives[$key]['ui_limit'] = explode("\n", $field['ui_limit']);
// Ensure that all strings are trimmed, eg. don't have extra spaces,
// \r chars etc.
foreach ($this->derivatives[$key]['ui_limit'] as $k => $v) {
$this->derivatives[$key]['ui_limit'][$k] = trim($v);
}
}
}
}
}
return $this->derivatives;
}
/**
* {@inheritdoc}
*/
protected function getType() {
return '';
}
/**
* {@inheritdoc}
*/
protected function getKey($entity_type, $field) {
return $entity_type . '-' . $field['id'];
}
}
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:: |
|
DynamicField:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |
|
DynamicField:: |
protected | function | ||
DynamicField:: |
protected | function | 4 |