Skip to content

Commit

Permalink
👌
Browse files Browse the repository at this point in the history
Signed-off-by: Jérémy Marodon <[email protected]>
  • Loading branch information
Th3Mouk committed Sep 16, 2024
1 parent 61faafd commit 1c3f3d2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
18 changes: 9 additions & 9 deletions src/Tree/Strategy/ORM/Nested.php
Original file line number Diff line number Diff line change
Expand Up @@ -577,10 +577,10 @@ public function max(EntityManagerInterface $em, $class, $rootId = 0)
/**
* Shift tree left and right values by delta
*
* @param string $class
* @param int $first
* @param int $delta
* @param int|string $root
* @param string $class
* @param int $first
* @param int $delta
* @param int|string|object|null $root
*
* @phpstan-param class-string $class
*
Expand All @@ -589,11 +589,11 @@ public function max(EntityManagerInterface $em, $class, $rootId = 0)
public function shiftRL(EntityManagerInterface $em, $class, $first, $delta, $root = null)
{
$meta = $em->getClassMetadata($class);
$identifierField = $meta->getSingleIdentifierFieldName();
$config = $this->listener->getConfiguration($em, $class);

if (isset($config['root']) && $root) {
$rootIdentifierField = $meta->getSingleIdentifierFieldName();
$rootId = AbstractWrapper::wrap($root, $em)->getIdentifier();
if (isset($config['root']) && is_object($root)) {
$root = AbstractWrapper::wrap($root, $em)->getIdentifier();
}

$sign = ($delta >= 0) ? ' + ' : ' - ';
Expand All @@ -605,7 +605,7 @@ public function shiftRL(EntityManagerInterface $em, $class, $first, $delta, $roo
if (isset($config['root'])) {
$qb->andWhere($qb->expr()->eq('node.'.$config['root'], ':rid'));
$id = $meta->getIdentifier();
$qb->setParameter('rid', $rootId, $meta->getTypeOfField($rootIdentifierField));
$qb->setParameter('rid', $root, $meta->getTypeOfField($identifierField));
}
$qb->getQuery()->getSingleScalarResult();

Expand All @@ -615,7 +615,7 @@ public function shiftRL(EntityManagerInterface $em, $class, $first, $delta, $roo
->where($qb->expr()->gte('node.'.$config['right'], $first));
if (isset($config['root'])) {
$qb->andWhere($qb->expr()->eq('node.'.$config['root'], ':rid'));
$qb->setParameter('rid', $rootId, $meta->getTypeOfField($rootIdentifierField));
$qb->setParameter('rid', $root, $meta->getTypeOfField($identifierField));
}

$qb->getQuery()->getSingleScalarResult();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class RootAssociationCategoryBinaryUuid
private ?string $title = null;

/**
* @var int|null
* @var int
*
* @Gedmo\TreeLeft
*
Expand All @@ -64,7 +64,7 @@ class RootAssociationCategoryBinaryUuid
private int $lft;

/**
* @var int|null
* @var int
*
* @Gedmo\TreeRight
*
Expand Down Expand Up @@ -100,10 +100,10 @@ class RootAssociationCategoryBinaryUuid
#[ORM\ManyToOne(targetEntity: self::class)]
#[ORM\JoinColumn(name: 'tree_root', referencedColumnName: 'id', onDelete: 'CASCADE')]
#[Gedmo\TreeRoot]
private ?RootAssociationCategoryBinaryUuid$root;
private ?RootAssociationCategoryBinaryUuid $root = null;

/**
* @var int|null
* @var int
*
* @Gedmo\TreeLevel
*
Expand Down

0 comments on commit 1c3f3d2

Please sign in to comment.