diff --git a/core/modules/config_translation/src/Tests/ConfigTranslationListUiTest.php b/core/modules/config_translation/src/Tests/ConfigTranslationListUiTest.php index 444274b..f6f5954 100644 --- a/core/modules/config_translation/src/Tests/ConfigTranslationListUiTest.php +++ b/core/modules/config_translation/src/Tests/ConfigTranslationListUiTest.php @@ -208,7 +208,7 @@ public function doCustomContentTypeListTest() { public function doContactFormsListTest() { // Create a test contact form to decouple looking for translate operations // link so this does not test more than necessary. - $contact_form = entity_create('contact_category', array( + $contact_form = entity_create('contact_form', array( 'id' => Unicode::strtolower($this->randomMachineName(16)), 'label' => $this->randomMachineName(), )); diff --git a/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php b/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php index 9253420..7a8f7e0 100644 --- a/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php +++ b/core/modules/config_translation/src/Tests/ConfigTranslationUiTest.php @@ -228,7 +228,7 @@ public function testSourceValueDuplicateSave() { } /** - * Tests the contact category translation. + * Tests the contact form translation. */ public function testContactConfigEntityTranslation() { $this->drupalLogin($this->admin_user); @@ -268,15 +268,15 @@ public function testContactConfigEntityTranslation() { // Update translatable fields. $edit = array( - 'config_names[contact.category.feedback][label][translation]' => 'Website feedback - ' . $langcode, - 'config_names[contact.category.feedback][reply][translation]' => 'Thank you for your mail - ' . $langcode, + 'config_names[contact.form.feedback][label][translation]' => 'Website feedback - ' . $langcode, + 'config_names[contact.form.feedback][reply][translation]' => 'Thank you for your mail - ' . $langcode, ); // Save language specific version of form. $this->drupalPostForm($translation_page_url, $edit, t('Save translation')); // Expect translated values in language specific file. - $override = \Drupal::languageManager()->getLanguageConfigOverride($langcode, 'contact.category.feedback'); + $override = \Drupal::languageManager()->getLanguageConfigOverride($langcode, 'contact.form.feedback'); $expected = array( 'label' => 'Website feedback - ' . $langcode, 'reply' => 'Thank you for your mail - ' . $langcode, @@ -307,7 +307,7 @@ public function testContactConfigEntityTranslation() { $langcode_prefixes = array_merge(array(''), $this->langcodes); foreach ($langcode_prefixes as $langcode_prefix) { $this->drupalGet(ltrim("$langcode_prefix/$translation_base_url/$langcode/edit")); - $this->assertFieldByName('config_names[contact.category.feedback][label][translation]', 'Website feedback - ' . $langcode); + $this->assertFieldByName('config_names[contact.form.feedback][label][translation]', 'Website feedback - ' . $langcode); $this->assertText($label); } } @@ -325,7 +325,7 @@ public function testContactConfigEntityTranslation() { // Test that delete links work and operations perform properly. foreach ($this->langcodes as $langcode) { - $replacements = array('%label' => t('!label !entity_type', array('!label' => $label, '!entity_type' => Unicode::strtolower(t('Contact category')))), '@language' => language_load($langcode)->name); + $replacements = array('%label' => t('!label !entity_type', array('!label' => $label, '!entity_type' => Unicode::strtolower(t('Contact form')))), '@language' => language_load($langcode)->name); $this->drupalGet("$translation_base_url/$langcode/delete"); $this->assertRaw(t('Are you sure you want to delete the @language translation of %label?', $replacements)); @@ -339,7 +339,7 @@ public function testContactConfigEntityTranslation() { $this->assertNoLinkByHref("$translation_base_url/$langcode/delete"); // Expect no language specific file present anymore. - $override = \Drupal::languageManager()->getLanguageConfigOverride($langcode, 'contact.category.feedback'); + $override = \Drupal::languageManager()->getLanguageConfigOverride($langcode, 'contact.form.feedback'); $this->assertTrue($override->isNew()); } diff --git a/core/modules/contact/config/install/contact.category.feedback.yml b/core/modules/contact/config/install/contact.form.feedback.yml similarity index 100% rename from core/modules/contact/config/install/contact.category.feedback.yml rename to core/modules/contact/config/install/contact.form.feedback.yml diff --git a/core/modules/contact/config/install/contact.category.personal.yml b/core/modules/contact/config/install/contact.form.personal.yml similarity index 100% rename from core/modules/contact/config/install/contact.category.personal.yml rename to core/modules/contact/config/install/contact.form.personal.yml diff --git a/core/modules/contact/config/install/contact.settings.yml b/core/modules/contact/config/install/contact.settings.yml index 28c760a..f4ae0c2 100644 --- a/core/modules/contact/config/install/contact.settings.yml +++ b/core/modules/contact/config/install/contact.settings.yml @@ -1,4 +1,4 @@ -default_category: feedback +default_form: feedback flood: limit: 5 interval: 3600 diff --git a/core/modules/contact/config/schema/contact.schema.yml b/core/modules/contact/config/schema/contact.schema.yml index 0ef4c2e..7ebb6f4 100644 --- a/core/modules/contact/config/schema/contact.schema.yml +++ b/core/modules/contact/config/schema/contact.schema.yml @@ -1,8 +1,8 @@ # Schema for the configuration files of the Contact module. -contact.category.*: +contact.form.*: type: config_entity - label: 'Contact category' + label: 'Contact form' mapping: id: type: string @@ -27,9 +27,9 @@ contact.settings: type: mapping label: 'Contact settings' mapping: - default_category: + default_form: type: string - label: 'Default category identifier' + label: 'Default form identifier' flood: type: mapping label: 'Flood control' diff --git a/core/modules/contact/contact.info.yml b/core/modules/contact/contact.info.yml index 647bc15..a50d17d 100644 --- a/core/modules/contact/contact.info.yml +++ b/core/modules/contact/contact.info.yml @@ -4,4 +4,4 @@ description: 'Enables the use of both personal and site-wide contact forms.' package: Core version: VERSION core: 8.x -configure: contact.category_list +configure: contact.form_list diff --git a/core/modules/contact/contact.install b/core/modules/contact/contact.install index 477f359..dbe3397 100644 --- a/core/modules/contact/contact.install +++ b/core/modules/contact/contact.install @@ -15,11 +15,11 @@ function contact_install() { if (empty($site_mail)) { $site_mail = ini_get('sendmail_from'); } - $config = \Drupal::config('contact.category.feedback'); + $config = \Drupal::config('contact.form.feedback'); // Update the recipients if the default configuration entity has been created. // We should never rely on default config entities as during enabling a module // during config sync they will not exist. if (!$config->isNew()) { - \Drupal::config('contact.category.feedback')->set('recipients', array($site_mail))->save(); + \Drupal::config('contact.form.feedback')->set('recipients', array($site_mail))->save(); } } diff --git a/core/modules/contact/contact.links.action.yml b/core/modules/contact/contact.links.action.yml index c917e7f..78e139a 100644 --- a/core/modules/contact/contact.links.action.yml +++ b/core/modules/contact/contact.links.action.yml @@ -1,6 +1,6 @@ -contact.category_add: - route_name: contact.category_add - title: 'Add category' +contact.form_add: + route_name: contact.form_add + title: 'Add contact form' weight: 1 appears_on: - - contact.category_list + - contact.form_list diff --git a/core/modules/contact/contact.links.menu.yml b/core/modules/contact/contact.links.menu.yml index 8091f1f..92c15d0 100644 --- a/core/modules/contact/contact.links.menu.yml +++ b/core/modules/contact/contact.links.menu.yml @@ -1,8 +1,8 @@ -contact.category_list: - title: 'Contact form categories' +contact.form_list: + title: 'Contact forms' parent: system.admin_structure - description: 'Create a system contact form and set up categories for the form to use.' - route_name: contact.category_list + description: 'Create and manage contact forms.' + route_name: contact.form_list contact.site_page: title: Contact route_name: contact.site_page diff --git a/core/modules/contact/contact.links.task.yml b/core/modules/contact/contact.links.task.yml index 687ade5..e391015 100644 --- a/core/modules/contact/contact.links.task.yml +++ b/core/modules/contact/contact.links.task.yml @@ -1,7 +1,7 @@ -entity.contact_category.edit_form: +entity.contact_form.edit_form: title: 'Edit' - route_name: entity.contact_category.edit_form - base_route: entity.contact_category.edit_form + route_name: entity.contact_form.edit_form + base_route: entity.contact_form.edit_form contact.personal_page: title: 'Contact' diff --git a/core/modules/contact/contact.module b/core/modules/contact/contact.module index 2856fa0..129d42a 100644 --- a/core/modules/contact/contact.module +++ b/core/modules/contact/contact.module @@ -22,7 +22,7 @@ function contact_help($route_name, RouteMatchInterface $route_match) { $output .= '
' . t('User contact forms') . '
'; $output .= '
' . t('Site users can be contacted with a user contact form that keeps their email address private. Users may enable or disable their personal contact forms by editing their My account page. If enabled, a Contact tab leads to a personal contact form displayed on their user profile. Site administrators are still able to use the contact form, even if has been disabled. The Contact tab is not shown when you view your own profile.') . '
'; $output .= '
' . t('Site-wide contact forms') . '
'; - $output .= '
' . t('The Contact page provides a simple form for users with the Use the site-wide contact form permission to send comments, feedback, or other requests. You can create categories for directing the contact form messages to a set of defined recipients. Common categories for a business site, for example, might include "Website feedback" (messages are forwarded to website administrators) and "Product information" (messages are forwarded to members of the sales department). Email addresses defined within a category are not displayed publicly.', array('@contact' => url('contact'))) . '

'; + $output .= '
' . t('The Contact page provides a simple form for users with the Use the site-wide contact form permission to send comments, feedback, or other requests. You can create forms for directing the contact messages to a set of defined recipients. Common forms for a business site, for example, might include "Website feedback" (messages are forwarded to website administrators) and "Product information" (messages are forwarded to members of the sales department). Email addresses defined within a form are not displayed publicly.', array('@contact' => url('contact'))) . '

'; $output .= '
' . t('Navigation') . '
'; $output .= '
' . t('When the site-wide contact form is enabled, a link in the Footer menu is created, which you can modify on the Menus administration page.', array('@menu' => url('admin/structure/menu'))) . '
'; $output .= '
' . t('Customization') . '
'; @@ -30,8 +30,8 @@ function contact_help($route_name, RouteMatchInterface $route_match) { $output .= ''; return $output; - case 'contact.category_list': - $output = '

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

'; + case 'contact.form_list': + $output = '

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

'; $output .= '

' . t('A Contact menu item is added to the Footer menu, which you can modify on the Menus administration page.', array('@menu-settings' => url('admin/structure/menu'))) . '

'; $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' => url('admin/structure/block'))) . '

