Skip to content
Snippets Groups Projects
Commit f77831e1 authored by John Voskuilen's avatar John Voskuilen
Browse files

Issue #3515981: Apply new orderby key to configuration schema for WorkflowState - undo

parent eb8043c3
No related branches found
No related tags found
No related merge requests found
Pipeline #459755 passed with warnings
......@@ -3,7 +3,6 @@
workflow.state.*:
type: config_entity
label: 'Workflow State'
orderby: weight
mapping:
id:
type: string
......
......@@ -242,8 +242,9 @@ class WorkflowState extends ConfigEntityBase implements WorkflowStateInterface {
* @_deprecated WorkflowState::getStates() ==> WorkflowState::loadMultiple()
*/
public static function loadMultiple(array $ids = NULL, $wid = '', $reset = FALSE) {
// Loaded States are already sorted via 'orderby: weight' in schema file.
// @todo Loaded States are sorted via 'orderby: weight' in schema file.
$states = parent::loadMultiple();
usort($states, ['Drupal\workflow\Entity\WorkflowState', 'sort']);
// Filter on Wid, if requested, E.g., by Workflow->getStates().
// Set the ID as array key.
......@@ -257,6 +258,22 @@ class WorkflowState extends ConfigEntityBase implements WorkflowStateInterface {
return $result;
}
/**
* {@inheritdoc}
*/
public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) {
/** @var \Drupal\workflow\Entity\WorkflowState $a */
/** @var \Drupal\workflow\Entity\WorkflowState $b */
$a_wid = $a->getWorkflowId();
$b_wid = $b->getWorkflowId();
if ($a_wid == $b_wid) {
$a_weight = $a->getWeight();
$b_weight = $b->getWeight();
return ($a_weight < $b_weight) ? -1 : 1;
}
return ($a_wid < $b_wid) ? -1 : 1;
}
/**
* Deactivate a Workflow State, moving existing content to a given State.
*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment