From dd841bafef537159062f5c99a564b581264c18ee Mon Sep 17 00:00:00 2001 From: Nathaniel Catchpole Date: Fri, 20 Sep 2013 15:39:18 +0100 Subject: [PATCH] =?UTF-8?q?Issue=20#2093027=20by=20G=C3=A1bor=20Hojtsy:=20?= =?UTF-8?q?Fixed=20Regression:=20contact=20category=20titles=20not=20used?= =?UTF-8?q?=20for=20page=20title=20anymore.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/modules/contact/contact.pages.inc | 11 +++++++---- .../lib/Drupal/contact/Tests/ContactPersonalTest.php | 2 ++ .../lib/Drupal/contact/Tests/ContactSitewideTest.php | 3 +++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/core/modules/contact/contact.pages.inc b/core/modules/contact/contact.pages.inc index 491bb30ab5f..a851812636d 100644 --- a/core/modules/contact/contact.pages.inc +++ b/core/modules/contact/contact.pages.inc @@ -8,6 +8,7 @@ use Drupal\contact\Entity\Category; use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; +use Drupal\Component\Utility\String; /** * Page callback: Presents the site-wide contact form. @@ -53,7 +54,9 @@ function contact_site_page(Category $category = NULL) { $message = entity_create('contact_message', array( 'category' => $category->id(), )); - return \Drupal::entityManager()->getForm($message); + $form = \Drupal::entityManager()->getForm($message); + $form['#title'] = String::checkPlain($category->label()); + return $form; } /** @@ -79,13 +82,13 @@ function contact_personal_page($recipient) { contact_flood_control(); } - drupal_set_title(t('Contact @username', array('@username' => user_format_name($recipient))), PASS_THROUGH); - $message = entity_create('contact_message', array( 'recipient' => $recipient, 'category' => 'personal', )); - return \Drupal::entityManager()->getForm($message); + $form = \Drupal::entityManager()->getForm($message); + $form['#title'] = t('Contact @username', array('@username' => $recipient->getUsername())); + return $form; } /** diff --git a/core/modules/contact/lib/Drupal/contact/Tests/ContactPersonalTest.php b/core/modules/contact/lib/Drupal/contact/Tests/ContactPersonalTest.php index e974ec6a8ff..a6ca7f9371e 100644 --- a/core/modules/contact/lib/Drupal/contact/Tests/ContactPersonalTest.php +++ b/core/modules/contact/lib/Drupal/contact/Tests/ContactPersonalTest.php @@ -94,6 +94,8 @@ class ContactPersonalTest extends WebTestBase { $this->drupalLogin($this->web_user); $this->drupalGet('user/' . $this->admin_user->id() . '/contact'); $this->assertResponse(200); + // Check the page title is properly displayed. + $this->assertRaw(t('Contact @username', array('@username' => $this->admin_user->getUsername()))); // Test denied access to admin user's own contact form. $this->drupalLogout(); diff --git a/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php b/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php index 8a9e210335a..1c69c2e3577 100644 --- a/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php +++ b/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php @@ -126,6 +126,9 @@ class ContactSitewideTest extends WebTestBase { $this->assertEqual($config['reply'], $reply); $this->assertNotEqual($id, \Drupal::config('contact.settings')->get('default_category')); $this->assertRaw(t('Category %label has been updated.', array('%label' => $label))); + // Ensure the label is displayed on the contact page for this category. + $this->drupalGet('contact/' . $id); + $this->assertText($label); // Reset the category back to be the default category. \Drupal::config('contact.settings')->set('default_category', $id)->save();