FarmEntityBundlePluginHandler.php in farmOS 2.x
File
modules/core/entity/src/BundlePlugin/FarmEntityBundlePluginHandler.php
View source
<?php
namespace Drupal\farm_entity\BundlePlugin;
use Drupal\entity\BundlePlugin\BundlePluginHandler;
class FarmEntityBundlePluginHandler extends BundlePluginHandler {
public function getFieldStorageDefinitions() {
$definitions = [];
foreach (array_keys($this->pluginManager
->getDefinitions()) as $plugin_id) {
$definitions += \Drupal::moduleHandler()
->invokeAll('farm_entity_bundle_field_info', [
$this->entityType,
$plugin_id,
]);
}
foreach ($definitions as $field_name => $definition) {
$definition
->setName($field_name);
$definition
->setTargetEntityTypeId($this->entityType
->id());
$definitions[$field_name] = $definition;
}
$definitions += parent::getFieldStorageDefinitions();
return $definitions;
}
public function getFieldDefinitions($bundle) {
$definitions = \Drupal::moduleHandler()
->invokeAll('farm_entity_bundle_field_info', [
$this->entityType,
$bundle,
]);
foreach ($definitions as $field_name => $definition) {
$definition
->setName($field_name);
$definition
->setTargetEntityTypeId($this->entityType
->id());
$definition
->setTargetBundle($bundle);
$definitions[$field_name] = $definition;
}
$definitions += parent::getFieldDefinitions($bundle);
return $definitions;
}
}