diff --git a/core/modules/comment/comment.install b/core/modules/comment/comment.install index 40fb1a0..9f1586f 100644 --- a/core/modules/comment/comment.install +++ b/core/modules/comment/comment.install @@ -25,7 +25,7 @@ function comment_uninstall() { */ function comment_install() { // By default, maintain entity statistics for comments. - // @see \Drupal\comment\CommentStorage::updateEntityStatistics(). + // @see \Drupal\comment\CommentStatisticsInterface \Drupal::state()->set('comment.maintain_entity_statistics', TRUE); } diff --git a/core/modules/comment/lib/Drupal/comment/CommentStorage.php b/core/modules/comment/lib/Drupal/comment/CommentStorage.php index 7f79673..27404e2 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentStorage.php +++ b/core/modules/comment/lib/Drupal/comment/CommentStorage.php @@ -23,43 +23,6 @@ class CommentStorage extends ContentEntityDatabaseStorage implements CommentStorageInterface { /** - * The comment statistics service. - * - * @var \Drupal\comment\CommentStatisticsInterface - */ - protected $statistics; - - /** - * Constructs a CommentStorage object. - * - * @param \Drupal\Core\Entity\EntityTypeInterface $entity_info - * An array of entity info for the entity type. - * @param \Drupal\Core\Database\Connection $database - * The database connection to be used. - * @param \Drupal\field\FieldInfo $field_info - * The field info service. - * @param \Drupal\comment\CommentStatisticsInterface $comment_statistics - * The comment statistics service. - */ - public function __construct(EntityTypeInterface $entity_info, Connection $database, FieldInfo $field_info, CommentStatisticsInterface $comment_statistics) { - parent::__construct($entity_info, $database, $field_info); - $this->statistics = $comment_statistics; - } - - /** - * {@inheritdoc} - */ - public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_info) { - return new static( - $entity_info, - $container->get('database'), - $container->get('field.info'), - $container->get('comment.statistics') - ); - } - - - /** * {@inheritdoc} */ protected function buildQuery($ids, $revision_id = FALSE) { @@ -85,13 +48,6 @@ protected function mapFromStorageRecords(array $records) { /** * {@inheritdoc} */ - public function updateEntityStatistics(CommentInterface $comment) { - $this->statistics->update($comment); - } - - /** - * {@inheritdoc} - */ public function getMaxThread(CommentInterface $comment) { $query = $this->database->select('comment', 'c') ->condition('entity_id', $comment->getCommentedEntityId()) diff --git a/core/modules/comment/lib/Drupal/comment/Entity/Comment.php b/core/modules/comment/lib/Drupal/comment/Entity/Comment.php index de10346..b78ee2f 100644 --- a/core/modules/comment/lib/Drupal/comment/Entity/Comment.php +++ b/core/modules/comment/lib/Drupal/comment/Entity/Comment.php @@ -145,7 +145,7 @@ public function postSave(EntityStorageInterface $storage, $update = TRUE) { $this->releaseThreadLock(); // Update the {comment_entity_statistics} table prior to executing the hook. - $storage->updateEntityStatistics($this); + \Drupal::service('comment.statistics')->update($this); if ($this->isPublished()) { \Drupal::moduleHandler()->invokeAll('comment_publish', array($this)); } @@ -171,7 +171,7 @@ public static function postDelete(EntityStorageInterface $storage, array $entiti entity_delete_multiple('comment', $child_cids); foreach ($entities as $id => $entity) { - $storage->updateEntityStatistics($entity); + \Drupal::service('comment.statistics')->update($entity); } }