commit 78f8dcc3d68a4cb1e3999ff38d129acdb1b0c0b0 parent de3935fef2fa7b7f0111e6e935d9254ef9fee07a Author: Felicitus <felicitus@felicitus.org> Date: Sun, 25 Mar 2012 03:07:02 +0200 Don't bail out if a new category is added and no category path was set. Diffstat:
M | src/backend/de/RaumZeitLabor/PartKeepr/Category/AbstractCategoryManager.php | | | 19 | ++++++++++++++----- |
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/src/backend/de/RaumZeitLabor/PartKeepr/Category/AbstractCategoryManager.php b/src/backend/de/RaumZeitLabor/PartKeepr/Category/AbstractCategoryManager.php @@ -17,6 +17,10 @@ abstract class AbstractCategoryManager extends Singleton { */ private $nodeManager; + /** + * Holds the FQCN of the target entity + * @var de\RaumZeitLabor\PartKeepr\Category\AbstractCategory + */ protected $categoryClass = "de\RaumZeitLabor\PartKeepr\Category\AbstractCategory"; /** @@ -97,18 +101,23 @@ abstract class AbstractCategoryManager extends Singleton { */ public function addCategory (AbstractCategory $category) { $parent = $category->getParent(); - + if ($parent == 0) { $parent = $this->getRootNode(); - } else { - $parent = PartKeepr::getEM()->find($this->categoryClass, $parent); - $parent = new NodeWrapper($parent, $this->getNodeManager()); } - return $parent->addChild($category); + $node = $parent->addChild($category); + + // Force category path update + $this->updateCategoryPaths($node); + + // Flush the category path changes + PartKeepr::getEM()->flush(); + + return $node; } /**