Update to drupal 8.0.0-rc1. For more information, see https://www.drupal.org/node/2582663

This commit is contained in:
Greg Anderson 2015-10-08 11:40:12 -07:00
parent eb34d130a8
commit f32e58e4b1
8476 changed files with 211648 additions and 170042 deletions

View file

@ -8,6 +8,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\FieldConfigInterface;
use Drupal\field\FieldStorageConfigInterface;
use Drupal\system\ActionConfigEntityInterface;
@ -449,7 +450,16 @@ function views_field_default_views_data(FieldStorageConfigInterface $field_stora
}
if ($aliases) {
$data[$table_alias][$field_alias]['aliases'] = $aliases;
$data[$table_alias][$field_alias]['help'] .= ' ' . t('Also known as: !also.', array('!also' => implode(', ', $also_known)));
// The $also_known variable contains markup that is HTML escaped and that
// loses safeness when imploded. The help text is used in #description
// and therefore XSS admin filtered by default. Escaped HTML is not
// altered by XSS filtering, therefore it is safe to just concatenate the
// strings. Afterwards we mark the entire string as safe, so it won't be
// escaped, no matter where it is used.
// Considering the dual use of this help data (both as metadata and as
// help text), other patterns such as use of #markup would not be correct
// here.
$data[$table_alias][$field_alias]['help'] = Markup::create($data[$table_alias][$field_alias]['help'] . ' ' . t('Also known as:') . ' ' . implode(', ', $also_known));
}
$keys = array_keys($field_columns);
@ -497,12 +507,12 @@ function views_field_default_views_data(FieldStorageConfigInterface $field_stora
}
if (count($field_columns) == 1 || $column == 'value') {
$title = t('@label (!name)', array('@label' => $label, '!name' => $field_name));
$title = t('@label (@name)', array('@label' => $label, '@name' => $field_name));
$title_short = $label;
}
else {
$title = t('@label (!name:!column)', array('@label' => $label, '!name' => $field_name, '!column' => $column));
$title_short = t('@label:!column', array('@label' => $label, '!column' => $column));
$title = t('@label (@name:@column)', array('@label' => $label, '@name' => $field_name, '@column' => $column));
$title_short = t('@label:@column', array('@label' => $label, '@column' => $column));
}
// Expose data for the property.
@ -535,10 +545,10 @@ function views_field_default_views_data(FieldStorageConfigInterface $field_stora
foreach ($all_labels as $label_name => $true) {
if ($label != $label_name) {
if (count($field_columns) == 1 || $column == 'value') {
$alias_title = t('@label (!name)', array('@label' => $label_name, '!name' => $field_name));
$alias_title = t('@label (@name)', array('@label' => $label_name, '@name' => $field_name));
}
else {
$alias_title = t('@label (!name:!column)', array('@label' => $label_name, '!name' => $field_name, '!column' => $column));
$alias_title = t('@label (@name:@column)', array('@label' => $label_name, '@name' => $field_name, '@column' => $column));
}
$aliases[] = array(
'group' => $group_name,
@ -550,7 +560,16 @@ function views_field_default_views_data(FieldStorageConfigInterface $field_stora
}
if ($aliases) {
$data[$table_alias][$column_real_name]['aliases'] = $aliases;
$data[$table_alias][$column_real_name]['help'] .= ' ' . t('Also known as: !also.', array('!also' => implode(', ', $also_known)));
// The $also_known variable contains markup that is HTML escaped and
// that loses safeness when imploded. The help text is used in
// #description and therefore XSS admin filtered by default. Escaped
// HTML is not altered by XSS filtering, therefore it is safe to just
// concatenate the strings. Afterwards we mark the entire string as
// safe, so it won't be escaped, no matter where it is used.
// Considering the dual use of this help data (both as metadata and as
// help text), other patterns such as use of #markup would not be
// correct here.
$data[$table_alias][$column_real_name]['help'] = Markup::create($data[$table_alias][$column_real_name]['help'] . ' ' . t('Also known as:') . ' ' . implode(', ', $also_known));
}
$data[$table_alias][$column_real_name]['argument'] = array(
@ -589,7 +608,7 @@ function views_field_default_views_data(FieldStorageConfigInterface $field_stora
// Expose additional delta column for multiple value fields.
if ($field_storage->isMultiple()) {
$title_delta = t('@label (!name:delta)', array('@label' => $label, '!name' => $field_name));
$title_delta = t('@label (@name:delta)', array('@label' => $label, '@name' => $field_name));
$title_short_delta = t('@label:delta', array('@label' => $label));
$data[$table_alias]['delta'] = array(
@ -633,3 +652,80 @@ function views_field_default_views_data(FieldStorageConfigInterface $field_stora
return $data;
}
/**
* Implements hook_field_views_data().
*
* The function implements the hook in behalf of 'core' because it adds a
* relationship and a reverse relationship to entity_reference field type, which
* is provided by core.
*/
function core_field_views_data(FieldStorageConfigInterface $field_storage) {
$data = views_field_default_views_data($field_storage);
// The code below only deals with the Entity reference field type.
if ($field_storage->getType() != 'entity_reference') {
return $data;
}
$entity_manager = \Drupal::entityManager();
$entity_type_id = $field_storage->getTargetEntityTypeId();
/** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */
$table_mapping = $entity_manager->getStorage($entity_type_id)->getTableMapping();
foreach ($data as $table_name => $table_data) {
// Add a relationship to the target entity type.
$target_entity_type_id = $field_storage->getSetting('target_type');
$target_entity_type = $entity_manager->getDefinition($target_entity_type_id);
$entity_type_id = $field_storage->getTargetEntityTypeId();
$entity_type = $entity_manager->getDefinition($entity_type_id);
$target_base_table = $target_entity_type->getDataTable() ?: $target_entity_type->getBaseTable();
$field_name = $field_storage->getName();
// Provide a relationship for the entity type with the entity reference
// field.
$args = array(
'@label' => $target_entity_type->getLabel(),
'@field_name' => $field_name,
);
$data[$table_name][$field_name]['relationship'] = array(
'title' => t('@label referenced from @field_name', $args),
'label' => t('@field_name: @label', $args),
'group' => $entity_type->getLabel(),
'help' => t('Appears in: @bundles.', array('@bundles' => implode(', ', $field_storage->getBundles()))),
'id' => 'standard',
'base' => $target_base_table,
'entity type' => $target_entity_type_id,
'base field' => $target_entity_type->getKey('id'),
'relationship field' => $field_name . '_target_id',
);
// Provide a reverse relationship for the entity type that is referenced by
// the field.
$args['@entity'] = $entity_type->getLabel();
$args['@label'] = $target_entity_type->getLowercaseLabel();
$pseudo_field_name = 'reverse__' . $entity_type_id . '__' . $field_name;
$data[$target_base_table][$pseudo_field_name]['relationship'] = array(
'title' => t('@entity using @field_name', $args),
'label' => t('@field_name', array('@field_name' => $field_name)),
'group' => $target_entity_type->getLabel(),
'help' => t('Relate each @entity with a @field_name set to the @label.', $args),
'id' => 'entity_reverse',
'base' => $entity_type->getDataTable() ?: $entity_type->getBaseTable(),
'entity_type' => $entity_type_id,
'base field' => $entity_type->getKey('id'),
'field_name' => $field_name,
'field table' => $table_mapping->getDedicatedDataTableName($field_storage),
'field field' => $field_name . '_target_id',
'join_extra' => array(
array(
'field' => 'deleted',
'value' => 0,
'numeric' => TRUE,
),
),
);
}
return $data;
}