|
|
|
|
|
|
|
|
|
|
|
<?php |
|
|
|
|
|
|
|
|
|
|
|
namespace Lc\ShopBundle\Repository; |
|
|
|
|
|
|
|
|
|
|
|
use Doctrine\Common\Persistence\ManagerRegistry; |
|
|
|
|
|
use Doctrine\ORM\EntityManager; |
|
|
|
|
|
use Doctrine\ORM\QueryBuilder; |
|
|
|
|
|
use Lc\ShopBundle\Context\ProductCategoryInterface; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @method ProductCategoryInterface|null find($id, $lockMode = null, $lockVersion = null) |
|
|
|
|
|
* @method ProductCategoryInterface|null findOneBy(array $criteria, array $orderBy = null) |
|
|
|
|
|
* @method ProductCategoryInterface[] findAll() |
|
|
|
|
|
* @method ProductCategoryInterface[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) |
|
|
|
|
|
*/ |
|
|
|
|
|
class ProductCategoryRepository extends BaseRepository |
|
|
|
|
|
{ |
|
|
|
|
|
public function __construct(EntityManager $entityManager) |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
parent::__construct($entityManager, ProductCategoryInterface::class); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static function adminQueryBuilderForTree(BaseRepository $e): QueryBuilder |
|
|
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
return $e->createQueryBuilder('e') |
|
|
|
|
|
->where('e.parent is NULL') |
|
|
|
|
|
->andWhere('e.status >= 0') |
|
|
|
|
|
->orderBy('e.position', 'ASC'); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function findAllParents() |
|
|
|
|
|
{ |
|
|
|
|
|
return $this->createQueryBuilder('e') |
|
|
|
|
|
->where('e.parent is NULL') |
|
|
|
|
|
->andWhere('e.status >= 0') |
|
|
|
|
|
->orderBy('e.position', 'ASC') |
|
|
|
|
|
->getQuery() |
|
|
|
|
|
->getResult(); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// /** |
|
|
|
|
|
// * @return ProductCategory[] Returns an array of ProductCategory objects |
|
|
|
|
|
// */ |
|
|
|
|
|
/* |
|
|
|
|
|
public function findByExampleField($value) |
|
|
|
|
|
{ |
|
|
|
|
|
return $this->createQueryBuilder('p') |
|
|
|
|
|
->andWhere('p.exampleField = :val') |
|
|
|
|
|
->setParameter('val', $value) |
|
|
|
|
|
->orderBy('p.id', 'ASC') |
|
|
|
|
|
->setMaxResults(10) |
|
|
|
|
|
->getQuery() |
|
|
|
|
|
->getResult() |
|
|
|
|
|
; |
|
|
|
|
|
} |
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
/* |
|
|
|
|
|
public function findOneBySomeField($value): ?ProductCategory |
|
|
|
|
|
{ |
|
|
|
|
|
return $this->createQueryBuilder('p') |
|
|
|
|
|
->andWhere('p.exampleField = :val') |
|
|
|
|
|
->setParameter('val', $value) |
|
|
|
|
|
->getQuery() |
|
|
|
|
|
->getOneOrNullResult() |
|
|
|
|
|
; |
|
|
|
|
|
} |
|
|
|
|
|
*/ |
|
|
|
|
|
} |