reorder position on folder and category tables before delete action

This commit is contained in:
Manuel Raynaud
2013-10-01 18:02:44 +02:00
parent bc33827c05
commit 6d8e6e1921
3 changed files with 9 additions and 2 deletions

View File

@@ -106,7 +106,7 @@ class Category extends BaseCategory
public function preDelete(ConnectionInterface $con = null)
{
$this->dispatchEvent(TheliaEvents::BEFORE_DELETECATEGORY, new CategoryEvent($this));
$this->reorderBeforeDelete();
return true;
}

View File

@@ -94,7 +94,7 @@ class Folder extends BaseFolder
public function preDelete(ConnectionInterface $con = null)
{
$this->dispatchEvent(TheliaEvents::BEFORE_DELETEFOLDER, new FolderEvent($this));
$this->reorderBeforeDelete();
return true;
}

View File

@@ -198,4 +198,11 @@ trait PositionManagementTrait {
}
}
}
protected function reorderBeforeDelete()
{
$this->createQuery()
->filterByParent($this->getParent())
->update(array('Position' => '(position-1)'));
}
}