diff --git a/core/modules/comment/lib/Drupal/comment/CommentManager.php b/core/modules/comment/lib/Drupal/comment/CommentManager.php index 7548839..2f64cac 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentManager.php +++ b/core/modules/comment/lib/Drupal/comment/CommentManager.php @@ -13,6 +13,7 @@ use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\Query\QueryFactory; +use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Routing\UrlGeneratorInterface; use Drupal\Core\Session\AccountInterface; use Drupal\Core\StringTranslation\TranslationInterface; @@ -80,6 +81,13 @@ class CommentManager implements CommentManagerInterface { protected $urlGenerator; /** + * The module handler service. + * + * @var \Drupal\Core\Extension\ModuleHandlerInterface + */ + protected $moduleHandler; + + /** * Construct the CommentManager object. * * @param \Drupal\field\FieldInfo $field_info @@ -96,8 +104,10 @@ class CommentManager implements CommentManagerInterface { * The string translation service. * @param \Drupal\Core\Routing\UrlGeneratorInterface $url_generator * The url generator service. + * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler + * The module handler service. */ - public function __construct(FieldInfo $field_info, EntityManagerInterface $entity_manager, QueryFactory $query_factory, AccountInterface $current_user, ConfigFactoryInterface $config_factory, TranslationInterface $translation_manager, UrlGeneratorInterface $url_generator) { + public function __construct(FieldInfo $field_info, EntityManagerInterface $entity_manager, QueryFactory $query_factory, AccountInterface $current_user, ConfigFactoryInterface $config_factory, TranslationInterface $translation_manager, UrlGeneratorInterface $url_generator, ModuleHandlerInterface $module_handler) { $this->fieldInfo = $field_info; $this->entityManager = $entity_manager; $this->queryFactory = $query_factory; @@ -105,6 +115,7 @@ public function __construct(FieldInfo $field_info, EntityManagerInterface $entit $this->userConfig = $config_factory->get('user.settings'); $this->translationManager = $translation_manager; $this->urlGenerator = $url_generator; + $this->moduleHandler = $module_handler; } /** @@ -332,7 +343,7 @@ public function forbiddenMessage(EntityInterface $entity, $field_name) { public function getCountNewComments(EntityInterface $entity, $field_name = NULL, $timestamp = 0) { // @todo Replace module handler with optional history service injection // after http://drupal.org/node/2081585 - if ($this->currentUser->isAuthenticated() && \Drupal::moduleHandler()->moduleExists('history')) { + if ($this->currentUser->isAuthenticated() && $this->moduleHandler->moduleExists('history')) { // Retrieve the timestamp at which the current user last viewed this entity. if (!$timestamp) { if ($entity->getEntityTypeId() == 'node') { diff --git a/core/modules/comment/lib/Drupal/comment/CommentManagerInterface.php b/core/modules/comment/lib/Drupal/comment/CommentManagerInterface.php index c83f5ae..61c35f5 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentManagerInterface.php +++ b/core/modules/comment/lib/Drupal/comment/CommentManagerInterface.php @@ -8,8 +8,6 @@ namespace Drupal\comment; use Drupal\Core\Entity\EntityInterface; -use Drupal\Core\Session\AccountInterface; - use Drupal\comment\Plugin\Field\FieldType\CommentItemInterface; /** diff --git a/core/modules/forum/tests/Drupal/forum/Tests/ForumManagerTest.php b/core/modules/forum/tests/Drupal/forum/Tests/ForumManagerTest.php index ee52b0a..9429592 100644 --- a/core/modules/forum/tests/Drupal/forum/Tests/ForumManagerTest.php +++ b/core/modules/forum/tests/Drupal/forum/Tests/ForumManagerTest.php @@ -74,7 +74,7 @@ public function testGetIndex() { ->disableOriginalConstructor() ->getMock(); - $comment_manager = $this->getMockBuilder('\Drupal\comment\CommentManager') + $comment_manager = $this->getMockBuilder('\Drupal\comment\CommentManagerInterface') ->disableOriginalConstructor() ->getMock();