Commit dd841baf authored by catch's avatar catch

Issue #2093027 by Gábor Hojtsy: Fixed Regression: contact category titles not...

Issue #2093027 by Gábor Hojtsy: Fixed Regression: contact category titles not used for page title anymore.
parent 61e57550
......@@ -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;
}
/**
......
......@@ -94,6 +94,8 @@ function testPersonalContactAccess() {
$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();
......
......@@ -126,6 +126,9 @@ function testSiteWideContact() {
$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();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment