Chris@0: t('New comments'), Chris@0: 'help' => t('The number of new comments on the node.'), Chris@0: 'field' => [ Chris@0: 'id' => 'node_new_comments', Chris@0: 'no group by' => TRUE, Chris@0: ], Chris@0: ]; Chris@0: Chris@0: // Provide a integration for each entity type except comment. Chris@0: foreach (\Drupal::entityManager()->getDefinitions() as $entity_type_id => $entity_type) { Chris@0: if ($entity_type_id == 'comment' || !$entity_type->entityClassImplements(ContentEntityInterface::class) || !$entity_type->getBaseTable()) { Chris@0: continue; Chris@0: } Chris@0: $fields = \Drupal::service('comment.manager')->getFields($entity_type_id); Chris@0: $base_table = $entity_type->getDataTable() ?: $entity_type->getBaseTable(); Chris@0: $args = ['@entity_type' => $entity_type_id]; Chris@0: Chris@0: if ($fields) { Chris@0: $data[$base_table]['comments_link'] = [ Chris@0: 'field' => [ Chris@0: 'title' => t('Add comment link'), Chris@0: '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), Chris@0: 'id' => 'comment_entity_link', Chris@0: ], Chris@0: ]; Chris@0: Chris@0: // Multilingual properties are stored in data table. Chris@0: if (!($table = $entity_type->getDataTable())) { Chris@0: $table = $entity_type->getBaseTable(); Chris@0: } Chris@0: $data[$table]['uid_touch'] = [ Chris@0: 'title' => t('User posted or commented'), Chris@0: 'help' => t('Display nodes only if a user posted the @entity_type or commented on the @entity_type.', $args), Chris@0: 'argument' => [ Chris@0: 'field' => 'uid', Chris@0: 'name table' => 'users_field_data', Chris@0: 'name field' => 'name', Chris@0: 'id' => 'argument_comment_user_uid', Chris@0: 'no group by' => TRUE, Chris@0: 'entity_type' => $entity_type_id, Chris@0: 'entity_id' => $entity_type->getKey('id'), Chris@0: ], Chris@0: 'filter' => [ Chris@0: 'field' => 'uid', Chris@0: 'name table' => 'users_field_data', Chris@0: 'name field' => 'name', Chris@0: 'id' => 'comment_user_uid', Chris@0: 'entity_type' => $entity_type_id, Chris@0: 'entity_id' => $entity_type->getKey('id'), Chris@0: ], Chris@0: ]; Chris@0: Chris@0: foreach ($fields as $field_name => $field) { Chris@0: $data[$base_table][$field_name . '_cid'] = [ Chris@0: 'title' => t('Comments of the @entity_type using field: @field_name', $args + ['@field_name' => $field_name]), Chris@0: '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), Chris@0: 'relationship' => [ Chris@0: 'group' => t('Comment'), Chris@0: 'label' => t('Comments'), Chris@0: 'base' => 'comment_field_data', Chris@0: 'base field' => 'entity_id', Chris@0: 'relationship field' => $entity_type->getKey('id'), Chris@0: 'id' => 'standard', Chris@0: 'extra' => [ Chris@0: [ Chris@0: 'field' => 'entity_type', Chris@0: 'value' => $entity_type_id, Chris@0: ], Chris@0: [ Chris@0: 'field' => 'field_name', Chris@0: 'value' => $field_name, Chris@0: ], Chris@0: ], Chris@0: ], Chris@0: ]; Chris@0: } Chris@0: } Chris@0: } Chris@0: }