Add Sortable Behavior to ReorderController validateModel (#5268)

Checks for the newly added Sortable Behavior as well as the existing Sortable Trait. See b19deb853f
This commit is contained in:
Marc Jauvin 2020-11-04 12:18:22 -05:00 committed by GitHub
parent fffa6db8d8
commit 59d183b3b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;