Update Composer, update everything
This commit is contained in:
parent
ea3e94409f
commit
dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions
|
@ -9,6 +9,7 @@ use Drupal\Component\Utility\NestedArray;
|
|||
use Drupal\Core\Entity\EntityStorageInterface;
|
||||
use Drupal\Core\Entity\Sql\SqlContentEntityStorage;
|
||||
use Drupal\Core\Render\Markup;
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\field\FieldConfigInterface;
|
||||
use Drupal\field\FieldStorageConfigInterface;
|
||||
use Drupal\system\ActionConfigEntityInterface;
|
||||
|
@ -170,7 +171,6 @@ function views_views_data() {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
// Field modules can implement hook_field_views_data() to override the default
|
||||
// behavior for adding fields.
|
||||
$module_handler = \Drupal::moduleHandler();
|
||||
|
@ -265,7 +265,7 @@ function views_entity_field_label($entity_type, $field_name) {
|
|||
// Sort the field labels by it most used label and return the most used one.
|
||||
// If the counts are equal, sort by the label to ensure the result is
|
||||
// deterministic.
|
||||
uksort($label_counter, function($a, $b) use ($label_counter) {
|
||||
uksort($label_counter, function ($a, $b) use ($label_counter) {
|
||||
if ($label_counter[$a] === $label_counter[$b]) {
|
||||
return strcmp($a, $b);
|
||||
}
|
||||
|
@ -352,6 +352,53 @@ function views_field_default_views_data(FieldStorageConfigInterface $field_stora
|
|||
];
|
||||
}
|
||||
|
||||
// Determine if the fields are translatable.
|
||||
$bundles_names = $field_storage->getBundles();
|
||||
$translation_join_type = FALSE;
|
||||
$fields = [];
|
||||
$translatable_configs = [];
|
||||
$untranslatable_configs = [];
|
||||
$untranslatable_config_bundles = [];
|
||||
|
||||
foreach ($bundles_names as $bundle) {
|
||||
$fields[$bundle] = FieldConfig::loadByName($entity_type->id(), $bundle, $field_name);
|
||||
}
|
||||
foreach ($fields as $bundle => $config_entity) {
|
||||
if (!empty($config_entity)) {
|
||||
if ($config_entity->isTranslatable()) {
|
||||
$translatable_configs[$bundle] = $config_entity;
|
||||
}
|
||||
else {
|
||||
$untranslatable_configs[$bundle] = $config_entity;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// https://www.drupal.org/node/2451657#comment-11462881
|
||||
\Drupal::logger('views')->error(
|
||||
'A non-existent config entity name returned by FieldStorageConfigInterface::getBundles(): entity type: %entity_type, bundle: %bundle, field name: %field',
|
||||
[
|
||||
'%entity_type' => $entity_type->id(),
|
||||
'%bundle' => $bundle,
|
||||
'%field' => $field_name,
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// If the field is translatable on all the bundles, there will be a join on
|
||||
// the langcode.
|
||||
if (!empty($translatable_configs) && empty($untranslatable_configs)) {
|
||||
$translation_join_type = 'language';
|
||||
}
|
||||
// If the field is translatable only on certain bundles, there will be a join
|
||||
// on langcode OR bundle name.
|
||||
elseif (!empty($translatable_configs) && !empty($untranslatable_configs)) {
|
||||
foreach ($untranslatable_configs as $config) {
|
||||
$untranslatable_config_bundles[] = $config->getTargetBundle();
|
||||
}
|
||||
$translation_join_type = 'language_bundle';
|
||||
}
|
||||
|
||||
// Build the relationships between the field table and the entity tables.
|
||||
$table_alias = $field_tables[EntityStorageInterface::FIELD_LOAD_CURRENT]['alias'];
|
||||
if ($data_table) {
|
||||
|
@ -362,7 +409,6 @@ function views_field_default_views_data(FieldStorageConfigInterface $field_stora
|
|||
'field' => 'entity_id',
|
||||
'extra' => [
|
||||
['field' => 'deleted', 'value' => 0, 'numeric' => TRUE],
|
||||
['left_field' => 'langcode', 'field' => 'langcode'],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
@ -378,6 +424,24 @@ function views_field_default_views_data(FieldStorageConfigInterface $field_stora
|
|||
];
|
||||
}
|
||||
|
||||
if ($translation_join_type === 'language_bundle') {
|
||||
$data[$table_alias]['table']['join'][$data_table]['join_id'] = 'field_or_language_join';
|
||||
$data[$table_alias]['table']['join'][$data_table]['extra'][] = [
|
||||
'left_field' => 'langcode',
|
||||
'field' => 'langcode',
|
||||
];
|
||||
$data[$table_alias]['table']['join'][$data_table]['extra'][] = [
|
||||
'field' => 'bundle',
|
||||
'value' => $untranslatable_config_bundles,
|
||||
];
|
||||
}
|
||||
elseif ($translation_join_type === 'language') {
|
||||
$data[$table_alias]['table']['join'][$data_table]['extra'][] = [
|
||||
'left_field' => 'langcode',
|
||||
'field' => 'langcode',
|
||||
];
|
||||
}
|
||||
|
||||
if ($supports_revisions) {
|
||||
$table_alias = $field_tables[EntityStorageInterface::FIELD_LOAD_REVISION]['alias'];
|
||||
if ($entity_revision_data_table) {
|
||||
|
@ -388,7 +452,6 @@ function views_field_default_views_data(FieldStorageConfigInterface $field_stora
|
|||
'field' => 'revision_id',
|
||||
'extra' => [
|
||||
['field' => 'deleted', 'value' => 0, 'numeric' => TRUE],
|
||||
['left_field' => 'langcode', 'field' => 'langcode'],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
@ -403,6 +466,23 @@ function views_field_default_views_data(FieldStorageConfigInterface $field_stora
|
|||
],
|
||||
];
|
||||
}
|
||||
if ($translation_join_type === 'language_bundle') {
|
||||
$data[$table_alias]['table']['join'][$entity_revision_data_table]['join_id'] = 'field_or_language_join';
|
||||
$data[$table_alias]['table']['join'][$entity_revision_data_table]['extra'][] = [
|
||||
'left_field' => 'langcode',
|
||||
'field' => 'langcode',
|
||||
];
|
||||
$data[$table_alias]['table']['join'][$entity_revision_data_table]['extra'][] = [
|
||||
'value' => $untranslatable_config_bundles,
|
||||
'field' => 'bundle',
|
||||
];
|
||||
}
|
||||
elseif ($translation_join_type === 'language') {
|
||||
$data[$table_alias]['table']['join'][$entity_revision_data_table]['extra'][] = [
|
||||
'left_field' => 'langcode',
|
||||
'field' => 'langcode',
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
$group_name = $entity_type->getLabel();
|
||||
|
|
Reference in a new issue