diff --cc core/modules/comment/lib/Drupal/comment/Controller/AdminController.php index 06fbee8,478d3be..0000000 --- a/core/modules/comment/lib/Drupal/comment/Controller/AdminController.php +++ b/core/modules/comment/lib/Drupal/comment/Controller/AdminController.php @@@ -12,6 -12,6 +12,7 @@@ use Drupal\field\FieldConfigInterface use Drupal\Component\Utility\String; use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Form\FormBuilderInterface; ++use Drupal\field\FieldInfo; use Drupal\field_ui\FieldUI; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\DependencyInjection\ContainerInterface; @@@ -29,19 -36,25 +30,27 @@@ class AdminController extends Controlle protected $commentManager; /** - * The form builder. + * Constructs an AdminController object. * - * @var \Drupal\Core\Form\FormBuilderInterface + * @param \Drupal\field\FieldInfo $field_info + * The field info service. + * @param \Drupal\comment\CommentManagerInterface $comment_manager + * The comment manager service. */ - protected $formBuilder; - public function __construct(FieldInfo $field_info, CommentManagerInterface $comment_manager) { - $this->fieldInfo = $field_info; ++ public function __construct(CommentManagerInterface $comment_manager, FieldInfo $field_info, FormBuilderInterface $form_builder) { + $this->commentManager = $comment_manager; ++ $this->fieldInfo = $field_info; ++ $this->formBuilder = $form_builder; + } /** * {@inheritdoc} */ public static function create(ContainerInterface $container) { return new static( + $container->get('comment.manager'), + $container->get('field.info'), - $container->get('comment.manager') + $container->get('form_builder') ); } @@@ -179,24 -174,62 +175,83 @@@ } /** + * Presents an administrative comment listing. + * + * @param \Symfony\Component\HttpFoundation\Request $request + * The request of the page. + * @param string $type + * The type of the overview form ('approval' or 'new') default to 'new'. + * + * @return array + * Then comment multiple delete confirmation form or the comments overview + * administration form. + */ + public function adminPage(Request $request, $type = 'new') { + if ($request->request->get('operation') == 'delete' && $request->request->get('comments')) { + return $this->formBuilder->getForm('\Drupal\comment\Form\ConfirmDeleteMultiple', $request); + } + else { + return $this->formBuilder->getForm('\Drupal\comment\Form\CommentAdminOverview', $type); + } + } + ++ /** + * Returns an overview of the entity types a comment field is attached to. + * + * @param string $commented_entity_type + * The entity type to which the comment field is attached. + * @param string $field_name + * The comment field for which the overview is to be displayed. + * + * @return array + * A renderable array containing the list of entity types and bundle + * combinations on which the comment field is in use. + */ + public function bundleInfo($commented_entity_type, $field_name) { + // Add a link to manage entity fields if the Field UI module is enabled. + $field_ui_enabled = $this->moduleHandler()->moduleExists('field_ui'); + + $field_info = $this->fieldInfo->getField($commented_entity_type, $field_name); + + $entity_type_info = $this->entityManager()->getDefinition($commented_entity_type); + $entity_bundle_info = $this->entityManager()->getBundleInfo($commented_entity_type); + + $build['usage'] = array( + '#theme' => 'item_list', + '#title' => String::checkPlain($entity_type_info->getLabel()), + '#items' => array(), + ); + // Loop over all of bundles to which this comment field is attached. + foreach ($field_info->getBundles() as $bundle) { + // Add the current instance to the list of bundles. + if ($field_ui_enabled && $route_info = FieldUI::getOverviewRouteInfo($commented_entity_type, $bundle)) { + // Add a link to configure the fields on the given bundle and entity + // type combination. + $build['usage']['#items'][] = $this->l($entity_bundle_info[$bundle]['label'], $route_info['route_name'], $route_info['route_parameters']); + } + else { + // Field UI is disabled so fallback to a list of bundle labels + // instead of links to configure fields. + $build['usage']['#items'][] = String::checkPlain($entity_bundle_info[$bundle]['label']); + } + } + + return $build; + } + + /** + * Route title callback. + * + * @param string $commented_entity_type + * The entity type to which the comment field is attached. + * @param string $field_name + * The comment field for which the overview is to be displayed. + * + * @return string + * The human readable field name. + */ + public function bundleTitle($commented_entity_type, $field_name) { + return $this->commentManager->getFieldUIPageTitle($commented_entity_type, $field_name); + } + } diff --git a/core/modules/comment/config/install/views.view.comment.yml b/core/modules/comment/config/install/views.view.comment.yml index b4a239f..311bde4 100644 --- a/core/modules/comment/config/install/views.view.comment.yml +++ b/core/modules/comment/config/install/views.view.comment.yml @@ -62,7 +62,6 @@ display: grouping: { } row_class: '' default_row_class: true - row_class_special: true override: true sticky: false caption: '' @@ -133,7 +132,7 @@ display: id: node table: comment field: node - required: 1 + required: true relationship: none group_type: group admin_label: Content @@ -241,8 +240,9 @@ display: hide_empty: false empty_zero: false hide_alter_empty: true - link_to_comment: 1 - link_to_entity: 0 + link_to_comment: true + link_to_entity: false + plugin_id: comment provider: comment name: id: name @@ -292,7 +292,7 @@ display: hide_empty: false empty_zero: false hide_alter_empty: true - link_to_user: 1 + link_to_user: true plugin_id: comment_username provider: comment title: @@ -343,7 +343,7 @@ display: hide_empty: false empty_zero: false hide_alter_empty: true - link_to_node: 1 + link_to_node: true plugin_id: node provider: node changed: @@ -448,8 +448,8 @@ display: empty_zero: false hide_alter_empty: true text: edit - link_to_entity: 0 - destination: 0 + link_to_entity: false + destination: false plugin_id: comment_link_edit provider: comment delete_comment: @@ -501,7 +501,7 @@ display: empty_zero: false hide_alter_empty: true text: delete - link_to_entity: 0 + link_to_entity: false plugin_id: comment_link_delete provider: comment translation_link: @@ -607,24 +607,25 @@ display: edit_comment: edit_comment delete_comment: delete_comment translation_link: translation_link - action_bulk_form: 0 - subject: 0 - name: 0 - title: 0 - changed: 0 - destination: 1 + action_bulk_form: '0' + subject: '0' + name: '0' + title: '0' + changed: '0' + destination: true plugin_id: dropbutton provider: views filters: status: - value: '1' + value: true table: comment field: status provider: comment id: status expose: operator: '' - group: '1' + group: 1 + plugin_id: boolean sorts: changed: id: changed @@ -697,8 +698,8 @@ display: group_type: group admin_label: '' operator: '=' - value: '0' - group: '1' + value: false + group: 1 exposed: false expose: operator_id: '' @@ -720,10 +721,11 @@ display: optional: true widget: select multiple: false - remember: 0 + remember: false default_group: All default_group_multiple: { } group_items: { } + plugin_id: boolean provider: comment defaults: filters: false @@ -837,8 +839,9 @@ display: hide_empty: false empty_zero: false hide_alter_empty: true - link_to_comment: 1 - link_to_entity: 0 + link_to_comment: true + link_to_entity: false + plugin_id: comment provider: comment name: id: name @@ -888,7 +891,7 @@ display: hide_empty: false empty_zero: false hide_alter_empty: true - link_to_user: 1 + link_to_user: true plugin_id: comment_username provider: comment title: @@ -939,7 +942,7 @@ display: hide_empty: false empty_zero: false hide_alter_empty: true - link_to_node: 1 + link_to_node: true plugin_id: node provider: node changed: @@ -1044,8 +1047,8 @@ display: empty_zero: false hide_alter_empty: true text: edit - link_to_entity: 0 - destination: 0 + link_to_entity: false + destination: false plugin_id: comment_link_edit provider: comment delete_comment: @@ -1097,7 +1100,7 @@ display: empty_zero: false hide_alter_empty: true text: delete - link_to_entity: 0 + link_to_entity: false plugin_id: comment_link_delete provider: comment translation_link: @@ -1203,16 +1206,22 @@ display: edit_comment: edit_comment delete_comment: delete_comment translation_link: translation_link - action_bulk_form: 0 - subject: 0 - name: 0 - title: 0 - changed: 0 - destination: 1 + action_bulk_form: '0' + subject: '0' + name: '0' + title: '0' + changed: '0' + destination: true plugin_id: dropbutton provider: views label: Comment module: views id: comment tag: '' +uuid: bf27f07e-b3e2-4460-b406-6e3610bada12 langcode: en +dependencies: + module: + - comment + - content_translation + - node diff --git a/core/modules/comment/config/schema/comment.schema.yml b/core/modules/comment/config/schema/comment.schema.yml index ae563c5..e30a37d 100644 --- a/core/modules/comment/config/schema/comment.schema.yml +++ b/core/modules/comment/config/schema/comment.schema.yml @@ -42,3 +42,7 @@ action.configuration.comment_unpublish_by_keyword_action: action.configuration.comment_unpublish_action: type: action_configuration_default label: 'Unpublish comment configuration' + +action.configuration.comment_delete_action: + type: action_configuration_default + label: 'Delete comment configuration' diff --git a/core/modules/comment/config/schema/comment.views.schema.yml b/core/modules/comment/config/schema/comment.views.schema.yml index 3a95f9d..5b0bfda 100644 --- a/core/modules/comment/config/schema/comment.views.schema.yml +++ b/core/modules/comment/config/schema/comment.views.schema.yml @@ -27,6 +27,20 @@ views.field.comment_entity_link: type: boolean label: 'Show teaser-style link' +views.field.comment_bulk_form: + type: views_field_bulk_form + label: 'Comment bulk form' + mapping: + include_exclude: + type: string + label: 'Available actions' + selected_actions: + type: sequence + label: 'Available actions' + sequence: + - type: string + label: 'Action' + views.field.comment_last_timestamp: type: views.field.date label: 'Last comment date' @@ -36,10 +50,10 @@ views.field.comment_link: label: 'Comment link' mapping: text: - type: views_field + type: string label: 'Text to display' link_to_entity: - type: views_field + type: boolean label: 'Link field to the entity if there is no comment.' views.field.comment_link_approve: diff --git a/core/modules/comment/lib/Drupal/comment/Plugin/views/field/CommentBulkForm.php b/core/modules/comment/lib/Drupal/comment/Plugin/views/field/CommentBulkForm.php index 584a569..dae4b7a 100644 --- a/core/modules/comment/lib/Drupal/comment/Plugin/views/field/CommentBulkForm.php +++ b/core/modules/comment/lib/Drupal/comment/Plugin/views/field/CommentBulkForm.php @@ -7,9 +7,7 @@ namespace Drupal\comment\Plugin\views\field; -use Drupal\Component\Annotation\PluginID; use Drupal\system\Plugin\views\field\BulkForm; -use Drupal\Core\Cache\Cache; use Drupal\Core\Entity\EntityManager; use Drupal\Core\Form\FormErrorInterface; @@ -23,7 +21,7 @@ class CommentBulkForm extends BulkForm { /** * Constructs a new CommentBulkForm object. */ - public function __construct(array $configuration, $plugin_id, array $plugin_definition, EntityManager $manager, EntityStorageInterface $storage, FormErrorInterface $form_builder) { + public function __construct(array $configuration, $plugin_id, array $plugin_definition, EntityManager $manager, FormErrorInterface $form_builder) { parent::__construct($configuration, $plugin_id, $plugin_definition, $manager, $form_builder); // Filter the actions to only include those for the 'comment' entity type. diff --git a/core/modules/node/tests/Drupal/node/Tests/Plugin/views/field/NodeBulkFormTest.php b/core/modules/node/tests/Drupal/node/Tests/Plugin/views/field/NodeBulkFormTest.php index 5deb7c5..07cb867 100644 --- a/core/modules/node/tests/Drupal/node/Tests/Plugin/views/field/NodeBulkFormTest.php +++ b/core/modules/node/tests/Drupal/node/Tests/Plugin/views/field/NodeBulkFormTest.php @@ -89,7 +89,8 @@ public function testConstructor() { $definition['title'] = ''; $options = array(); - $node_bulk_form = new NodeBulkForm(array(), 'node_bulk_form', $definition, $entity_storage); + $form_error = $this->getMock('Drupal\Core\Form\FormErrorInterface'); + $node_bulk_form = new NodeBulkForm(array(), 'node_bulk_form', $definition, $entity_storage, $form_error); $node_bulk_form->init($executable, $display, $options); $this->assertAttributeEquals(array_slice($actions, 0, -1, TRUE), 'actions', $node_bulk_form); diff --git a/core/modules/user/tests/Drupal/user/Tests/Plugin/views/field/UserBulkFormTest.php b/core/modules/user/tests/Drupal/user/Tests/Plugin/views/field/UserBulkFormTest.php index 642aacd..d3c1bb9 100644 --- a/core/modules/user/tests/Drupal/user/Tests/Plugin/views/field/UserBulkFormTest.php +++ b/core/modules/user/tests/Drupal/user/Tests/Plugin/views/field/UserBulkFormTest.php @@ -89,7 +89,8 @@ public function testConstructor() { $definition['title'] = ''; $options = array(); - $user_bulk_form = new UserBulkForm(array(), 'user_bulk_form', $definition, $entity_storage); + $form_error = $this->getMock('Drupal\Core\Form\FormErrorInterface'); + $user_bulk_form = new UserBulkForm(array(), 'user_bulk_form', $definition, $entity_storage, $form_error); $user_bulk_form->init($executable, $display, $options); $this->assertAttributeEquals(array_slice($actions, 0, -1, TRUE), 'actions', $user_bulk_form);