class BundleField in Display Suite 8.3
Same name in this branch
- 8.3 src/Plugin/Derivative/BundleField.php \Drupal\ds\Plugin\Derivative\BundleField
- 8.3 src/Plugin/DsField/BundleField.php \Drupal\ds\Plugin\DsField\BundleField
Same name and namespace in other branches
- 8.4 src/Plugin/Derivative/BundleField.php \Drupal\ds\Plugin\Derivative\BundleField
- 8.2 src/Plugin/Derivative/BundleField.php \Drupal\ds\Plugin\Derivative\BundleField
Provides a derivative for bundle fields.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\ds\Plugin\Derivative\BundleField implements ContainerDeriverInterface
Expanded class hierarchy of BundleField
File
- src/
Plugin/ Derivative/ BundleField.php, line 13
Namespace
Drupal\ds\Plugin\DerivativeView source
class BundleField extends DeriverBase implements ContainerDeriverInterface {
/**
* Stores all entity row plugin information.
*
* @var array
*/
protected $derivatives = [];
/**
* The base plugin ID that the derivative is for.
*
* @var string
*/
protected $basePluginId;
/**
* The entity manager.
*
* @var \Drupal\Core\Entity\EntityTypeManagerInterface
*/
protected $entityTypeManager;
/**
* Constructs a DsEntityRow object.
*
* @param string $base_plugin_id
* The base plugin ID.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity manager.
*/
public function __construct($base_plugin_id, EntityTypeManagerInterface $entity_type_manager) {
$this->basePluginId = $base_plugin_id;
$this->entityTypeManager = $entity_type_manager;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static($base_plugin_id, $container
->get('entity_type.manager'));
}
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
foreach ($this->entityTypeManager
->getDefinitions() as $entity_type_id => $entity_type) {
$base_table = $entity_type
->getBaseTable();
if ($entity_type
->get('field_ui_base_route') && !empty($base_table)) {
$this->derivatives[$entity_type_id] = $base_plugin_definition;
$this->derivatives[$entity_type_id] += [
'provider' => $entity_type_id,
'title' => 'Bundle name',
'entity_type' => $entity_type_id,
];
}
}
return $this->derivatives;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
BundleField:: |
protected | property | The base plugin ID that the derivative is for. | |
BundleField:: |
protected | property |
Stores all entity row plugin information. Overrides DeriverBase:: |
|
BundleField:: |
protected | property | The entity manager. | |
BundleField:: |
public static | function |
Creates a new class instance. Overrides ContainerDeriverInterface:: |
|
BundleField:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverBase:: |
|
BundleField:: |
public | function | Constructs a DsEntityRow object. | |
DeriverBase:: |
public | function |
Gets the definition of a derivative plugin. Overrides DeriverInterface:: |