public function FieldSource::getSourceFields in UI Patterns 8
Return list of source fields.
Return value
\Drupal\ui_patterns\Definition\PatternSourceField[] List of source fields.
Overrides PatternSourceInterface::getSourceFields
File
- src/
Plugin/ UiPatterns/ Source/ FieldSource.php, line 54
Class
- FieldSource
- Defines Fields API pattern source plugin.
Namespace
Drupal\ui_patterns\Plugin\UiPatterns\SourceCode
public function getSourceFields() {
$sources = [];
$fields = $this->entityFieldManager
->getFieldDefinitions($this
->getContextProperty('entity_type'), $this
->getContextProperty('entity_bundle'));
/** @var \Drupal\Core\Field\FieldDefinitionInterface $field */
foreach ($fields as $field) {
if (!$this
->getContextProperty('limit')) {
$sources[] = $this
->getSourceField($field
->getName(), $field
->getLabel());
}
elseif (in_array($field
->getName(), $this
->getContextProperty('limit'))) {
$sources[] = $this
->getSourceField($field
->getName(), $field
->getLabel());
}
}
return $sources;
}