Update core 8.3.0
This commit is contained in:
parent
da7a7918f8
commit
cd7a898e66
6144 changed files with 132297 additions and 87747 deletions
|
@ -5,47 +5,49 @@
|
|||
* Provide views data for comment.module.
|
||||
*/
|
||||
|
||||
use Drupal\Core\Entity\ContentEntityInterface;
|
||||
|
||||
/**
|
||||
* Implements hook_views_data_alter().
|
||||
*/
|
||||
function comment_views_data_alter(&$data) {
|
||||
// New comments are only supported for node table because it requires the
|
||||
// history table.
|
||||
$data['node']['new_comments'] = array(
|
||||
$data['node']['new_comments'] = [
|
||||
'title' => t('New comments'),
|
||||
'help' => t('The number of new comments on the node.'),
|
||||
'field' => array(
|
||||
'field' => [
|
||||
'id' => 'node_new_comments',
|
||||
'no group by' => TRUE,
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
// Provide a integration for each entity type except comment.
|
||||
foreach (\Drupal::entityManager()->getDefinitions() as $entity_type_id => $entity_type) {
|
||||
if ($entity_type_id == 'comment' || !$entity_type->isSubclassOf('\Drupal\Core\Entity\ContentEntityInterface') || !$entity_type->getBaseTable()) {
|
||||
if ($entity_type_id == 'comment' || !$entity_type->entityClassImplements(ContentEntityInterface::class) || !$entity_type->getBaseTable()) {
|
||||
continue;
|
||||
}
|
||||
$fields = \Drupal::service('comment.manager')->getFields($entity_type_id);
|
||||
$base_table = $entity_type->getDataTable() ?: $entity_type->getBaseTable();
|
||||
$args = array('@entity_type' => $entity_type_id);
|
||||
$args = ['@entity_type' => $entity_type_id];
|
||||
|
||||
if ($fields) {
|
||||
$data[$base_table]['comments_link'] = array(
|
||||
'field' => array(
|
||||
$data[$base_table]['comments_link'] = [
|
||||
'field' => [
|
||||
'title' => t('Add comment link'),
|
||||
'help' => t('Display the standard add comment link used on regular @entity_type, which will only display if the viewing user has access to add a comment.', $args),
|
||||
'id' => 'comment_entity_link',
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
// Multilingual properties are stored in data table.
|
||||
if (!($table = $entity_type->getDataTable())) {
|
||||
$table = $entity_type->getBaseTable();
|
||||
}
|
||||
$data[$table]['uid_touch'] = array(
|
||||
$data[$table]['uid_touch'] = [
|
||||
'title' => t('User posted or commented'),
|
||||
'help' => t('Display nodes only if a user posted the @entity_type or commented on the @entity_type.', $args),
|
||||
'argument' => array(
|
||||
'argument' => [
|
||||
'field' => 'uid',
|
||||
'name table' => 'users_field_data',
|
||||
'name field' => 'name',
|
||||
|
@ -53,40 +55,40 @@ function comment_views_data_alter(&$data) {
|
|||
'no group by' => TRUE,
|
||||
'entity_type' => $entity_type_id,
|
||||
'entity_id' => $entity_type->getKey('id'),
|
||||
),
|
||||
'filter' => array(
|
||||
],
|
||||
'filter' => [
|
||||
'field' => 'uid',
|
||||
'name table' => 'users_field_data',
|
||||
'name field' => 'name',
|
||||
'id' => 'comment_user_uid',
|
||||
'entity_type' => $entity_type_id,
|
||||
'entity_id' => $entity_type->getKey('id'),
|
||||
),
|
||||
);
|
||||
],
|
||||
];
|
||||
|
||||
foreach ($fields as $field_name => $field) {
|
||||
$data[$base_table][$field_name . '_cid'] = array(
|
||||
'title' => t('Comments of the @entity_type using field: @field_name', $args + array('@field_name' => $field_name)),
|
||||
$data[$base_table][$field_name . '_cid'] = [
|
||||
'title' => t('Comments of the @entity_type using field: @field_name', $args + ['@field_name' => $field_name]),
|
||||
'help' => t('Relate all comments on the @entity_type. This will create 1 duplicate record for every comment. Usually if you need this it is better to create a comment view.', $args),
|
||||
'relationship' => array(
|
||||
'relationship' => [
|
||||
'group' => t('Comment'),
|
||||
'label' => t('Comments'),
|
||||
'base' => 'comment_field_data',
|
||||
'base field' => 'entity_id',
|
||||
'relationship field' => $entity_type->getKey('id'),
|
||||
'id' => 'standard',
|
||||
'extra' => array(
|
||||
array(
|
||||
'extra' => [
|
||||
[
|
||||
'field' => 'entity_type',
|
||||
'value' => $entity_type_id,
|
||||
),
|
||||
array(
|
||||
],
|
||||
[
|
||||
'field' => 'field_name',
|
||||
'value' => $field_name,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Reference in a new issue