diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Core/Entity/Vocabulary.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Core/Entity/Vocabulary.php index 9d55435..806ac98 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Core/Entity/Vocabulary.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/Core/Entity/Vocabulary.php @@ -32,7 +32,8 @@ * entity_keys = { * "id" = "vid", * "label" = "name", - * "uuid" = "uuid" + * "uuid" = "uuid", + * "weight" = "weight" * } * ) */ diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyListController.php b/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyListController.php index b3dc6ac..689f7b8 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyListController.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/VocabularyListController.php @@ -71,17 +71,8 @@ public function render() { } // Unset weight key to use render. unset($this->weightKey); - $build = array( - '#theme' => 'table', - '#header' => $this->buildHeader(), - '#rows' => array(), - '#empty' => t('No vocabularies available. Add vocabulary.', array('@link' => url('admin/structure/taxonomy/add'))), - ); - unset($build['#header']['weight']); - foreach ($entities as $entity) { - $row = parent::buildRow($entity); - $build['#rows'][$entity->id()] = $row; - } + $build = parent::render(); + $build['#empty'] = t('No vocabularies available. Add vocabulary.', array('@link' => url('admin/structure/taxonomy/add'))); return $build; } @@ -89,27 +80,11 @@ public function render() { * {@inheritdoc} */ public function buildForm(array $form, array &$form_state) { - $form['vocabularies'] = array( - '#type' => 'table', - '#header' => $this->buildHeader(), - '#tabledrag' => array( - array('order', 'sibling', 'weight'), - ), - '#attributes' => array( - 'id' => 'taxonomy', - ), - ); - - foreach ($this->load() as $entity) { - $form['vocabularies'][$entity->id()] = $this->buildRow($entity); - } - - $form['actions']['#type'] = 'actions'; - $form['actions']['submit'] = array( - '#type' => 'submit', - '#value' => t('Save'), - '#button_type' => 'primary', + $form = parent::buildForm($form, $form_state); + $form['vocabularies']['#attributes'] = array( + 'id' => 'taxonomy', ); + $form['actions']['submit']['#value'] = t('Save'); return $form; } @@ -117,24 +92,8 @@ public function buildForm(array $form, array &$form_state) { /** * {@inheritdoc} */ - public function validateForm(array &$form, array &$form_state) { - // No validation. - } - - /** - * {@inheritdoc} - */ public function submitForm(array &$form, array &$form_state) { - $vocabularies = $form_state['values']['vocabularies']; - - $entities = entity_load_multiple($this->entityType, array_keys($vocabularies)); - foreach ($vocabularies as $id => $value) { - if (isset($entities[$id]) && $value['weight'] != $entities[$id]->get('weight')) { - // Update changed weight. - $entities[$id]->set('weight', $value['weight']); - $entities[$id]->save(); - } - } + parent::submitForm($form, $form_state); drupal_set_message(t('The configuration options have been saved.')); } diff --git a/core/modules/user/lib/Drupal/user/Plugin/Core/Entity/Role.php b/core/modules/user/lib/Drupal/user/Plugin/Core/Entity/Role.php index d35d7f1..947fde2 100644 --- a/core/modules/user/lib/Drupal/user/Plugin/Core/Entity/Role.php +++ b/core/modules/user/lib/Drupal/user/Plugin/Core/Entity/Role.php @@ -33,7 +33,8 @@ * entity_keys = { * "id" = "id", * "uuid" = "uuid", - * "label" = "label" + * "label" = "label", + * "weight" = "weight" * } * ) */ diff --git a/core/modules/user/lib/Drupal/user/RoleListController.php b/core/modules/user/lib/Drupal/user/RoleListController.php index a2250f5..30670c5 100644 --- a/core/modules/user/lib/Drupal/user/RoleListController.php +++ b/core/modules/user/lib/Drupal/user/RoleListController.php @@ -29,8 +29,6 @@ public function getFormID() { public function buildHeader() { $row = parent::buildHeader(); $row['label'] = t('Name'); - unset($row['id']); - $row['weight'] = t('Weight'); return $row; } @@ -55,83 +53,8 @@ public function getOperations(EntityInterface $entity) { /** * {@inheritdoc} */ - public function buildRow(EntityInterface $entity) { - $row = parent::buildRow($entity); - - // Override default values to markup elements. - $row['#attributes']['class'][] = 'draggable'; - unset($row['id']); - - $row['label'] = array( - '#markup' => check_plain($row['label']), - ); - $row['#weight'] = $entity->get('weight'); - // Add weight column. - $row['weight'] = array( - '#type' => 'weight', - '#title' => t('Weight for @title', array('@title' => $entity->label())), - '#title_display' => 'invisible', - '#default_value' => $entity->get('weight'), - '#attributes' => array('class' => array('weight')), - ); - return $row; - } - - /** - * {@inheritdoc} - */ - public function render() { - return drupal_get_form($this); - } - - /** - * {@inheritdoc} - */ - public function buildForm(array $form, array &$form_state) { - $form['entities'] = array( - '#type' => 'table', - '#header' => $this->buildHeader(), - '#empty' => t('There is no @label yet.', array('@label' => $this->entityInfo['label'])), - '#tabledrag' => array( - array('order', 'sibling', 'weight'), - ), - ); - - foreach ($this->load() as $entity) { - $form['entities'][$entity->id()] = $this->buildRow($entity); - } - - $form['actions']['#type'] = 'actions'; - $form['actions']['submit'] = array( - '#type' => 'submit', - '#value' => t('Save order'), - '#button_type' => 'primary', - ); - - return $form; - } - - /** - * {@inheritdoc} - */ - public function validateForm(array &$form, array &$form_state) { - // No validation. - } - - /** - * {@inheritdoc} - */ public function submitForm(array &$form, array &$form_state) { - $values = $form_state['values']['entities']; - - $entities = entity_load_multiple($this->entityType, array_keys($values)); - foreach ($values as $id => $value) { - if (isset($entities[$id]) && $value['weight'] != $entities[$id]->get('weight')) { - // Update changed weight. - $entities[$id]->set('weight', $value['weight']); - $entities[$id]->save(); - } - } + parent::submitForm($form, $form_state); drupal_set_message(t('The role settings have been updated.')); }