diff --git a/core/modules/contact/contact.module b/core/modules/contact/contact.module index 4957052..c8dc12f 100644 --- a/core/modules/contact/contact.module +++ b/core/modules/contact/contact.module @@ -58,28 +58,21 @@ 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'), + 'title' => 'Add contact form category', 'type' => MENU_LOCAL_ACTION, 'weight' => 1, - 'file' => 'contact.admin.inc', + 'route_name' => 'contact_category_add', ); $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 new file mode 100644 index 0000000..c5e5661 --- /dev/null +++ b/core/modules/contact/contact.routing.yml @@ -0,0 +1,20 @@ +contact_category_list: + pattern: '/admin/structure/contact' + defaults: + _content: '\Drupal\contact\Controller\ContactController::adminList' + requirements: + _permission: 'administer contact forms' + +contact_category_add: + pattern: '/admin/structure/contact/add' + defaults: + _content: '\Drupal\contact\Controller\ContactController::categoryAdd' + requirements: + _permission: 'administer contact forms' + +contact_category_edit: + pattern: '/admin/structure/contact/manage/{contact_category}/edit' + defaults: + _content: '\Drupal\contact\Controller\ContactController::categoryEdit' + requirements: + _permission: 'administer contact forms' \ No newline at end of file diff --git a/core/modules/contact/lib/Drupal/contact/Controller/ContactController.php b/core/modules/contact/lib/Drupal/contact/Controller/ContactController.php new file mode 100644 index 0000000..1c4234f --- /dev/null +++ b/core/modules/contact/lib/Drupal/contact/Controller/ContactController.php @@ -0,0 +1,59 @@ +get('plugin.manager.entity')); + } + + /** + * Overrides \Drupal\Core\ControllerInterface::__construct(). + */ + public function __construct(EntityManager $entity_manager) { + $this->entityManager = $entity_manager; + } + + /** + * Content for contact category listing page. + */ + public function adminList() { + return $this->entityManager->getListController('contact_category')->render(); + } + + /** + * Content for contact category creation page. + */ + public function categoryAdd() { + $category = entity_create('contact_category', array()); + return entity_get_form($category); + } + + /** + * Content for the contact category edit page. + */ + public function categoryEdit(Category $contact_category) { + return entity_get_form($contact_category); + } + +} \ No newline at end of file