You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.2 KiB
48 lines
1.2 KiB
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/* For licensing terms, see /license.txt */
|
|
|
|
namespace Chamilo\CourseBundle\Repository;
|
|
|
|
use Chamilo\CoreBundle\Traits\Repository\ORM\NestedTreeRepositoryTrait;
|
|
use Chamilo\CourseBundle\Entity\CLpItem;
|
|
use Chamilo\CourseBundle\Traits\NonResourceRepository;
|
|
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
|
|
use Doctrine\Persistence\ManagerRegistry;
|
|
|
|
final class CLpItemRepository extends ServiceEntityRepository
|
|
{
|
|
use NestedTreeRepositoryTrait;
|
|
use NonResourceRepository;
|
|
|
|
public function __construct(ManagerRegistry $registry)
|
|
{
|
|
parent::__construct($registry, CLpItem::class);
|
|
|
|
$this->initializeTreeRepository($this->getEntityManager(), $this->getClassMetadata());
|
|
}
|
|
|
|
public function getRootItem($lpId): ?CLpItem
|
|
{
|
|
return $this->findOneBy([
|
|
'path' => 'root',
|
|
'lp' => $lpId,
|
|
]);
|
|
}
|
|
|
|
public function getTree($lpId)
|
|
{
|
|
$qb = $this->createQueryBuilder('i');
|
|
$qb
|
|
->andWhere('lp = :lp AND path = :path')
|
|
->setParameters([
|
|
'lp' => $lpId,
|
|
'path' => 'root',
|
|
])
|
|
;
|
|
|
|
return $qb->getQuery()->getResult('tree');
|
|
}
|
|
}
|
|
|