Mercurial > hg > cmmr2012-drupal-site
comparison core/modules/contact/contact.module @ 5:12f9dff5fda9 tip
Update to Drupal core 8.7.1
author | Chris Cannam |
---|---|
date | Thu, 09 May 2019 15:34:47 +0100 |
parents | c75dbcec494b |
children |
comparison
equal
deleted
inserted
replaced
4:a9cd425dd02b | 5:12f9dff5fda9 |
---|---|
3 /** | 3 /** |
4 * @file | 4 * @file |
5 * Enables the use of personal and site-wide contact forms. | 5 * Enables the use of personal and site-wide contact forms. |
6 */ | 6 */ |
7 | 7 |
8 use Drupal\Core\Url; | |
8 use Drupal\Core\Form\FormStateInterface; | 9 use Drupal\Core\Form\FormStateInterface; |
9 use Drupal\Core\Routing\RouteMatchInterface; | 10 use Drupal\Core\Routing\RouteMatchInterface; |
10 use Drupal\contact\Plugin\rest\resource\ContactMessageResource; | 11 use Drupal\contact\Plugin\rest\resource\ContactMessageResource; |
11 use Drupal\user\Entity\User; | 12 use Drupal\user\Entity\User; |
12 | 13 |
15 */ | 16 */ |
16 function contact_help($route_name, RouteMatchInterface $route_match) { | 17 function contact_help($route_name, RouteMatchInterface $route_match) { |
17 | 18 |
18 switch ($route_name) { | 19 switch ($route_name) { |
19 case 'help.page.contact': | 20 case 'help.page.contact': |
20 $menu_page = \Drupal::moduleHandler()->moduleExists('menu_ui') ? \Drupal::url('entity.menu.collection') : '#'; | 21 $menu_page = \Drupal::moduleHandler()->moduleExists('menu_ui') ? Url::fromRoute('entity.menu.collection')->toString() : '#'; |
21 $block_page = \Drupal::moduleHandler()->moduleExists('block') ? \Drupal::url('block.admin_display') : '#'; | 22 $block_page = \Drupal::moduleHandler()->moduleExists('block') ? Url::fromRoute('block.admin_display')->toString() : '#'; |
22 $contact_page = \Drupal::url('entity.contact_form.collection'); | 23 $contact_page = Url::fromRoute('entity.contact_form.collection')->toString(); |
23 $output = ''; | 24 $output = ''; |
24 $output .= '<h3>' . t('About') . '</h3>'; | 25 $output .= '<h3>' . t('About') . '</h3>'; |
25 $output .= '<p>' . t('The Contact module allows visitors to contact registered users on your site, using the personal contact form, and also allows you to set up site-wide contact forms. For more information, see the <a href=":contact">online documentation for the Contact module</a>.', [':contact' => 'https://www.drupal.org/documentation/modules/contact']) . '</p>'; | 26 $output .= '<p>' . t('The Contact module allows visitors to contact registered users on your site, using the personal contact form, and also allows you to set up site-wide contact forms. For more information, see the <a href=":contact">online documentation for the Contact module</a>.', [':contact' => 'https://www.drupal.org/documentation/modules/contact']) . '</p>'; |
26 $output .= '<h3>' . t('Uses') . '</h3>'; | 27 $output .= '<h3>' . t('Uses') . '</h3>'; |
27 $output .= '<dl>'; | 28 $output .= '<dl>'; |
121 | 122 |
122 $variables = [ | 123 $variables = [ |
123 '@site-name' => \Drupal::config('system.site')->get('name'), | 124 '@site-name' => \Drupal::config('system.site')->get('name'), |
124 '@subject' => $contact_message->getSubject(), | 125 '@subject' => $contact_message->getSubject(), |
125 '@form' => !empty($params['contact_form']) ? $params['contact_form']->label() : NULL, | 126 '@form' => !empty($params['contact_form']) ? $params['contact_form']->label() : NULL, |
126 '@form-url' => \Drupal::url('<current>', [], ['absolute' => TRUE, 'language' => $language]), | 127 '@form-url' => Url::fromRoute('<current>', [], ['absolute' => TRUE, 'language' => $language])->toString(), |
127 '@sender-name' => $sender->getDisplayName(), | 128 '@sender-name' => $sender->getDisplayName(), |
128 ]; | 129 ]; |
129 if ($sender->isAuthenticated()) { | 130 if ($sender->isAuthenticated()) { |
130 $variables['@sender-url'] = $sender->url('canonical', ['absolute' => TRUE, 'language' => $language]); | 131 $variables['@sender-url'] = $sender->toUrl('canonical', ['absolute' => TRUE, 'language' => $language])->toString(); |
131 } | 132 } |
132 else { | 133 else { |
133 $variables['@sender-url'] = $params['sender']->getEmail(); | 134 $variables['@sender-url'] = $params['sender']->getEmail(); |
134 } | 135 } |
135 | 136 |
151 | 152 |
152 case 'user_mail': | 153 case 'user_mail': |
153 case 'user_copy': | 154 case 'user_copy': |
154 $variables += [ | 155 $variables += [ |
155 '@recipient-name' => $params['recipient']->getDisplayName(), | 156 '@recipient-name' => $params['recipient']->getDisplayName(), |
156 '@recipient-edit-url' => $params['recipient']->url('edit-form', ['absolute' => TRUE, 'language' => $language]), | 157 '@recipient-edit-url' => $params['recipient']->toUrl('edit-form', ['absolute' => TRUE, 'language' => $language])->toString(), |
157 ]; | 158 ]; |
158 $message['subject'] .= t('[@site-name] @subject', $variables, $options); | 159 $message['subject'] .= t('[@site-name] @subject', $variables, $options); |
159 $message['body'][] = t('Hello @recipient-name,', $variables, $options); | 160 $message['body'][] = t('Hello @recipient-name,', $variables, $options); |
160 $message['body'][] = t("@sender-name (@sender-url) has sent you a message via your contact form at @site-name.", $variables, $options); | 161 $message['body'][] = t("@sender-name (@sender-url) has sent you a message via your contact form at @site-name.", $variables, $options); |
161 $message['body'][] = t("If you don't want to receive such emails, you can change your settings at @recipient-edit-url.", $variables, $options); | 162 $message['body'][] = t("If you don't want to receive such emails, you can change your settings at @recipient-edit-url.", $variables, $options); |