diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 76a17cf..8633af9 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -342,7 +342,7 @@ function comment_menu() { 'description' => 'Manage fields and displays settings for comment forms.', 'route_name' => 'comment_overview_bundles', ); - // @todo remove once routing start work with tabs. + // @todo Decide on better UX http://drupal.org/node/1901110 $items['admin/structure/comments/manage/%'] = array( 'title' => 'Comment form stub', 'access callback' => FALSE, @@ -1018,9 +1018,9 @@ function comment_view_multiple($comments, $view_mode = 'full', $langcode = NULL) } /** - * Implements hook_form_FORM_ID_alter() for field_ui_field_edit_form(). + * Implements hook_form_FORM_ID_alter() for field_ui_field_instance_edit_form(). */ -function comment_form_field_ui_field_edit_form_alter(&$form, $form_state) { +function comment_form_field_ui_field_instance_edit_form_alter(&$form, $form_state) { if ($form['#field']['type'] == 'comment') { // Collect translation settings. if (module_exists('translation_entity')) { @@ -1049,9 +1049,9 @@ function comment_form_field_ui_display_overview_form_alter(&$form, $form_state) } /** - * Implements hook_form_FORM_ID_alter() for field_ui_field_settings_form(). + * Implements hook_form_FORM_ID_alter() for field_ui_field_edit_form(). */ -function comment_form_field_ui_field_settings_form_alter(&$form, $form_state) { +function comment_form_field_ui_field_edit_form_alter(&$form, $form_state) { if ($form['#field']['type'] == 'comment') { // We only support posting one comment at the time so it doesn't make sense // to let the site builder choose anything else. commit 9c380303f238b49f9940c365568563595f5ffa31 Author: Andy Postnikov Date: Fri May 17 00:28:43 2013 +0300 Implement bundle page stub diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 8633af9..c89344f 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -342,10 +342,9 @@ function comment_menu() { 'description' => 'Manage fields and displays settings for comment forms.', 'route_name' => 'comment_overview_bundles', ); - // @todo Decide on better UX http://drupal.org/node/1901110 $items['admin/structure/comments/manage/%'] = array( - 'title' => 'Comment form stub', - 'access callback' => FALSE, + 'title' => 'Comment form', + 'route_name' => 'comment_bundle', ); $items['admin/content/comment'] = array( 'title' => 'Comments', diff --git a/core/modules/comment/comment.routing.yml b/core/modules/comment/comment.routing.yml index 182ad3b..afa08d6 100644 --- a/core/modules/comment/comment.routing.yml +++ b/core/modules/comment/comment.routing.yml @@ -10,3 +10,9 @@ comment_overview_bundles: _content: 'Drupal\comment\Controller\AdminController::overviewBundles' requirements: _permission: 'administer comments' +comment_bundle: + pattern: '/admin/structure/comments/manage/{field_name}' + defaults: + _content: 'Drupal\comment\Controller\AdminController::bundleInfo' + requirements: + _permission: 'administer comments' diff --git a/core/modules/comment/lib/Drupal/comment/Controller/AdminController.php b/core/modules/comment/lib/Drupal/comment/Controller/AdminController.php index b4b7f99..28a5627 100644 --- a/core/modules/comment/lib/Drupal/comment/Controller/AdminController.php +++ b/core/modules/comment/lib/Drupal/comment/Controller/AdminController.php @@ -153,4 +153,48 @@ public function overviewBundles() { return $build; } + /** + * Returns markup help text of comment bundle. + * + * @param string $field_name + * The comment field to attach fields. + * + * @return array + * Renderable array. + */ + public function bundleInfo($field_name) { + // @todo Decide on better UX http://drupal.org/node/1901110 + $build['usage'] = array( + '#theme' => 'item_list', + '#items' => array(), + ); + // @todo remove when entity_get_bundles() is a method on the entity manager. + $entity_bundles = entity_get_bundles(); + $entity_types = $this->entityManager->getDefinitions(); + $field_ui = $this->moduleHandler->moduleExists('field_ui'); + + $field_info = $this->fieldInfo->getField($field_name); + foreach ($field_info['bundles'] as $entity_type => $field_bundles) { + $bundles = array(); + foreach ($field_bundles as $bundle) { + if (isset($entity_bundles[$entity_type][$bundle])) { + // Add the current instance. + if ($field_ui && ($path = $this->entityManager->getAdminPath($entity_type, $bundle))) { + $bundles[] = l($entity_bundles[$entity_type][$bundle]['label'], $path . '/fields'); + } + else { + $bundles[] = $entity_bundles[$entity_type][$bundle]['label']; + } + } + } + // Format used entity bundles. + $build['usage']['#items'][] = t('@entity_type: !bundles', array( + '@entity_type' => $entity_types[$entity_type]['label'], + '!bundles' => implode(', ', $bundles), + )); + } + + return $build; + } + }