diff --git a/core/modules/contact/contact.admin.inc b/core/modules/contact/contact.admin.inc deleted file mode 100644 index 32ddf7102e4..00000000000 --- a/core/modules/contact/contact.admin.inc +++ /dev/null @@ -1,53 +0,0 @@ -getListController('contact_category') - ->render(); -} - -/** - * Page callback: Presents the category creation form. - * - * @return array - * A form array as expected by drupal_render(). - * - * @see contact_menu() - */ -function contact_category_add() { - drupal_set_title(t('Add contact form category')); - $category = entity_create('contact_category', array()); - return entity_get_form($category); -} - -/** - * Page callback: Presents the category edit form. - * - * @param Drupal\contact\Plugin\Core\Entity\Category $category - * The contact category to edit. - * - * @return array - * A form array as expected by drupal_render(). - * - * @see contact_menu() - */ -function contact_category_edit(Category $category) { - drupal_set_title(t('Edit %label contact form category', array('%label' => $category->label())), PASS_THROUGH); - return entity_get_form($category); -} diff --git a/core/modules/contact/contact.module b/core/modules/contact/contact.module index 3ef1ce6fb33..718a128c180 100644 --- a/core/modules/contact/contact.module +++ b/core/modules/contact/contact.module @@ -58,28 +58,19 @@ function contact_permission() { */ function contact_menu() { $items['admin/structure/contact'] = array( - 'title' => 'Contact form', + 'title' => 'Contact form categories', 'description' => 'Create a system contact form and set up categories for the form to use.', - 'page callback' => 'contact_category_list', - 'access arguments' => array('administer contact forms'), - 'file' => 'contact.admin.inc', + 'route_name' => 'contact_category_list', ); $items['admin/structure/contact/add'] = array( 'title' => 'Add category', - 'page callback' => 'contact_category_add', - 'access arguments' => array('administer contact forms'), + 'route_name' => 'contact_category_add', 'type' => MENU_LOCAL_ACTION, 'weight' => 1, - 'file' => 'contact.admin.inc', ); $items['admin/structure/contact/manage/%contact_category'] = array( 'title' => 'Edit contact category', - 'title callback' => 'entity_page_label', - 'title arguments' => array(4), - 'page callback' => 'contact_category_edit', - 'page arguments' => array(4), - 'access arguments' => array('administer contact forms'), - 'file' => 'contact.admin.inc', + 'route_name' => 'contact_category_edit', ); $items['admin/structure/contact/manage/%contact_category/edit'] = array( 'title' => 'Edit', diff --git a/core/modules/contact/contact.routing.yml b/core/modules/contact/contact.routing.yml index 1f349379855..4cbfff238aa 100644 --- a/core/modules/contact/contact.routing.yml +++ b/core/modules/contact/contact.routing.yml @@ -4,3 +4,25 @@ contact_category_delete: _form: '\Drupal\contact\Form\DeleteForm' requirements: _permission: 'administer contact forms' + +contact_category_list: + pattern: '/admin/structure/contact' + defaults: + _content: '\Drupal\Core\Entity\Controller\EntityListController::listing' + entity_type: 'contact_category' + requirements: + _permission: 'administer contact forms' + +contact_category_add: + pattern: '/admin/structure/contact/add' + defaults: + _entity_form: contact_category.add + requirements: + _permission: 'administer contact forms' + +contact_category_edit: + pattern: '/admin/structure/contact/manage/{contact_category}' + defaults: + _entity_form: contact_category.edit + requirements: + _permission: 'administer contact forms' diff --git a/core/modules/contact/lib/Drupal/contact/Plugin/Core/Entity/Category.php b/core/modules/contact/lib/Drupal/contact/Plugin/Core/Entity/Category.php index 7e068da84e3..a224d1a7bfd 100644 --- a/core/modules/contact/lib/Drupal/contact/Plugin/Core/Entity/Category.php +++ b/core/modules/contact/lib/Drupal/contact/Plugin/Core/Entity/Category.php @@ -23,7 +23,8 @@ use Drupal\contact\CategoryInterface; * "storage" = "Drupal\contact\CategoryStorageController", * "list" = "Drupal\contact\CategoryListController", * "form" = { - * "default" = "Drupal\contact\CategoryFormController" + * "add" = "Drupal\contact\CategoryFormController", + * "edit" = "Drupal\contact\CategoryFormController" * } * }, * uri_callback = "contact_category_uri", diff --git a/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php b/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php index 1ea830b49a4..9ae74b9471e 100644 --- a/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php +++ b/core/modules/contact/lib/Drupal/contact/Tests/ContactSitewideTest.php @@ -276,7 +276,7 @@ class ContactSitewideTest extends WebTestBase { $edit['recipients'] = $recipients; $edit['reply'] = $reply; $edit['selected'] = ($selected ? TRUE : FALSE); - $this->drupalPost("admin/structure/contact/manage/$id/edit", $edit, t('Save')); + $this->drupalPost("admin/structure/contact/manage/$id", $edit, t('Save')); } /**