diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/StringFormatter.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/StringFormatter.php index 82637c9..59bd1a0 100644 --- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/StringFormatter.php +++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldFormatter/StringFormatter.php @@ -170,8 +170,8 @@ protected function viewValue(FieldItemInterface $item) { * The URI elements of the entity. */ protected function getEntityUrl(EntityInterface $entity) { - // For the default revision this falls back to 'canonical'. - return $entity->urlInfo('revision'); + // For the default revision this falls back to 'canonical'. + return $entity->urlInfo('revision'); } } diff --git a/core/modules/comment/comment.install b/core/modules/comment/comment.install index a3bdb3f..7add6b9 100644 --- a/core/modules/comment/comment.install +++ b/core/modules/comment/comment.install @@ -119,22 +119,40 @@ function comment_schema() { */ /** - * Enable the comment admin view. + * Clear caches to fix Comment entity list builder and operations Views field. */ function comment_update_8001() { + // Empty update to cause a cache flush to rebuild comment entity handler + // information, so that comment operation links work. +} + +/** + * Enable the comment admin view. + */ +function comment_update_8002() { $module_handler = \Drupal::moduleHandler(); // Skip the update if views is not installed. if (!$module_handler->moduleExists('views')) { return; } + $entity_type_manager = \Drupal::entityTypeManager(); + // Save the comment admin view to config. $optional_install_path = drupal_get_path('module', 'comment') . '/' . InstallStorage::CONFIG_OPTIONAL_DIRECTORY; $storage = new FileStorage($optional_install_path); - \Drupal::entityManager() + $entity_type_manager ->getStorage('view') ->create($storage->read('views.view.comment')) ->save(); + + // Save the comment delete action to config. + $config_install_path = drupal_get_path('module', 'comment') . '/' . InstallStorage::CONFIG_INSTALL_DIRECTORY; + $storage = new FileStorage($config_install_path); + $entity_type_manager + ->getStorage('action') + ->create($storage->read('system.action.comment_delete_action')) + ->save(); } /** diff --git a/core/modules/comment/src/Entity/Comment.php b/core/modules/comment/src/Entity/Comment.php index 6679757..e2ab3d8 100644 --- a/core/modules/comment/src/Entity/Comment.php +++ b/core/modules/comment/src/Entity/Comment.php @@ -37,7 +37,6 @@ * "default" = "Drupal\comment\CommentForm", * "delete" = "Drupal\comment\Form\DeleteForm" * }, - * "list_builder" = "Drupal\Core\Entity\EntityListBuilder", * "translation" = "Drupal\comment\CommentTranslationHandler" * }, * base_table = "comment", diff --git a/core/modules/comment/src/Form/CommentAdminOverview.php b/core/modules/comment/src/Form/CommentAdminOverview.php index 74aa45b..87dce59 100644 --- a/core/modules/comment/src/Form/CommentAdminOverview.php +++ b/core/modules/comment/src/Form/CommentAdminOverview.php @@ -10,7 +10,7 @@ use Drupal\comment\CommentInterface; use Drupal\Component\Utility\Unicode; use Drupal\Core\Datetime\DateFormatterInterface; -use Drupal\Core\Entity\EntityManagerInterface; +use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Form\FormBase; use Drupal\Core\Form\FormStateInterface; @@ -23,11 +23,18 @@ class CommentAdminOverview extends FormBase { /** - * The entity storage. + * The entity type manager. * - * @var \Drupal\Core\Entity\EntityManagerInterface + * @var \Drupal\Core\Entity\EntityTypeManagerInterface */ - protected $entityManager; + protected $entityTypeManager; + + /** + * The comment storage. + * + * @var \Drupal\comment\CommentStorageInterface + */ + protected $commentStorage; /** * The date formatter service. @@ -53,7 +60,7 @@ class CommentAdminOverview extends FormBase { /** * Creates a CommentAdminOverview form. * - * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager + * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager * The entity manager service. * @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter * The date formatter service. @@ -62,9 +69,9 @@ class CommentAdminOverview extends FormBase { * @param \Drupal\user\PrivateTempStoreFactory $temp_store_factory * The tempstore factory. */ - public function __construct(EntityManagerInterface $entity_manager, DateFormatterInterface $date_formatter, ModuleHandlerInterface $module_handler, PrivateTempStoreFactory $temp_store_factory) { - $this->entityManager = $entity_manager; - $this->commentStorage = $entity_manager->getStorage('comment'); + public function __construct(EntityTypeManagerInterface $entity_type_manager, DateFormatterInterface $date_formatter, ModuleHandlerInterface $module_handler, PrivateTempStoreFactory $temp_store_factory) { + $this->entityTypeManager = $entity_type_manager; + $this->commentStorage = $entity_type_manager->getStorage('comment'); $this->dateFormatter = $date_formatter; $this->moduleHandler = $module_handler; $this->tempStoreFactory = $temp_store_factory; @@ -75,7 +82,7 @@ public function __construct(EntityManagerInterface $entity_manager, DateFormatte */ public static function create(ContainerInterface $container) { return new static( - $container->get('entity.manager'), + $container->get('entity_type.manager'), $container->get('date.formatter'), $container->get('module_handler'), $container->get('user.private_tempstore') @@ -119,6 +126,8 @@ public function buildForm(array $form, FormStateInterface $form_state, $type = ' $options['unpublish'] = $this->t('Unpublish the selected comments'); } $options['delete'] = $this->t('Delete the selected comments'); + module_load_install('comment'); + comment_update_8002(); $form['options']['operation'] = array( '#type' => 'select', @@ -177,7 +186,9 @@ public function buildForm(array $form, FormStateInterface $form_state, $type = ' } foreach ($commented_entity_ids as $entity_type => $ids) { - $commented_entities[$entity_type] = $this->entityManager->getStorage($entity_type)->loadMultiple($ids); + $commented_entities[$entity_type] = $this->entityTypeManager + ->getStorage($entity_type) + ->loadMultiple($ids); } foreach ($comments as $comment) { diff --git a/core/modules/comment/src/Tests/Views/CommentAdminTest.php b/core/modules/comment/src/Tests/Views/CommentAdminTest.php index 19b6116..546d96d 100644 --- a/core/modules/comment/src/Tests/Views/CommentAdminTest.php +++ b/core/modules/comment/src/Tests/Views/CommentAdminTest.php @@ -132,11 +132,11 @@ public function testApprovalAdminInterface() { $this->drupalGet('admin/content/comment'); $this->assertNoText(new HtmlEscapedText($this->node->label()), 'Comment admin cannot see the title of an unpublished node'); $this->drupalLogout(); - $this->nodeAccessUser = $this->drupalCreateUser(array( + $nodeAccessUser = $this->drupalCreateUser(array( 'administer comments', 'bypass node access' )); - $this->drupalLogin($this->nodeAccessUser); + $this->drupalLogin($nodeAccessUser); $this->drupalGet('admin/content/comment'); $this->assertText(new HtmlEscapedText($this->node->label()), 'Comment admin with bypass node access permissions can still see the title of a published node'); }