Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
JDruery committed Aug 26, 2024
1 parent 436a6e8 commit 30bbe08
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 25 deletions.
16 changes: 7 additions & 9 deletions src/Tree/Strategy/ORM/Closure.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,6 @@ public function processPostPersist($em, $entity, AdapterInterface $ea)

foreach ($this->pendingChildNodeInserts[$emHash] as $node) {
$nodeClass = get_class($node);
//print_r("$nodeClass $entityClass\n");
if ($entityClass !== $nodeClass) continue;
unset($this->pendingChildNodeInserts[$emHash][spl_object_id($node)]);
$meta = $em->getClassMetadata(get_class($node));
Expand Down Expand Up @@ -365,15 +364,14 @@ public function processPostPersist($em, $entity, AdapterInterface $ea)
$levelProp->setValue($node, 1);
}

//print_r($entries);
foreach ($entries as $key => $closure) {
//$ancestorColumnName = $entriesMeta[$key]['ancestorColumnName'];
//$descendantColumnName = $entriesMeta[$key]['descendantColumnName'];
//$existing = $em->getRepository($entriesMeta[$key]['class'])->findBy([
// $ancestorColumnName => $closure[$ancestorColumnName],
// $descendantColumnName => $closure[$descendantColumnName],
//]);
//if (count($existing)) continue;
$ancestorColumnName = $entriesMeta[$key]['ancestorColumnName'];
$descendantColumnName = $entriesMeta[$key]['descendantColumnName'];
$existing = $em->getRepository($entriesMeta[$key]['class'])->findBy([
$ancestorColumnName => $closure[$ancestorColumnName],
$descendantColumnName => $closure[$descendantColumnName],
]);
if (count($existing)) continue;
if (!$em->getConnection()->insert($closureTable, $closure)) {
throw new RuntimeException('Failed to insert new Closure record');
}
Expand Down
18 changes: 2 additions & 16 deletions tests/Gedmo/Tree/Issue/Issue2652Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,11 @@
use Gedmo\Tests\Tool\BaseTestCaseORM;
use Gedmo\Tests\Tree\Fixture\Closure\Category;
use Gedmo\Tests\Tree\Fixture\Closure\CategoryClosure;
use Gedmo\Tests\Tree\Fixture\Closure\CategoryWithoutLevel;
use Gedmo\Tests\Tree\Fixture\Closure\CategoryWithoutLevelClosure;
use Gedmo\Tests\Tree\Fixture\Closure\News;
use Gedmo\Tests\Tree\Fixture\Closure\Person;
use Gedmo\Tests\Tree\Fixture\Closure\PersonClosure;
use Gedmo\Tests\Tree\Fixture\Closure\User;
use Gedmo\Tests\Tree\Fixture\Issue2652\Category2;
use Gedmo\Tests\Tree\Fixture\Issue2652\Category2Closure;
use Gedmo\Tree\Strategy\ORM\Closure;
use Gedmo\Tree\TreeListener;

use Gedmo\Tests\Tree\Fixture\Issue2652\Category2;
use Gedmo\Tests\Tree\Fixture\Issue2652\Category2Closure;

/**
* These are tests for Tree behavior
Expand All @@ -38,13 +32,6 @@ final class Issue2652Test extends BaseTestCaseORM
{
public const CATEGORY = Category::class;
public const CLOSURE = CategoryClosure::class;
public const PERSON = Person::class;
public const USER = User::class;
public const PERSON_CLOSURE = PersonClosure::class;
public const NEWS = News::class;
public const CATEGORY_WITHOUT_LEVEL = CategoryWithoutLevel::class;
public const CATEGORY_WITHOUT_LEVEL_CLOSURE = CategoryWithoutLevelClosure::class;

public const CATEGORY2 = Category2::class;
public const CLOSURE2 = Category2Closure::class;

Expand All @@ -71,7 +58,6 @@ public function testAddMultipleEntityTypes(): void
$repo = $this->em->getRepository(self::CATEGORY);

$food = $repo->findOneBy(['title' => 'Food']);
print_r($food);
$dql = 'SELECT c FROM '.self::CLOSURE.' c';
$dql .= ' WHERE c.ancestor = :ancestor';
$query = $this->em->createQuery($dql);
Expand Down

0 comments on commit 30bbe08

Please sign in to comment.