upgrades core to 8.4.2
This commit is contained in:
@@ -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;
|
||||
@@ -265,7 +266,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 +353,49 @@ 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(
|
||||
t('A non-existent config entity name returned by FieldStorageConfigInterface::getBundles(): field name: %field, bundle: %bundle',
|
||||
['%field' => $field_name, '%bundle' => $bundle]
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
// 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 +406,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 +421,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 +449,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 +463,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 New Issue
Block a user