Fixed reordering flex pages

This commit is contained in:
Matias Griese
2020-03-03 20:17:44 +02:00
parent 0bcbe39521
commit d285eda4c2
2 changed files with 13 additions and 13 deletions

View File

@@ -255,29 +255,25 @@ class PageObject extends FlexPageObject
/** @var PageCollection|null $siblings */
$siblings = $siblings->getCollection()->withOrdered()->orderBy(['order' => 'ASC']);
// Remove old copy of the current page from the siblings list.
$storageKey = $this->getStorageKey();
if ($storageKey !== null) {
$siblings->remove($storageKey);
}
$filesystem = Filesystem::getInstance(false);
$oldParentKey = ltrim($filesystem->dirname("/$storageKey"), '/');
$newParentKey = $this->getProperty('parent_key');
$isMoved = $oldParentKey !== $newParentKey;
$order = !$isMoved ? $this->order() : false;
foreach ($siblings as $sibling) {
$basename = basename($sibling->getKey());
if (!in_array($basename, $ordering, true)) {
$ordering[] = $basename;
if ($storageKey !== null) {
if ($order) {
// Add current page back to the list if it's ordered.
$siblings->set($storageKey, $this);
} else {
// Remove old copy of the current page from the siblings list.
$siblings->remove($storageKey);
}
}
// Add current page back to the list if it's ordered.
if ($order !== false) {
$siblings->set($storageKey, $this);
$basename = basename($this->getKey());
foreach ($siblings as $sibling) {
$basename = basename($sibling->getKey());
if (!in_array($basename, $ordering, true)) {
$ordering[] = $basename;
}

View File

@@ -152,6 +152,10 @@ trait PageTranslateTrait
}
}
if ($language === '') {
}
return $language;
}