public function ViewsFieldTemplate::getDerivativeDefinitions in Calendar 8
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 DeriverInterface::getDerivativeDefinitions
See also
getDerivativeDefinition()
1 call to ViewsFieldTemplate::getDerivativeDefinitions()
- ViewsFieldTemplate::getDerivativeDefinition in src/
Plugin/ Derivative/ ViewsFieldTemplate.php - Gets the definition of a derivative plugin.
File
- src/
Plugin/ Derivative/ ViewsFieldTemplate.php, line 98
Class
- ViewsFieldTemplate
- Derivative class to find all field and properties for calendar View Builders.
Namespace
Drupal\calendar\Plugin\DerivativeCode
public function getDerivativeDefinitions($base_plugin_definition) {
/**
* @var \Drupal\Core\Entity\EntityTypeInterface $entity_type
*/
foreach ($this->entityManager
->getDefinitions() as $entity_type_id => $entity_type) {
// Just add support for entity types which have a views integration.
if (($base_table = $entity_type
->getBaseTable()) && $this->viewsData
->get($base_table) && $this->entityManager
->hasHandler($entity_type_id, 'view_builder')) {
$entity_views_tables = [
$base_table => $this->viewsData
->get($base_table),
];
if ($data_table = $entity_type
->getDataTable()) {
$entity_views_tables[$data_table] = $this->viewsData
->get($data_table);
}
foreach ($entity_views_tables as $table_id => $entity_views_table) {
foreach ($entity_views_table as $key => $field_info) {
if ($this
->isDateField($field_info)) {
$derivative = [
'replacements' => [
'entity_label' => $entity_type
->getLabel(),
'entity_type' => $entity_type_id,
'field_id' => $field_info['entity field'],
'base_table' => $table_id,
'base_field' => $this
->getTableBaseField($entity_views_table),
'default_field_id' => $this
->getTableDefaultField($entity_views_table, $entity_type_id),
'field_label' => $field_info['title'],
],
'view_template_id' => 'calendar_base_field',
];
$this
->setDerivative($derivative, $base_plugin_definition);
}
}
}
// @todo Loop through all fields attached to this entity type.
// The have different base tables that are joined to this table.
$this
->setConfigurableFieldsDerivatives($entity_type, $base_plugin_definition);
}
}
return $this->derivatives;
}