Skip to content

Commit

Permalink
Changed usage of DocumentTrait attributes from public to setters/gett…
Browse files Browse the repository at this point in the history
…ers.
  • Loading branch information
gimikus committed Dec 2, 2014
1 parent cb3d604 commit b4c12fc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
10 changes: 5 additions & 5 deletions Service/CategoryService.php
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private function buildChildNode($node, $references, $maxLevel)
if ($maxLevel == 0 || $level <= $maxLevel) {
$node->setLevel($level);
$node->setParent($references[$node->getParentId()]);
$references[$node->getParentId()]->setChild($node, $node->id);
$references[$node->getParentId()]->setChild($node, $node->getId());
}
}
}
Expand Down Expand Up @@ -129,7 +129,7 @@ public function getCategory($id)
private function buildRootNode($node, $tree, $level)
{
$node->setLevel($level);
$tree[$node->id] = $node;
$tree[$node->getId()] = $node;
}

/**
Expand All @@ -142,12 +142,12 @@ private function buildRootNode($node, $tree, $level)
*/
private function buildNode($node, $references, $tree, $maxLevel)
{
if ($node->id == $this->getCurrentCategoryId()) {
if ($node->getId() == $this->getCurrentCategoryId()) {
$node->setCurrent(true);
$this->currentLeaf = $node;
}

$references[$node->id] = $node;
$references[$node->getId()] = $node;

if ($node->getParentId() == self::ROOT_CATEGORY_ID) {
$this->buildRootNode($node, $tree, 1);
Expand Down Expand Up @@ -306,7 +306,7 @@ protected function findPartialTree($tree, $categoryId)
{
/** @var CategoryTrait|DocumentTrait $node */
foreach ($tree as $node) {
if ($node->id == $categoryId) {
if ($node->getId() == $categoryId) {
return [$node];
}
if ($node->getChildren()) {
Expand Down
3 changes: 2 additions & 1 deletion Tests/Unit/Service/CategoryServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ public function testSetGetCurrentCategoryId()
protected function buildCategory($category)
{
$cat = new Category();
$cat->id = $category['id'];
$cat->setId($category['id']);
$cat->setActive($category['is_active']);
$cat->setSort($category['sort']);
$cat->setLeft($category['left']);
Expand Down Expand Up @@ -359,6 +359,7 @@ public function testGetCurrentCategoryDocument(array $data)
$expected = $data['cat42'];
$expected->setCurrent(true);
$expected->setExpanded(true);

$expected->getParent()->setExpanded(true);

$leaf = $service->getCurrentCategoryDocument();
Expand Down

0 comments on commit b4c12fc

Please sign in to comment.