public function DynamicField::getDerivativeDefinitions in Display Suite 8.2
Same name and namespace in other branches
- 8.4 src/Plugin/Derivative/DynamicField.php \Drupal\ds\Plugin\Derivative\DynamicField::getDerivativeDefinitions()
- 8.3 src/Plugin/Derivative/DynamicField.php \Drupal\ds\Plugin\Derivative\DynamicField::getDerivativeDefinitions()
Gets the definition of all derivatives of a base plugin.
Parameters
array $base_plugin_definition: The definition array of the base plugin.
Return value
array An array of full derivative definitions keyed on derivative id.
Overrides DeriverBase::getDerivativeDefinitions
See also
getDerivativeDefinition()
File
- src/
Plugin/ Derivative/ DynamicField.php, line 16
Class
- DynamicField
- Retrieves dynamic field plugin definitions.
Namespace
Drupal\ds\Plugin\DerivativeCode
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] += array(
'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;
}