diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 794e8d3..fb2f320 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -10,13 +10,11 @@ * book page, user etc. */ -use Drupal\Component\Utility\String; use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityChangedInterface; use Drupal\comment\CommentInterface; use Drupal\comment\Entity\Comment; use Drupal\entity\Entity\EntityDisplay; -use Drupal\field\Field; use Drupal\field\FieldInstanceInterface; use Drupal\field\FieldInterface; use Drupal\file\FileInterface; @@ -941,7 +939,7 @@ function comment_form_field_ui_field_instance_edit_form_alter(&$form, $form_stat */ function comment_form_field_ui_field_overview_form_alter(&$form, $form_state) { if ($form['#entity_type'] == 'comment') { - $form['#title'] = String::checkPlain($form['#bundle']); + $form['#title'] = \Drupal::service('comment.manager')->getFieldUIPageTitle($form['#bundle']); } } @@ -950,7 +948,7 @@ function comment_form_field_ui_field_overview_form_alter(&$form, $form_state) { */ function comment_form_field_ui_form_display_overview_form_alter(&$form, $form_state) { if ($form['#entity_type'] == 'comment') { - $form['#title'] = String::checkPlain($form['#bundle']); + $form['#title'] = \Drupal::service('comment.manager')->getFieldUIPageTitle($form['#bundle']); } } @@ -959,7 +957,7 @@ function comment_form_field_ui_form_display_overview_form_alter(&$form, $form_st */ function comment_form_field_ui_display_overview_form_alter(&$form, $form_state) { if ($form['#entity_type'] == 'comment') { - $form['#title'] = String::checkPlain($form['#bundle']); + $form['#title'] = \Drupal::service('comment.manager')->getFieldUIPageTitle($form['#bundle']); } } diff --git a/core/modules/comment/lib/Drupal/comment/CommentManager.php b/core/modules/comment/lib/Drupal/comment/CommentManager.php index 7e9458b..4b3ab0b 100644 --- a/core/modules/comment/lib/Drupal/comment/CommentManager.php +++ b/core/modules/comment/lib/Drupal/comment/CommentManager.php @@ -7,6 +7,7 @@ namespace Drupal\comment; +use Drupal\Component\Utility\String; use Drupal\field\FieldInfo; use Drupal\Core\Entity\EntityManager; @@ -222,4 +223,22 @@ 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. + */ + public function getFieldUIPageTitle($field_name) { + list($entity_type, $field) = explode('__', $field_name, 2); + $field_info = $this->fieldInfo->getField($entity_type, $field); + $bundles = $field_info->getBundles(); + $sample_bundle = reset($bundles); + $sample_instance = $this->fieldInfo->getInstance($entity_type, $sample_bundle, $field); + return String::checkPlain($sample_instance->label); + } + } diff --git a/core/modules/comment/lib/Drupal/comment/Controller/AdminController.php b/core/modules/comment/lib/Drupal/comment/Controller/AdminController.php index 2729272..4f49850 100644 --- a/core/modules/comment/lib/Drupal/comment/Controller/AdminController.php +++ b/core/modules/comment/lib/Drupal/comment/Controller/AdminController.php @@ -221,13 +221,7 @@ public function bundleInfo($field_name) { * The human readable field name. */ public function bundleTitle($field_name) { - // @todo Provide dynamic routing to get entity type and field name. - list($entity_type, $field) = explode('__', $field_name, 2); - $field_info = $this->fieldInfo->getField($entity_type, $field); - $bundles = $field_info->getBundles(); - $sample_bundle = reset($bundles); - $sample_instance = $this->fieldInfo->getInstance($entity_type, $sample_bundle, $field); - return String::checkPlain($sample_instance->label); + return $this->commentManager->getFieldUIPageTitle($field_name); } }