diff --git a/core/modules/comment/lib/Drupal/comment/CommentManager.php b/core/modules/comment/lib/Drupal/comment/CommentManager.php index 4b3ab0b..5454a1b 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentManager.php +++ b/core/modules/comment/lib/Drupal/comment/CommentManager.php @@ -14,7 +14,7 @@ /** * Comment manager contains common functions to manage comment fields. */ -class CommentManager { +class CommentManager implements CommentManagerInterface { /** * The field info service. @@ -44,13 +44,7 @@ public function __construct(FieldInfo $field_info, EntityManager $entity_manager } /** - * Utility function to return URI of the comment's parent entity. - * - * @param \Drupal\comment\CommentInterface $comment - * The comment entity. - * - * @return array - * An array returned by \Drupal\Core\Entity\EntityInterface::uri(). + * {@inheritdoc} */ public function getParentEntityUri(CommentInterface $comment) { return $this->entityManager @@ -60,19 +54,7 @@ public function getParentEntityUri(CommentInterface $comment) { } /** - * Utility function to return an array of comment fields. - * - * @param string $entity_type - * The entity type to return fields which are attached on. - * - * @return array - * An array of comment field map definitions, keyed by field name. Each - * value is an array with two entries: - * - type: The field type. - * - bundles: The bundles in which the field appears, as an array with entity - * types as keys and the array of bundle names as values. - * - * @see field_info_field_map() + * {@inheritdoc} */ public function getFields($entity_type = NULL) { $map = $this->getAllFields(); @@ -83,7 +65,7 @@ public function getFields($entity_type = NULL) { } /** - * Utility function to return all comment fields. + * {@inheritdoc} */ public function getAllFields() { $map = $this->fieldInfo->getFieldMap(); @@ -100,20 +82,7 @@ public function getAllFields() { } /** - * Utility method to add the default comment field to an entity. - * - * Attaches a comment field named 'comment' to the given entity type and - * bundle. Largely replicates the default behaviour in Drupal 7 and earlier. - * - * @param string $entity_type - * The entity type to attach the default comment field to. - * @param string $bundle - * The bundle to attach the default comment field instance to. - * @param string $field_name - * (optional) Field name to use for the comment field. Defaults to 'comment'. - * @param int $default_value - * (optional) Default value, one of COMMENT_HIDDEN, COMMENT_OPEN, - * COMMENT_CLOSED. Defaults to COMMENT_OPEN. + * {@inheritdoc} */ public function addDefaultField($entity_type, $bundle, $field_name = 'comment', $default_value = COMMENT_OPEN) { // Make sure the field doesn't already exist. @@ -170,12 +139,7 @@ public function addDefaultField($entity_type, $bundle, $field_name = 'comment', } /** - * Creates a comment_body field instance. - * - * @param string $entity_type - * The type of the entity to which the comment field attached. - * @param string $field_name - * Name of the comment field to add comment_body field. + * {@inheritdoc} */ public function addBodyField($entity_type, $field_name) { // Create the field if needed. @@ -224,13 +188,7 @@ public function addBodyField($entity_type, $field_name) { } /** - * Builds human readable page title for field_ui management screens. - * - * @param string $field_name - * The comment field for which the overview is to be displayed. - * - * @return string - * The human readable field name. + * {@inheritdoc} */ public function getFieldUIPageTitle($field_name) { list($entity_type, $field) = explode('__', $field_name, 2); diff --git a/core/modules/comment/lib/Drupal/comment/CommentManagerInterface.php b/core/modules/comment/lib/Drupal/comment/CommentManagerInterface.php new file mode 100644 index 0000000..b4c16e3 --- /dev/null +++ b/core/modules/comment/lib/Drupal/comment/CommentManagerInterface.php @@ -0,0 +1,87 @@ +fieldInfo = $field_info; $this->commentManager = $comment_manager; } diff --git a/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php b/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php index 7775219..1c2ffa9 100644 --- a/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php +++ b/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php @@ -8,7 +8,7 @@ namespace Drupal\comment\Controller; use Drupal\comment\CommentInterface; -use Drupal\comment\CommentManager; +use Drupal\comment\CommentManagerInterface; use Drupal\field\FieldInfo; use Drupal\Core\Access\CsrfTokenGenerator; use Drupal\Core\Controller\ControllerBase; @@ -61,7 +61,7 @@ class CommentController extends ControllerBase implements ContainerInjectionInte /** * The comment manager service. * - * @var \Drupal\comment\CommentManager + * @var \Drupal\comment\CommentManagerInterface */ protected $commentManager; @@ -76,10 +76,10 @@ class CommentController extends ControllerBase implements ContainerInjectionInte * The current user service. * @param \Drupal\field\FieldInfo $field_info * Field Info service. - * @param \Drupal\comment\CommentManager $comment_manager + * @param \Drupal\comment\CommentManagerInterface $comment_manager * The comment manager service. */ - public function __construct(HttpKernelInterface $httpKernel, CsrfTokenGenerator $csrf_token, AccountInterface $current_user, FieldInfo $field_info, CommentManager $comment_manager) { + public function __construct(HttpKernelInterface $httpKernel, CsrfTokenGenerator $csrf_token, AccountInterface $current_user, FieldInfo $field_info, CommentManagerInterface $comment_manager) { $this->httpKernel = $httpKernel; $this->csrfToken = $csrf_token; $this->currentUser = $current_user; diff --git a/core/modules/comment/lib/Drupal/comment/Form/DeleteForm.php b/core/modules/comment/lib/Drupal/comment/Form/DeleteForm.php index 2c13db5..07f3146 100644 --- a/core/modules/comment/lib/Drupal/comment/Form/DeleteForm.php +++ b/core/modules/comment/lib/Drupal/comment/Form/DeleteForm.php @@ -7,7 +7,7 @@ namespace Drupal\comment\Form; -use Drupal\comment\CommentManager; +use Drupal\comment\CommentManagerInterface; use Drupal\Core\Cache\Cache; use Drupal\Core\Entity\ContentEntityConfirmFormBase; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -20,17 +20,17 @@ class DeleteForm extends ContentEntityConfirmFormBase { /** * The comment manager. * - * @var \Drupal\comment\CommentManager + * @var \Drupal\comment\CommentManagerInterface */ protected $commentManager; /** * Constructs a DeleteForm object. * - * @param \Drupal\comment\CommentManager $comment_manager + * @param \Drupal\comment\CommentManagerInterface $comment_manager * The comment manager service. */ - public function __construct(CommentManager $comment_manager) { + public function __construct(CommentManagerInterface $comment_manager) { $this->commentManager = $comment_manager; }