'; return $output; @@ -113,7 +113,7 @@ function contact_mail($key, &$message, $params) { $variables = array( '!site-name' => \Drupal::config('system.site')->get('name'), '!subject' => $contact_message->getSubject(), - '!category' => !empty($params['contact_category']) ? $params['contact_category']->label() : NULL, + '!form' => !empty($params['contact_form']) ? $params['contact_form']->label() : NULL, '!form-url' => url(current_path(), array('absolute' => TRUE, 'language' => $language)), '!sender-name' => user_format_name($sender), ); @@ -129,15 +129,15 @@ function contact_mail($key, &$message, $params) { switch ($key) { case 'page_mail': case 'page_copy': - $message['subject'] .= t('[!category] !subject', $variables, $options); + $message['subject'] .= t('[!form] !subject', $variables, $options); $message['body'][] = t("!sender-name (!sender-url) sent a message using the contact form at !form-url.", $variables, $options); $build = entity_view($contact_message, 'mail', $language->id); $message['body'][] = drupal_render($build); break; case 'page_autoreply': - $message['subject'] .= t('[!category] !subject', $variables, $options); - $message['body'][] = $params['contact_category']->reply; + $message['subject'] .= t('[!form] !subject', $variables, $options); + $message['body'][] = $params['contact_form']->reply; break; case 'user_mail': diff --git a/core/modules/contact/contact.routing.yml b/core/modules/contact/contact.routing.yml index c6cfef6..567ccf0 100644 --- a/core/modules/contact/contact.routing.yml +++ b/core/modules/contact/contact.routing.yml @@ -1,51 +1,51 @@ -entity.contact_category.delete_form: - path: '/admin/structure/contact/manage/{contact_category}/delete' +entity.contact_form.delete_form: + path: '/admin/structure/contact/manage/{contact_form}/delete' defaults: - _entity_form: 'contact_category.delete' + _entity_form: 'contact_form.delete' _title: 'Delete' requirements: - _entity_access: 'contact_category.delete' + _entity_access: 'contact_form.delete' -contact.category_list: +contact.form_list: path: '/admin/structure/contact' defaults: - _entity_list: 'contact_category' - _title: 'Contact form categories' + _entity_list: 'contact_form' + _title: 'Contact forms' requirements: _permission: 'administer contact forms' -contact.category_add: +contact.form_add: path: '/admin/structure/contact/add' defaults: - _entity_form: 'contact_category.add' - _title: 'Add category' + _entity_form: 'contact_form.add' + _title: 'Add contact form' requirements: _permission: 'administer contact forms' -entity.contact_category.edit_form: - path: '/admin/structure/contact/manage/{contact_category}' +entity.contact_form.edit_form: + path: '/admin/structure/contact/manage/{contact_form}' defaults: - _entity_form: 'contact_category.edit' - _title: 'Edit contact category' + _entity_form: 'contact_form.edit' + _title: 'Edit contact form' requirements: - _entity_access: 'contact_category.update' + _entity_access: 'contact_form.update' contact.site_page: path: '/contact' defaults: _title: 'Contact' _content: '\Drupal\contact\Controller\ContactController::contactSitePage' - contact_category: NULL + contact_form: NULL requirements: _permission: 'access site-wide contact form' -contact.site_page_category: - path: '/contact/{contact_category}' +contact.site_page_form: + path: '/contact/{contact_form}' defaults: - _title: 'Contact category form' + _title: 'Contact' _content: '\Drupal\contact\Controller\ContactController::contactSitePage' requirements: - _entity_access: 'contact_category.view' + _entity_access: 'contact_form.view' contact.personal_page: path: '/user/{user}/contact' diff --git a/core/modules/contact/src/CategoryInterface.php b/core/modules/contact/src/CategoryInterface.php deleted file mode 100644 index 0f3dd5b..0000000 --- a/core/modules/contact/src/CategoryInterface.php +++ /dev/null @@ -1,17 +0,0 @@ -hasPermission('access site-wide contact form') && $entity->id() !== 'personal'; } elseif ($operation == 'delete' || $operation == 'update') { - // Do not allow the 'personal' category to be deleted, as it's used for + // Do not allow the 'personal' form to be deleted, as it's used for // the personal contact form. return $account->hasPermission('administer contact forms') && $entity->id() !== 'personal'; } diff --git a/core/modules/contact/src/CategoryForm.php b/core/modules/contact/src/ContactFormEditForm.php similarity index 58% rename from core/modules/contact/src/CategoryForm.php rename to core/modules/contact/src/ContactFormEditForm.php index e6defb1..a706671 100644 --- a/core/modules/contact/src/CategoryForm.php +++ b/core/modules/contact/src/ContactFormEditForm.php @@ -2,7 +2,7 @@ /** * @file - * Contains \Drupal\contact\CategoryForm. + * Contains \Drupal\contact\ContactFormEditForm. */ namespace Drupal\contact; @@ -12,9 +12,9 @@ use Drupal\Core\Form\FormStateInterface; /** - * Base form for category edit forms. + * Base form for contact form edit forms. */ -class CategoryForm extends EntityForm { +class ContactFormEditForm extends EntityForm { /** * {@inheritdoc} @@ -22,49 +22,49 @@ class CategoryForm extends EntityForm { public function form(array $form, FormStateInterface $form_state) { $form = parent::form($form, $form_state); - $category = $this->entity; - $default_category = $this->config('contact.settings')->get('default_category'); + $contact_form = $this->entity; + $default_form = $this->config('contact.settings')->get('default_form'); $form['label'] = array( '#type' => 'textfield', '#title' => $this->t('Label'), '#maxlength' => 255, - '#default_value' => $category->label(), + '#default_value' => $contact_form->label(), '#description' => $this->t("Example: 'website feedback' or 'product information'."), '#required' => TRUE, ); $form['id'] = array( '#type' => 'machine_name', - '#default_value' => $category->id(), + '#default_value' => $contact_form->id(), '#maxlength' => EntityTypeInterface::BUNDLE_MAX_LENGTH, '#machine_name' => array( - 'exists' => '\Drupal\contact\Entity\Category::load', + 'exists' => '\Drupal\contact\Entity\ContactForm::load', ), - '#disabled' => !$category->isNew(), + '#disabled' => !$contact_form->isNew(), ); $form['recipients'] = array( '#type' => 'textarea', '#title' => $this->t('Recipients'), - '#default_value' => implode(', ', $category->recipients), + '#default_value' => implode(', ', $contact_form->recipients), '#description' => $this->t("Example: 'webmaster@example.com' or 'sales@example.com,support@example.com' . To specify multiple recipients, separate each email address with a comma."), '#required' => TRUE, ); $form['reply'] = array( '#type' => 'textarea', '#title' => $this->t('Auto-reply'), - '#default_value' => $category->reply, + '#default_value' => $contact_form->reply, '#description' => $this->t('Optional auto-reply. Leave empty if you do not want to send the user an auto-reply message.'), ); $form['weight'] = array( '#type' => 'weight', '#title' => $this->t('Weight'), - '#default_value' => $category->weight, - '#description' => $this->t('When listing categories, those with lighter (smaller) weights get listed before categories with heavier (larger) weights. Categories with equal weights are sorted alphabetically.'), + '#default_value' => $contact_form->weight, + '#description' => $this->t('When listing forms, those with lighter (smaller) weights get listed before forms with heavier (larger) weights. Forms with equal weights are sorted alphabetically.'), ); $form['selected'] = array( '#type' => 'checkbox', - '#title' => $this->t('Make this the default category.'), - '#default_value' => $default_category === $category->id(), + '#title' => $this->t('Make this the default form.'), + '#default_value' => $default_form === $contact_form->id(), ); return $form; @@ -92,35 +92,35 @@ public function validate(array $form, FormStateInterface $form_state) { * {@inheritdoc} */ public function save(array $form, FormStateInterface $form_state) { - $category = $this->entity; - $status = $category->save(); + $contact_form = $this->entity; + $status = $contact_form->save(); $contact_settings = $this->config('contact.settings'); $edit_link = \Drupal::linkGenerator()->generateFromUrl($this->t('Edit'), $this->entity->urlInfo()); if ($status == SAVED_UPDATED) { - drupal_set_message($this->t('Category %label has been updated.', array('%label' => $category->label()))); - $this->logger('contact')->notice('Category %label has been updated.', array('%label' => $category->label(), 'link' => $edit_link)); + drupal_set_message($this->t('Contact form %label has been updated.', array('%label' => $contact_form->label()))); + $this->logger('contact')->notice('Contact form %label has been updated.', array('%label' => $contact_form->label(), 'link' => $edit_link)); } else { - drupal_set_message($this->t('Category %label has been added.', array('%label' => $category->label()))); - $this->logger('contact')->notice('Category %label has been added.', array('%label' => $category->label(), 'link' => $edit_link)); + drupal_set_message($this->t('Contact form %label has been added.', array('%label' => $contact_form->label()))); + $this->logger('contact')->notice('Contact form %label has been added.', array('%label' => $contact_form->label(), 'link' => $edit_link)); } - // Update the default category. + // Update the default form. if ($form_state->getValue('selected')) { $contact_settings - ->set('default_category', $category->id()) + ->set('default_form', $contact_form->id()) ->save(); } - // If it was the default category, empty out the setting. - elseif ($contact_settings->get('default_category') == $category->id()) { + // If it was the default form, empty out the setting. + elseif ($contact_settings->get('default_form') == $contact_form->id()) { $contact_settings - ->set('default_category', NULL) + ->set('default_form', NULL) ->save(); } - $form_state->setRedirect('contact.category_list'); + $form_state->setRedirect('contact.form_list'); } } diff --git a/core/modules/contact/src/ContactFormInterface.php b/core/modules/contact/src/ContactFormInterface.php new file mode 100644 index 0000000..cda8e27 --- /dev/null +++ b/core/modules/contact/src/ContactFormInterface.php @@ -0,0 +1,17 @@ +getLabel($entity); - // Special case the personal category. + $row['form'] = $this->getLabel($entity); + // Special case the personal form. if ($entity->id() == 'personal') { $row['recipients'] = t('Selected user'); $row['selected'] = t('No'); } else { $row['recipients'] = String::checkPlain(implode(', ', $entity->recipients)); - $default_category = \Drupal::config('contact.settings')->get('default_category'); - $row['selected'] = ($default_category == $entity->id() ? t('Yes') : t('No')); + $default_form = \Drupal::config('contact.settings')->get('default_form'); + $row['selected'] = ($default_form == $entity->id() ? t('Yes') : t('No')); } return $row + parent::buildRow($entity); } diff --git a/core/modules/contact/src/Controller/ContactController.php b/core/modules/contact/src/Controller/ContactController.php index 307989a..cffbf5a 100644 --- a/core/modules/contact/src/Controller/ContactController.php +++ b/core/modules/contact/src/Controller/ContactController.php @@ -10,7 +10,7 @@ use Drupal\Core\Controller\ControllerBase; use Drupal\Core\Datetime\DateFormatter; use Drupal\Core\Flood\FloodInterface; -use Drupal\contact\CategoryInterface; +use Drupal\contact\ContactFormInterface; use Drupal\user\UserInterface; use Drupal\Component\Utility\String; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -62,32 +62,32 @@ public static function create(ContainerInterface $container) { /** * Presents the site-wide contact form. * - * @param \Drupal\contact\CategoryInterface $contact_category - * The contact category to use. + * @param \Drupal\contact\ContactFormInterface $contact_form + * The contact form to use. * * @return array * The form as render array as expected by drupal_render(). * * @throws \Symfony\Component\HttpKernel\Exception\NotFoundHttpException * Exception is thrown when user tries to access non existing default - * contact category form. + * contact form. */ - public function contactSitePage(CategoryInterface $contact_category = NULL) { + public function contactSitePage(ContactFormInterface $contact_form = NULL) { // Check if flood control has been activated for sending emails. if (!$this->currentUser()->hasPermission('administer contact forms')) { $this->contactFloodControl(); } - // Use the default category if no category has been passed. - if (empty($contact_category)) { - $contact_category = $this->entityManager() - ->getStorage('contact_category') - ->load($this->config('contact.settings')->get('default_category')); - // If there are no categories, do not display the form. - if (empty($contact_category)) { + // Use the default form if no form has been passed. + if (empty($contact_form)) { + $contact_form = $this->entityManager() + ->getStorage('contact_form') + ->load($this->config('contact.settings')->get('default_form')); + // If there are no forms, do not display the form. + if (empty($contact_form)) { if ($this->currentUser()->hasPermission('administer contact forms')) { - drupal_set_message($this->t('The contact form has not been configured. Add one or more categories to the form.', array( - '@add' => $this->url('contact.category_add'))), 'error'); + drupal_set_message($this->t('The contact form has not been configured. Add one or more forms .', array( + '@add' => $this->url('contact.form_add'))), 'error'); return array(); } else { @@ -99,11 +99,11 @@ public function contactSitePage(CategoryInterface $contact_category = NULL) { $message = $this->entityManager() ->getStorage('contact_message') ->create(array( - 'category' => $contact_category->id(), + 'contact_form' => $contact_form->id(), )); $form = $this->entityFormBuilder()->getForm($message); - $form['#title'] = String::checkPlain($contact_category->label()); + $form['#title'] = String::checkPlain($contact_form->label()); return $form; } @@ -123,7 +123,7 @@ public function contactPersonalPage(UserInterface $user) { } $message = $this->entityManager()->getStorage('contact_message')->create(array( - 'category' => 'personal', + 'contact_form' => 'personal', 'recipient' => $user->id(), )); diff --git a/core/modules/contact/src/Entity/Category.php b/core/modules/contact/src/Entity/ContactForm.php similarity index 51% rename from core/modules/contact/src/Entity/Category.php rename to core/modules/contact/src/Entity/ContactForm.php index ec770e4..4cf623a 100644 --- a/core/modules/contact/src/Entity/Category.php +++ b/core/modules/contact/src/Entity/ContactForm.php @@ -2,7 +2,7 @@ /** * @file - * Definition of Drupal\contact\Entity\Category. + * Contains \Drupal\contact\Entity\ContactForm. */ namespace Drupal\contact\Entity; @@ -10,24 +10,24 @@ use Drupal\Core\Config\Entity\ConfigEntityBase; use Drupal\Core\Config\Entity\ConfigEntityBundleBase; use Drupal\Core\Entity\EntityStorageInterface; -use Drupal\contact\CategoryInterface; +use Drupal\contact\ContactFormInterface; /** - * Defines the contact category entity. + * Defines the contact form entity. * * @ConfigEntityType( - * id = "contact_category", - * label = @Translation("Contact category"), + * id = "contact_form", + * label = @Translation("Contact form"), * controllers = { - * "access" = "Drupal\contact\CategoryAccessControlHandler", - * "list_builder" = "Drupal\contact\CategoryListBuilder", + * "access" = "Drupal\contact\ContactFormAccessControlHandler", + * "list_builder" = "Drupal\contact\ContactFormListBuilder", * "form" = { - * "add" = "Drupal\contact\CategoryForm", - * "edit" = "Drupal\contact\CategoryForm", - * "delete" = "Drupal\contact\Form\CategoryDeleteForm" + * "add" = "Drupal\contact\ContactFormEditForm", + * "edit" = "Drupal\contact\ContactFormEditForm", + * "delete" = "Drupal\contact\Form\ContactFormDeleteForm" * } * }, - * config_prefix = "category", + * config_prefix = "form", * admin_permission = "administer contact forms", * bundle_of = "contact_message", * entity_keys = { @@ -35,22 +35,22 @@ * "label" = "label" * }, * links = { - * "delete-form" = "entity.contact_category.delete_form", - * "edit-form" = "entity.contact_category.edit_form" + * "delete-form" = "entity.contact_form.delete_form", + * "edit-form" = "entity.contact_form.edit_form" * } * ) */ -class Category extends ConfigEntityBundleBase implements CategoryInterface { +class ContactForm extends ConfigEntityBundleBase implements ContactFormInterface { /** - * The category ID. + * The form ID. * * @var string */ public $id; /** - * The category label. + * The form label. * * @var string */ @@ -71,7 +71,7 @@ class Category extends ConfigEntityBundleBase implements CategoryInterface { public $reply = ''; /** - * Weight of this category (used for sorting). + * Weight of this form (used for sorting). * * @var int */ diff --git a/core/modules/contact/src/Entity/Message.php b/core/modules/contact/src/Entity/Message.php index 96d3630..ac361de 100644 --- a/core/modules/contact/src/Entity/Message.php +++ b/core/modules/contact/src/Entity/Message.php @@ -26,13 +26,13 @@ * } * }, * entity_keys = { - * "bundle" = "category", + * "bundle" = "contact_form", * "uuid" = "uuid" * }, - * bundle_entity_type = "contact_category", + * bundle_entity_type = "contact_form", * fieldable = TRUE, * links = { - * "admin-form" = "entity.contact_category.edit_form" + * "admin-form" = "entity.contact_form.edit_form" * } * ) */ @@ -48,8 +48,8 @@ public function isPersonal() { /** * {@inheritdoc} */ - public function getCategory() { - return $this->get('category')->entity; + public function getContactForm() { + return $this->get('contact_form')->entity; } /** @@ -135,10 +135,10 @@ public function getPersonalRecipient() { * {@inheritdoc} */ public static function baseFieldDefinitions(EntityTypeInterface $entity_type) { - $fields['category'] = BaseFieldDefinition::create('entity_reference') - ->setLabel(t('Category ID')) - ->setDescription(t('The ID of the associated category.')) - ->setSetting('target_type', 'contact_category') + $fields['contact_form'] = BaseFieldDefinition::create('entity_reference') + ->setLabel(t('Form ID')) + ->setDescription(t('The ID of the associated form.')) + ->setSetting('target_type', 'contact_form') ->setRequired(TRUE); $fields['uuid'] = BaseFieldDefinition::create('uuid') diff --git a/core/modules/contact/src/Form/CategoryDeleteForm.php b/core/modules/contact/src/Form/ContactFormDeleteForm.php similarity index 61% rename from core/modules/contact/src/Form/CategoryDeleteForm.php rename to core/modules/contact/src/Form/ContactFormDeleteForm.php index cd534d4..26c21aa 100644 --- a/core/modules/contact/src/Form/CategoryDeleteForm.php +++ b/core/modules/contact/src/Form/ContactFormDeleteForm.php @@ -2,7 +2,7 @@ /** * @file - * Contains \Drupal\contact\Form\CategoryDeleteForm. + * Contains \Drupal\contact\Form\ContactFormDeleteDeleteForm. */ namespace Drupal\contact\Form; @@ -12,9 +12,9 @@ use Drupal\Core\Url; /** - * Builds the form to delete a contact category. + * Builds the form to delete a contact form. */ -class CategoryDeleteForm extends EntityConfirmFormBase { +class ContactFormDeleteForm extends EntityConfirmFormBase { /** * {@inheritdoc} @@ -27,7 +27,7 @@ public function getQuestion() { * {@inheritdoc} */ public function getCancelUrl() { - return new Url('contact.category_list'); + return new Url('contact.form_list'); } /** @@ -42,8 +42,8 @@ public function getConfirmText() { */ public function submit(array $form, FormStateInterface $form_state) { $this->entity->delete(); - drupal_set_message($this->t('Category %label has been deleted.', array('%label' => $this->entity->label()))); - $this->logger('contact')->notice('Category %label has been deleted.', array('%label' => $this->entity->label())); + drupal_set_message($this->t('Contact form %label has been deleted.', array('%label' => $this->entity->label()))); + $this->logger('contact')->notice('Contact form %label has been deleted.', array('%label' => $this->entity->label())); $form_state->setRedirectUrl($this->getCancelUrl()); } diff --git a/core/modules/contact/src/MessageForm.php b/core/modules/contact/src/MessageForm.php index 83066a3..72aaeb3 100644 --- a/core/modules/contact/src/MessageForm.php +++ b/core/modules/contact/src/MessageForm.php @@ -87,7 +87,7 @@ public function form(array $form, FormStateInterface $form_state) { $form['preview']['message'] = $this->entityManager->getViewBuilder('contact_message')->view($message, 'full'); } - $language_configuration = $this->moduleHandler->invoke('language', 'get_default_configuration', array('contact_message', $message->getCategory()->id())); + $language_configuration = $this->moduleHandler->invoke('language', 'get_default_configuration', array('contact_message', $message->getContactForm()->id())); $form['langcode'] = array( '#title' => $this->t('Language'), '#type' => 'language_select', @@ -202,11 +202,11 @@ public function save(array $form, FormStateInterface $form_state) { $params['sender'] = $sender; if (!$message->isPersonal()) { - // Send to the category recipient(s), using the site's default language. - $category = $message->getCategory(); - $params['contact_category'] = $category; + // Send to the form recipient(s), using the site's default language. + $contact_form = $message->getContactForm(); + $params['contact_form'] = $contact_form; - $to = implode(', ', $category->recipients); + $to = implode(', ', $contact_form->recipients); $recipient_langcode = $this->languageManager->getDefaultLanguage()->getId(); } elseif ($recipient = $message->getPersonalRecipient()) { @@ -229,7 +229,7 @@ public function save(array $form, FormStateInterface $form_state) { } // If configured, send an auto-reply, using the current language. - if (!$message->isPersonal() && $category->reply) { + if (!$message->isPersonal() && $contact_form->reply) { // User contact forms do not support an auto-reply message, so this // message always originates from the site. drupal_mail('contact', 'page_autoreply', $sender->getEmail(), $language_interface->id, $params); @@ -237,10 +237,10 @@ public function save(array $form, FormStateInterface $form_state) { $this->flood->register('contact', $this->config('contact.settings')->get('flood.interval')); if (!$message->isPersonal()) { - $this->logger('contact')->notice('%sender-name (@sender-from) sent an email regarding %category.', array( + $this->logger('contact')->notice('%sender-name (@sender-from) sent an email regarding %contact_form.', array( '%sender-name' => $sender->getUsername(), '@sender-from' => $sender->getEmail(), - '%category' => $category->label(), + '%contact_form' => $contact_form->label(), )); } else { diff --git a/core/modules/contact/src/MessageInterface.php b/core/modules/contact/src/MessageInterface.php index b73bd2d..224564e 100644 --- a/core/modules/contact/src/MessageInterface.php +++ b/core/modules/contact/src/MessageInterface.php @@ -10,17 +10,17 @@ use Drupal\Core\Entity\ContentEntityInterface; /** - * Provides an interface defining a contant message entity + * Provides an interface defining a contact message entity. */ interface MessageInterface extends ContentEntityInterface { /** - * Returns the category this contact message belongs to. + * Returns the form this contact message belongs to. * - * @return \Drupal\contact\CategoryInterface - * The contact category entity. + * @return \Drupal\contact\ContactFormInterface + * The contact form entity. */ - public function getCategory(); + public function getContactForm(); /** * Returns the name of the sender. diff --git a/core/modules/contact/src/Tests/ContactSitewideTest.php b/core/modules/contact/src/Tests/ContactSitewideTest.php index fa09a34..436b2bf 100644 --- a/core/modules/contact/src/Tests/ContactSitewideTest.php +++ b/core/modules/contact/src/Tests/ContactSitewideTest.php @@ -52,9 +52,9 @@ function testSiteWideContact() { $this->assertText(t('The configuration options have been saved.')); $this->drupalGet('admin/structure/contact'); - // Default category exists. + // Default form exists. $this->assertLinkByHref('admin/structure/contact/manage/feedback/delete'); - // User category could not be changed or deleted. + // User form could not be changed or deleted. // Cannot use ::assertNoLinkByHref as it does partial url matching and with // field_ui enabled admin/structure/contact/manage/personal/fields exists. // @todo: See https://drupal.org/node/2031223 for the above @@ -69,13 +69,13 @@ function testSiteWideContact() { $this->drupalGet('admin/structure/contact/manage/personal'); $this->assertResponse(403); - // Delete old categories to ensure that new categories are used. - $this->deleteCategories(); + // Delete old forms to ensure that new forms are used. + $this->deleteContactForms(); $this->drupalGet('admin/structure/contact'); - $this->assertText('Personal', 'Personal category was not deleted'); + $this->assertText('Personal', 'Personal form was not deleted'); $this->assertNoLinkByHref('admin/structure/contact/manage/feedback'); - // Ensure that the contact form won't be shown without categories. + // Ensure that the contact form won't be shown without forms. user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access site-wide contact form')); $this->drupalLogout(); $this->drupalGet('contact'); @@ -85,20 +85,20 @@ function testSiteWideContact() { $this->drupalGet('contact'); $this->assertResponse(200); $this->assertText(t('The contact form has not been configured.')); - // Test access personal category via site-wide contact page. + // Test access personal form via site-wide contact page. $this->drupalGet('contact/personal'); $this->assertResponse(403); - // Add categories. + // Add forms. // Test invalid recipients. $invalid_recipients = array('invalid', 'invalid@', 'invalid@site.', '@site.', '@site.com'); foreach ($invalid_recipients as $invalid_recipient) { - $this->addCategory($this->randomMachineName(16), $this->randomMachineName(16), $invalid_recipient, '', FALSE); + $this->addContactForm($this->randomMachineName(16), $this->randomMachineName(16), $invalid_recipient, '', FALSE); $this->assertRaw(t('%recipient is an invalid email address.', array('%recipient' => $invalid_recipient))); } - // Test validation of empty category and recipients fields. - $this->addCategory('', '', '', '', TRUE); + // Test validation of empty form and recipients fields. + $this->addContactForm('', '', '', '', TRUE); $this->assertText(t('Label field is required.')); $this->assertText(t('Machine-readable name field is required.')); $this->assertText(t('Recipients field is required.')); @@ -107,56 +107,56 @@ function testSiteWideContact() { $recipients = array('simpletest@example.com', 'simpletest2@example.com', 'simpletest3@example.com'); $max_length = EntityTypeInterface::BUNDLE_MAX_LENGTH; $max_length_exceeded = $max_length + 1; - $this->addCategory($id = drupal_strtolower($this->randomMachineName($max_length_exceeded)), $label = $this->randomMachineName($max_length_exceeded), implode(',', array($recipients[0])), '', TRUE); + $this->addContactForm($id = drupal_strtolower($this->randomMachineName($max_length_exceeded)), $label = $this->randomMachineName($max_length_exceeded), implode(',', array($recipients[0])), '', TRUE); $this->assertText(format_string('Machine-readable name cannot be longer than !max characters but is currently !exceeded characters long.', array('!max' => $max_length, '!exceeded' => $max_length_exceeded))); - $this->addCategory($id = drupal_strtolower($this->randomMachineName($max_length)), $label = $this->randomMachineName($max_length), implode(',', array($recipients[0])), '', TRUE); - $this->assertRaw(t('Category %label has been added.', array('%label' => $label))); + $this->addContactForm($id = drupal_strtolower($this->randomMachineName($max_length)), $label = $this->randomMachineName($max_length), implode(',', array($recipients[0])), '', TRUE); + $this->assertRaw(t('Contact form %label has been added.', array('%label' => $label))); - // Create first valid category. - $this->addCategory($id = drupal_strtolower($this->randomMachineName(16)), $label = $this->randomMachineName(16), implode(',', array($recipients[0])), '', TRUE); - $this->assertRaw(t('Category %label has been added.', array('%label' => $label))); + // Create first valid form. + $this->addContactForm($id = drupal_strtolower($this->randomMachineName(16)), $label = $this->randomMachineName(16), implode(',', array($recipients[0])), '', TRUE); + $this->assertRaw(t('Contact form %label has been added.', array('%label' => $label))); - // Check that the category was created in site default language. - $langcode = \Drupal::config('contact.category.' . $id)->get('langcode'); + // Check that the form was created in site default language. + $langcode = \Drupal::config('contact.form.' . $id)->get('langcode'); $default_langcode = \Drupal::languageManager()->getDefaultLanguage()->id; $this->assertEqual($langcode, $default_langcode); - // Make sure the newly created category is included in the list of categories. - $this->assertNoUniqueText($label, 'New category included in categories list.'); + // Make sure the newly created form is included in the list of forms. + $this->assertNoUniqueText($label, 'New form included in forms list.'); - // Test update contact form category. - $this->updateCategory($id, $label = $this->randomMachineName(16), $recipients_str = implode(',', array($recipients[0], $recipients[1])), $reply = $this->randomMachineName(30), FALSE); - $config = \Drupal::config('contact.category.' . $id)->get(); + // Test update contact form. + $this->updateContactForm($id, $label = $this->randomMachineName(16), $recipients_str = implode(',', array($recipients[0], $recipients[1])), $reply = $this->randomMachineName(30), FALSE); + $config = \Drupal::config('contact.form.' . $id)->get(); $this->assertEqual($config['label'], $label); $this->assertEqual($config['recipients'], array($recipients[0], $recipients[1])); $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->assertNotEqual($id, \Drupal::config('contact.settings')->get('default_form')); + $this->assertRaw(t('Contact form %label has been updated.', array('%label' => $label))); + // Ensure the label is displayed on the contact page for this form. $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(); + // Reset the form back to be the default form. + \Drupal::config('contact.settings')->set('default_form', $id)->save(); - // Ensure that the contact form is shown without a category selection input. + // Ensure that the contact form is shown without a form selection input. user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access site-wide contact form')); $this->drupalLogout(); $this->drupalGet('contact'); $this->assertText(t('Your email address')); - $this->assertNoText(t('Category')); + $this->assertNoText(t('Form')); $this->drupalLogin($admin_user); - // Add more categories. - $this->addCategory(drupal_strtolower($this->randomMachineName(16)), $label = $this->randomMachineName(16), implode(',', array($recipients[0], $recipients[1])), '', FALSE); - $this->assertRaw(t('Category %label has been added.', array('%label' => $label))); + // Add more forms. + $this->addContactForm(drupal_strtolower($this->randomMachineName(16)), $label = $this->randomMachineName(16), implode(',', array($recipients[0], $recipients[1])), '', FALSE); + $this->assertRaw(t('Contact form %label has been added.', array('%label' => $label))); - $this->addCategory($name = drupal_strtolower($this->randomMachineName(16)), $label = $this->randomMachineName(16), implode(',', array($recipients[0], $recipients[1], $recipients[2])), '', FALSE); - $this->assertRaw(t('Category %label has been added.', array('%label' => $label))); + $this->addContactForm($name = drupal_strtolower($this->randomMachineName(16)), $label = $this->randomMachineName(16), implode(',', array($recipients[0], $recipients[1], $recipients[2])), '', FALSE); + $this->assertRaw(t('Contact form %label has been added.', array('%label' => $label))); - // Try adding a category that already exists. - $this->addCategory($name, $label, '', '', FALSE); - $this->assertNoRaw(t('Category %label has been saved.', array('%label' => $label))); + // Try adding a form that already exists. + $this->addContactForm($name, $label, '', '', FALSE); + $this->assertNoRaw(t('Contact form %label has been added.', array('%label' => $label))); $this->assertRaw(t('The machine-readable name is already in use. It must be unique.')); // Clear flood table in preparation for flood test and allow other checks to complete. @@ -191,14 +191,14 @@ function testSiteWideContact() { $this->submitContact($this->randomMachineName(16), $recipients[0], $this->randomMachineName(16), $id, ''); $this->assertText(t('Message field is required.')); - // Test contact form with no default category selected. + // Test contact form with no default form selected. \Drupal::config('contact.settings') - ->set('default_category', '') + ->set('default_form', '') ->save(); $this->drupalGet('contact'); $this->assertResponse(404); - // Try to access contact form with non-existing category IDs. + // Try to access contact form with non-existing form IDs. $this->drupalGet('contact/0'); $this->assertResponse(404); $this->drupalGet('contact/' . $this->randomMachineName()); @@ -217,12 +217,12 @@ function testSiteWideContact() { // Test listing controller. $this->drupalLogin($admin_user); - $this->deleteCategories(); + $this->deleteContactForms(); $label = $this->randomMachineName(16); $recipients = implode(',', array($recipients[0], $recipients[1], $recipients[2])); - $category = drupal_strtolower($this->randomMachineName(16)); - $this->addCategory($category, $label, $recipients, '', FALSE); + $contact_form = drupal_strtolower($this->randomMachineName(16)); + $this->addContactForm($contact_form, $label, $recipients, '', FALSE); $this->drupalGet('admin/structure/contact'); $this->clickLink(t('Edit')); $this->assertResponse(200); @@ -231,7 +231,7 @@ function testSiteWideContact() { // Test field UI and field integration. $this->drupalGet('admin/structure/contact'); - // Find out in which row the category we want to add a field to is. + // Find out in which row the form we want to add a field to is. $i = 0; foreach($this->xpath('//table/tbody/tr') as $row) { if (((string)$row->td[0]) == $label) { @@ -255,7 +255,7 @@ function testSiteWideContact() { $this->drupalPostForm(NULL, array(), t('Save settings')); // Check that the field is displayed. - $this->drupalGet('contact/' . $category); + $this->drupalGet('contact/' . $contact_form); $this->assertText($field_label); // Submit the contact form and verify the content. @@ -280,18 +280,18 @@ function testAutoReply() { $admin_user = $this->drupalCreateUser(array('access site-wide contact form', 'administer contact forms', 'administer permissions', 'administer users')); $this->drupalLogin($admin_user); - // Set up three categories, 2 with an auto-reply and one without. + // Set up three forms, 2 with an auto-reply and one without. $foo_autoreply = $this->randomMachineName(40); $bar_autoreply = $this->randomMachineName(40); - $this->addCategory('foo', 'foo', 'foo@example.com', $foo_autoreply, FALSE); - $this->addCategory('bar', 'bar', 'bar@example.com', $bar_autoreply, FALSE); - $this->addCategory('no_autoreply', 'no_autoreply', 'bar@example.com', '', FALSE); + $this->addContactForm('foo', 'foo', 'foo@example.com', $foo_autoreply, FALSE); + $this->addContactForm('bar', 'bar', 'bar@example.com', $bar_autoreply, FALSE); + $this->addContactForm('no_autoreply', 'no_autoreply', 'bar@example.com', '', FALSE); // Log the current user out in order to test the name and email fields. $this->drupalLogout(); user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access site-wide contact form')); - // Test the auto-reply for category 'foo'. + // Test the auto-reply for form 'foo'. $email = $this->randomMachineName(32) . '@example.com'; $subject = $this->randomMachineName(64); $this->submitContact($this->randomMachineName(16), $email, $subject, 'foo', $this->randomString(128)); @@ -301,11 +301,11 @@ function testAutoReply() { $this->assertEqual(count($captured_emails), 1); $this->assertEqual(trim($captured_emails[0]['body']), trim(drupal_html_to_text($foo_autoreply))); - // Test the auto-reply for category 'bar'. + // Test the auto-reply for form 'bar'. $email = $this->randomMachineName(32) . '@example.com'; $this->submitContact($this->randomMachineName(16), $email, $this->randomString(64), 'bar', $this->randomString(128)); - // Auto-reply for category 'bar' should result in one auto-reply email to the sender. + // Auto-reply for form 'bar' should result in one auto-reply email to the sender. $captured_emails = $this->drupalGetMails(array('id' => 'contact_page_autoreply', 'to' => $email)); $this->assertEqual(count($captured_emails), 1); $this->assertEqual(trim($captured_emails[0]['body']), trim(drupal_html_to_text($bar_autoreply))); @@ -318,21 +318,21 @@ function testAutoReply() { } /** - * Adds a category. + * Adds a form. * * @param string $id - * The category machine name. + * The form machine name. * @param string $label - * The category label. + * The form label. * @param string $recipients * The list of recipient email addresses. * @param string $reply * The auto-reply text that is sent to a user upon completing the contact * form. * @param boolean $selected - * A Boolean indicating whether the category should be selected by default. + * A Boolean indicating whether the form should be selected by default. */ - function addCategory($id, $label, $recipients, $reply, $selected) { + function addContactForm($id, $label, $recipients, $reply, $selected) { $edit = array(); $edit['label'] = $label; $edit['id'] = $id; @@ -343,21 +343,21 @@ function addCategory($id, $label, $recipients, $reply, $selected) { } /** - * Updates a category. + * Updates a form. * * @param string $id - * The category machine name. + * The form machine name. * @param string $label - * The category label. + * The form label. * @param string $recipients * The list of recipient email addresses. * @param string $reply * The auto-reply text that is sent to a user upon completing the contact * form. * @param boolean $selected - * A Boolean indicating whether the category should be selected by default. + * A Boolean indicating whether the form should be selected by default. */ - function updateCategory($id, $label, $recipients, $reply, $selected) { + function updateContactForm($id, $label, $recipients, $reply, $selected) { $edit = array(); $edit['label'] = $label; $edit['recipients'] = $recipients; @@ -376,7 +376,7 @@ function updateCategory($id, $label, $recipients, $reply, $selected) { * @param string $subject * The subject of the message. * @param string $id - * The category ID of the message. + * The form ID of the message. * @param string $message * The message body. */ @@ -386,7 +386,7 @@ function submitContact($name, $mail, $subject, $id, $message) { $edit['mail'] = $mail; $edit['subject[0][value]'] = $subject; $edit['message[0][value]'] = $message; - if ($id == \Drupal::config('contact.settings')->get('default_category')) { + if ($id == \Drupal::config('contact.settings')->get('default_form')) { $this->drupalPostForm('contact', $edit, t('Send message')); } else { @@ -395,20 +395,20 @@ function submitContact($name, $mail, $subject, $id, $message) { } /** - * Deletes all categories. + * Deletes all forms. */ - function deleteCategories() { - $categories = entity_load_multiple('contact_category'); - foreach ($categories as $id => $category) { + function deleteContactForms() { + $contact_forms = entity_load_multiple('contact_form'); + foreach ($contact_forms as $id => $contact_form) { if ($id == 'personal') { - // Personal category could not be deleted. + // Personal form could not be deleted. $this->drupalGet("admin/structure/contact/manage/$id/delete"); $this->assertResponse(403); } else { $this->drupalPostForm("admin/structure/contact/manage/$id/delete", array(), t('Delete')); - $this->assertRaw(t('Category %label has been deleted.', array('%label' => $category->label()))); - $this->assertFalse(entity_load('contact_category', $id), format_string('Category %category not found', array('%category' => $category->label()))); + $this->assertRaw(t('Contact form %label has been deleted.', array('%label' => $contact_form->label()))); + $this->assertFalse(entity_load('contact_form', $id), format_string('Form %contact_form not found', array('%contact_form' => $contact_form->label()))); } } } diff --git a/core/modules/contact/src/Tests/ContactStorageTest.php b/core/modules/contact/src/Tests/ContactStorageTest.php index c57c8e5..f444c0a 100644 --- a/core/modules/contact/src/Tests/ContactStorageTest.php +++ b/core/modules/contact/src/Tests/ContactStorageTest.php @@ -47,24 +47,24 @@ public function testContactStorage() { 'administer contact_message fields', )); $this->drupalLogin($admin_user); - // Create first valid category. + // Create first valid contact form. $mail = 'simpletest@example.com'; - $this->addCategory($id = drupal_strtolower($this->randomMachineName(16)), $label = $this->randomMachineName(16), implode(',', array($mail)), '', TRUE); - $this->assertRaw(t('Category %label has been added.', array('%label' => $label))); + $this->addContactForm($id = drupal_strtolower($this->randomMachineName(16)), $label = $this->randomMachineName(16), implode(',', array($mail)), '', TRUE); + $this->assertRaw(t('Contact form %label has been added.', array('%label' => $label))); // Ensure that anonymous can submit site-wide contact form. user_role_grant_permissions(DRUPAL_ANONYMOUS_RID, array('access site-wide contact form')); $this->drupalLogout(); $this->drupalGet('contact'); $this->assertText(t('Your email address')); - $this->assertNoText(t('Category')); + $this->assertNoText(t('Form')); $this->submitContact($name = $this->randomMachineName(16), $mail, $subject = $this->randomMachineName(16), $id, $message = $this->randomMachineName(64)); $this->assertText(t('Your message has been sent.')); $messages = Message::loadMultiple(); /** @var \Drupal\contact\Entity\Message $message */ $message = reset($messages); - $this->assertEqual($message->getCategory()->id(), $id); + $this->assertEqual($message->getContactForm()->id(), $id); $this->assertEqual($message->getSenderName(), $name); $this->assertEqual($message->getSubject(), $subject); $this->assertEqual($message->getSenderMail(), $mail); diff --git a/core/modules/contact/src/Tests/MessageEntityTest.php b/core/modules/contact/src/Tests/MessageEntityTest.php index e27d23c..29618b7 100644 --- a/core/modules/contact/src/Tests/MessageEntityTest.php +++ b/core/modules/contact/src/Tests/MessageEntityTest.php @@ -34,7 +34,7 @@ protected function setUp() { */ public function testMessageMethods() { $message_storage = $this->container->get('entity.manager')->getStorage('contact_message'); - $message = $message_storage->create(array('category' => 'feedback')); + $message = $message_storage->create(array('contact_form' => 'feedback')); // Check for empty values first. $this->assertEqual($message->getMessage(), ''); @@ -43,7 +43,7 @@ public function testMessageMethods() { $this->assertFalse($message->copySender()); // Check for default values. - $this->assertEqual('feedback', $message->getCategory()->id()); + $this->assertEqual('feedback', $message->getContactForm()->id()); $this->assertFalse($message->isPersonal()); // Set some values and check for them afterwards. diff --git a/core/modules/contact/src/Tests/Views/ContactFieldsTest.php b/core/modules/contact/src/Tests/Views/ContactFieldsTest.php index e74ec90..63c7d1a 100644 --- a/core/modules/contact/src/Tests/Views/ContactFieldsTest.php +++ b/core/modules/contact/src/Tests/Views/ContactFieldsTest.php @@ -41,9 +41,9 @@ protected function setUp() { )); $this->field_storage->save(); - entity_create('contact_category', array( + entity_create('contact_form', array( 'id' => 'contact_message', - 'label' => 'Test contact category', + 'label' => 'Test contact form', ))->save(); entity_create('field_instance_config', array( diff --git a/core/modules/migrate_drupal/config/install/migrate.migration.d6_contact_category.yml b/core/modules/migrate_drupal/config/install/migrate.migration.d6_contact_category.yml index 2081c4d..9b04a83 100644 --- a/core/modules/migrate_drupal/config/install/migrate.migration.d6_contact_category.yml +++ b/core/modules/migrate_drupal/config/install/migrate.migration.d6_contact_category.yml @@ -19,4 +19,4 @@ process: reply: reply weight: weight destination: - plugin: entity:contact_category + plugin: entity:contact_form diff --git a/core/modules/migrate_drupal/config/install/migrate.migration.d6_contact_settings.yml b/core/modules/migrate_drupal/config/install/migrate.migration.d6_contact_settings.yml index 6852050..91816cb 100644 --- a/core/modules/migrate_drupal/config/install/migrate.migration.d6_contact_settings.yml +++ b/core/modules/migrate_drupal/config/install/migrate.migration.d6_contact_settings.yml @@ -10,7 +10,7 @@ source: process: user_default_enabled: contact_default_status 'flood/limit': contact_hourly_threshold - default_category: + default_form: plugin: migration migration: d6_contact_category source: default_category diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateContactCategoryTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateContactCategoryTest.php index 0676705..6b9a50d 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateContactCategoryTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateContactCategoryTest.php @@ -12,7 +12,7 @@ use Drupal\migrate_drupal\Tests\MigrateDrupalTestBase; /** - * Migrate contact categories to contact.category.*.yml. + * Migrate contact categories to contact.form.*.yml. * * @group migrate_drupal */ @@ -43,24 +43,24 @@ public function setUp() { * The Drupal 6 contact categories to Drupal 8 migration. */ public function testContactCategory() { - /** @var \Drupal\contact\Entity\Category $contact_category */ - $contact_category = entity_load('contact_category', 'website_feedback'); - $this->assertEqual($contact_category->label, 'Website feedback'); - $this->assertEqual($contact_category->recipients, array('admin@example.com')); - $this->assertEqual($contact_category->reply, ''); - $this->assertEqual($contact_category->weight, 0); + /** @var \Drupal\contact\Entity\ContactForm $contact_form */ + $contact_form = entity_load('contact_form', 'website_feedback'); + $this->assertEqual($contact_form->label, 'Website feedback'); + $this->assertEqual($contact_form->recipients, array('admin@example.com')); + $this->assertEqual($contact_form->reply, ''); + $this->assertEqual($contact_form->weight, 0); - $contact_category = entity_load('contact_category', 'some_other_category'); - $this->assertEqual($contact_category->label, 'Some other category'); - $this->assertEqual($contact_category->recipients, array('test@example.com')); - $this->assertEqual($contact_category->reply, 'Thanks for contacting us, we will reply ASAP!'); - $this->assertEqual($contact_category->weight, 1); + $contact_form = entity_load('contact_form', 'some_other_category'); + $this->assertEqual($contact_form->label, 'Some other category'); + $this->assertEqual($contact_form->recipients, array('test@example.com')); + $this->assertEqual($contact_form->reply, 'Thanks for contacting us, we will reply ASAP!'); + $this->assertEqual($contact_form->weight, 1); - $contact_category = entity_load('contact_category', 'a_category_much_longer_than_thir'); - $this->assertEqual($contact_category->label, 'A category much longer than thirty two characters'); - $this->assertEqual($contact_category->recipients, array('fortyninechars@example.com')); - $this->assertEqual($contact_category->reply, ''); - $this->assertEqual($contact_category->weight, 2); + $contact_form = entity_load('contact_form', 'a_category_much_longer_than_thir'); + $this->assertEqual($contact_form->label, 'A category much longer than thirty two characters'); + $this->assertEqual($contact_form->recipients, array('fortyninechars@example.com')); + $this->assertEqual($contact_form->reply, ''); + $this->assertEqual($contact_form->weight, 2); } } diff --git a/core/modules/migrate_drupal/src/Tests/d6/MigrateContactConfigsTest.php b/core/modules/migrate_drupal/src/Tests/d6/MigrateContactConfigsTest.php index 8ef2a13..a7e7000 100644 --- a/core/modules/migrate_drupal/src/Tests/d6/MigrateContactConfigsTest.php +++ b/core/modules/migrate_drupal/src/Tests/d6/MigrateContactConfigsTest.php @@ -58,7 +58,7 @@ public function testContactSettings() { $config = \Drupal::config('contact.settings'); $this->assertIdentical($config->get('user_default_enabled'), true); $this->assertIdentical($config->get('flood.limit'), 3); - $this->assertIdentical($config->get('default_category'), 'some_other_category'); + $this->assertIdentical($config->get('default_form'), 'some_other_category'); $this->assertConfigSchema(\Drupal::service('config.typed'), 'contact.settings', $config->get()); } diff --git a/core/modules/system/src/Tests/Ajax/DialogTest.php b/core/modules/system/src/Tests/Ajax/DialogTest.php index 127b863..867ed11 100644 --- a/core/modules/system/src/Tests/Ajax/DialogTest.php +++ b/core/modules/system/src/Tests/Ajax/DialogTest.php @@ -57,7 +57,7 @@ public function testDialog() { 'settings' => NULL, 'dialogOptions' => array( 'modal' => TRUE, - 'title' => 'Add category', + 'title' => 'Add contact form', ), ); $normal_expected_response = array( @@ -165,7 +165,7 @@ public function testDialog() { $this->drupalGet('admin/structure/contact/add'); // Check we get a chunk of the code, we can't test the whole form as form // build id and token with be different. - $form = $this->xpath("//form[@id='contact-category-add-form']"); + $form = $this->xpath("//form[@id='contact-form-add-form']"); $this->assertTrue(!empty($form), 'Non-JS entity form page present.'); // Emulate going to the JS version of the form and check the JSON response. @@ -173,7 +173,7 @@ public function testDialog() { $this->drupalSetContent($ajax_result[1]['data']); // Remove the data, the form build id and token will never match. unset($ajax_result[1]['data']); - $form = $this->xpath("//form[@id='contact-category-add-form']"); + $form = $this->xpath("//form[@id='contact-form-add-form']"); $this->assertTrue(!empty($form), 'Modal dialog JSON contains entity form.'); $this->assertEqual($entity_form_expected_response, $ajax_result[1]); }