public function BundlePluginHandler::getFieldDefinitions in Entity API 8
Gets the field definitions for a specific bundle.
Parameters
string $bundle: The bundle name.
Return value
\Drupal\entity\BundleFieldDefinition[] An array of bundle field definitions, keyed by field name.
Overrides BundlePluginHandlerInterface::getFieldDefinitions
File
- src/
BundlePlugin/ BundlePluginHandler.php, line 87
Class
Namespace
Drupal\entity\BundlePluginCode
public function getFieldDefinitions($bundle) {
$plugin = $this->pluginManager
->createInstance($bundle);
assert($plugin instanceof BundlePluginInterface);
$definitions = $plugin
->buildFieldDefinitions();
// Ensure the presence of required keys which aren't set by the plugin.
foreach ($definitions as $field_name => $definition) {
$definition
->setName($field_name);
$definition
->setTargetEntityTypeId($this->entityType
->id());
$definition
->setTargetBundle($bundle);
$definitions[$field_name] = $definition;
}
return $definitions;
}