Issue #1938386 by andypost, mkadin, tim.plunkett: Convert contact_category_()* pages to a new-style Controller.
parent
ba5c2c4dca
commit
1d26631741
|
@ -1,53 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Admin page callbacks for the Contact module.
|
||||
*/
|
||||
|
||||
use Drupal\contact\Plugin\Core\Entity\Category;
|
||||
|
||||
/**
|
||||
* Page callback: Lists contact categories.
|
||||
*
|
||||
* @return array
|
||||
* A build array in the format expected by drupal_render().
|
||||
*
|
||||
* @see contact_menu()
|
||||
*/
|
||||
function contact_category_list() {
|
||||
drupal_set_title(t('Contact form categories'));
|
||||
return Drupal::entityManager()
|
||||
->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);
|
||||
}
|
|
@ -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',
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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",
|
||||
|
|
|
@ -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'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue