diff --git a/core/modules/contact/contact.module b/core/modules/contact/contact.module index f6fc4cd..93a8ec0 100644 --- a/core/modules/contact/contact.module +++ b/core/modules/contact/contact.module @@ -7,6 +7,7 @@ use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Routing\RouteMatchInterface; +use Drupal\Core\Url; /** * Implements hook_help(). @@ -31,9 +32,13 @@ function contact_help($route_name, RouteMatchInterface $route_match) { return $output; case 'contact.form_list': - $output = '

' . t('Add one or more forms on this page to set up your site-wide contact form.', array('@form' => \Drupal::url('contact.site_page'))) . '

'; - $output .= '

' . t('A Contact menu item is added to the Footer menu, which you can modify on the Menus administration page.', array('@menu-settings' => \Drupal::url('menu_ui.overview_page'))) . '

'; + $output = '

' . t('Create seperate contact forms for different purposes.') . '

'; $output .= '

' . t('If you would like additional text to appear on the site-wide contact page, use a block. You can create and edit blocks on the Blocks administration page.', array('@blocks' => \Drupal::url('block.admin_display'))) . '

'; + if (\Drupal::moduleHandler()->moduleExists('block')) { + $output .= '

' . t('Each form gets a link in the Contact forms block. You can enable this block on the Block layout page.', array( + '@block' => Url::fromRoute('block.admin_display')->toString(), + )); + } return $output; } } diff --git a/core/modules/contact/src/ContactFormListBuilder.php b/core/modules/contact/src/ContactFormListBuilder.php index 369249a..6de4c27 100644 --- a/core/modules/contact/src/ContactFormListBuilder.php +++ b/core/modules/contact/src/ContactFormListBuilder.php @@ -20,15 +20,13 @@ */ class ContactFormListBuilder extends ConfigEntityListBuilder { - use LinkGeneratorTrait; - /** * {@inheritdoc} */ public function buildHeader() { $header['form'] = t('Form'); $header['recipients'] = t('Recipients'); - $header['selected'] = t('Selected'); + $header['default'] = t('Default'); return $header + parent::buildHeader(); } @@ -40,13 +38,13 @@ public function buildRow(EntityInterface $entity) { if ($entity->id() == 'personal') { $row['form'] = $this->getLabel($entity); $row['recipients'] = t('Selected user'); - $row['selected'] = t('No'); + $row['default'] = t('No'); } else { - $row['form'] = $this->l($this->getLabel($entity), Url::fromRoute('contact.site_page_form', ['contact_form' => $entity->id()])); + $row['form'] = $entity->link($this->getLabel($entity), 'submit-form'); $row['recipients'] = String::checkPlain(implode(', ', $entity->getRecipients())); $default_form = \Drupal::config('contact.settings')->get('default_form'); - $row['selected'] = ($default_form == $entity->id() ? t('Yes') : t('No')); + $row['default'] = ($default_form == $entity->id() ? t('Yes') : t('No')); } return $row + parent::buildRow($entity); } diff --git a/core/modules/contact/src/Entity/ContactForm.php b/core/modules/contact/src/Entity/ContactForm.php index 2dd7ce3..0cad8e3 100644 --- a/core/modules/contact/src/Entity/ContactForm.php +++ b/core/modules/contact/src/Entity/ContactForm.php @@ -7,9 +7,11 @@ namespace Drupal\contact\Entity; +use Drupal\Core\Cache\Cache; use Drupal\Core\Config\Entity\ConfigEntityBundleBase; use Drupal\contact\ContactFormInterface; use Drupal\Core\Config\Entity\ThirdPartySettingsTrait; +use Drupal\Core\Entity\EntityStorageInterface; /** * Defines the contact form entity. @@ -35,7 +37,8 @@ * }, * links = { * "delete-form" = "entity.contact_form.delete_form", - * "edit-form" = "entity.contact_form.edit_form" + * "edit-form" = "entity.contact_form.edit_form", + * "submit-form" = "contact.site_page_form", * } * ) */ diff --git a/core/modules/contact/src/Plugin/Block/ContactNavigationBlock.php b/core/modules/contact/src/Plugin/Block/ContactNavigationBlock.php index 9c3d709..fadbd93 100644 --- a/core/modules/contact/src/Plugin/Block/ContactNavigationBlock.php +++ b/core/modules/contact/src/Plugin/Block/ContactNavigationBlock.php @@ -216,15 +216,16 @@ public function build() { $links = []; /** @var \Drupal\contact\ContactFormInterface $contact_form */ foreach ($this->storage->loadMultiple(array_keys($this->configuration['forms'])) as $id => $contact_form) { - $links[$id] = [ - '#type' => 'link', - '#title' => $contact_form->label(), - '#url' => Url::fromRoute('contact.site_page_form', ['contact_form' => $id]), - ]; + $links[$id] = $contact_form->link($contact_form->label(), 'submit-form', [ + 'set_active_class' => TRUE, + ]); } return [ '#theme' => 'item_list__contact', '#items' => $links, + '#attributes' => [ + 'class' => ['menu'], + ] ]; }