diff --git a/core/modules/contact/contact.admin.inc b/core/modules/contact/contact.admin.inc index bc706c3..6bc8ed3 100644 --- a/core/modules/contact/contact.admin.inc +++ b/core/modules/contact/contact.admin.inc @@ -17,7 +17,7 @@ */ function contact_category_list() { drupal_set_title(t('Contact form categories')); - return drupal_container()->get('plugin.manager.entity') + return Drupal::service('plugin.manager.entity') ->getListController('contact_category') ->render(); } diff --git a/core/modules/contact/lib/Drupal/contact/CategoryListController.php b/core/modules/contact/lib/Drupal/contact/CategoryListController.php index b7d9091..058979a 100644 --- a/core/modules/contact/lib/Drupal/contact/CategoryListController.php +++ b/core/modules/contact/lib/Drupal/contact/CategoryListController.php @@ -8,11 +8,19 @@ use Drupal\Core\Config\Entity\ConfigEntityListController; use Drupal\Core\Entity\EntityInterface; +use Drupal\Core\Form\FormInterface; /** * Provides a listing of contact categories. */ -class CategoryListController extends ConfigEntityListController { +class CategoryListController extends ConfigEntityListController implements FormInterface { + + /** + * Implements \Drupal\Core\Form\FormInterface::getFormID(). + */ + public function getFormID() { + return 'contact_category_list_form'; + } /** * Overrides \Drupal\Core\Entity\EntityListController::getOperations(). @@ -66,28 +74,17 @@ public function buildRow(EntityInterface $entity) { public function render() { $entities = $this->load(); if (count($entities) > 1) { - $form_state = array(); - $form_state['build_info']['args'] = array(); - $form_state['build_info']['callback'] = array($this, 'form'); - - return drupal_build_form($this->entityType . '_list_form', $form_state); + // Creates a form for manipulating contact category form weights. + return drupal_get_form($this); } return parent::render(); } /** - * Creates a tabledrag form for manipulating contact category form weights. - * - * @param array $form - * An associative array containing the structure of the form. - * @param array $form_state - * A reference to a keyed array containing the current state of the form. - * - * @return array - * The array containing the complete form. + * Implements \Drupal\Core\Form\FormInterface::buildForm(). */ - function form($form, $form_state) { + public function buildForm(array $form, array &$form_state) { $form['entities'] = array( '#type' => 'table', '#header' => $this->buildHeader() + array('weight' => t('Weight')), @@ -138,7 +135,6 @@ function form($form, $form_state) { $form['actions']['submit'] = array( '#type' => 'submit', '#value' => t('Save changes'), - '#submit' => array(array($this, 'submit')), '#button_type' => 'primary', ); @@ -146,14 +142,16 @@ function form($form, $form_state) { } /** - * Submit handler for the overview form. - * - * @param array $form - * An associative array containing the structure of the form. - * @param array $form_state - * A reference to a keyed array containing the current state of the form. + * Implements \Drupal\Core\Form\FormInterface::validateForm(). + */ + public function validateForm(array &$form, array &$form_state) { + // No validation. + } + + /** + * Implements \Drupal\Core\Form\FormInterface::submitForm(). */ - public function submit($form, &$form_state) { + public function submitForm(array &$form, array &$form_state) { $values = $form_state['values']['entities']; $entities = entity_load_multiple($this->entityType, array_keys($values));