From 59d183b3b01566213aea87714aa08c338ad5de77 Mon Sep 17 00:00:00 2001 From: Marc Jauvin Date: Wed, 4 Nov 2020 12:18:22 -0500 Subject: [PATCH] Add Sortable Behavior to ReorderController validateModel (#5268) Checks for the newly added Sortable Behavior as well as the existing Sortable Trait. See https://github.com/octobercms/library/commit/b19deb853fbec8426aa9668b6546fa25245c871c --- modules/backend/behaviors/ReorderController.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/backend/behaviors/ReorderController.php b/modules/backend/behaviors/ReorderController.php index 1795afca0..4b9681972 100644 --- a/modules/backend/behaviors/ReorderController.php +++ b/modules/backend/behaviors/ReorderController.php @@ -214,7 +214,10 @@ class ReorderController extends ControllerBehavior $model = $this->controller->reorderGetModel(); $modelTraits = class_uses($model); - if (isset($modelTraits[\October\Rain\Database\Traits\Sortable::class])) { + if ( + isset($modelTraits[\October\Rain\Database\Traits\Sortable::class]) || + $model->isClassExtendedWith(\October\Rain\Database\Behaviors\Sortable::class) + ) { $this->sortMode = 'simple'; } elseif (isset($modelTraits[\October\Rain\Database\Traits\NestedTree::class])) { @@ -222,7 +225,7 @@ class ReorderController extends ControllerBehavior $this->showTree = true; } else { - throw new ApplicationException('The model must implement the NestedTree or Sortable traits.'); + throw new ApplicationException('The model must implement the Sortable trait/behavior or the NestedTree trait.'); } return $model;