Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 14 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
ProjectsRepository | |
0.00% |
0 / 14 |
|
0.00% |
0 / 4 |
56 | |
0.00% |
0 / 1 |
__construct | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
add | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
remove | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
6 | |||
findOneByName | |
0.00% |
0 / 7 |
|
0.00% |
0 / 1 |
6 |
1 | <?php |
2 | |
3 | namespace App\Repository; |
4 | |
5 | use App\Entity\Projects; |
6 | use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository; |
7 | use Doctrine\ORM\NonUniqueResultException; |
8 | use Doctrine\Persistence\ManagerRegistry; |
9 | |
10 | /** |
11 | * @method Projects|null find($id, $lockMode = null, $lockVersion = null) |
12 | * @method Projects|null findOneBy(array $criteria, array $orderBy = null) |
13 | * @method Projects[] findAll() |
14 | * @method Projects[] findBy(array $criteria, array $orderBy = null, $limit = null, $offset = null) |
15 | */ |
16 | class ProjectsRepository extends ServiceEntityRepository |
17 | { |
18 | public function __construct(ManagerRegistry $registry) |
19 | { |
20 | parent::__construct(registry: $registry, entityClass: Projects::class); |
21 | } |
22 | |
23 | public function add(Projects $entity, bool $flush = true): void |
24 | { |
25 | $this->_em->persist($entity); |
26 | if ($flush) { |
27 | $this->_em->flush(); |
28 | } |
29 | } |
30 | |
31 | public function remove(Projects $entity, bool $flush = true): void |
32 | { |
33 | $this->_em->remove($entity); |
34 | if ($flush) { |
35 | $this->_em->flush(); |
36 | } |
37 | } |
38 | |
39 | // /** |
40 | // * @return Projects[] Returns an array of Projects objects |
41 | // */ |
42 | /* |
43 | public function findByExampleField($value) |
44 | { |
45 | return $this->createQueryBuilder('p') |
46 | ->andWhere('p.exampleField = :val') |
47 | ->setParameter('val', $value) |
48 | ->orderBy('p.id', 'ASC') |
49 | ->setMaxResults(10) |
50 | ->getQuery() |
51 | ->getResult() |
52 | ; |
53 | } |
54 | */ |
55 | |
56 | /** |
57 | * @param $value |
58 | */ |
59 | public function findOneByName($value): ?Projects |
60 | { |
61 | try { |
62 | return $this->createQueryBuilder(alias: 'q') |
63 | ->andWhere('q.name = :val') |
64 | ->setParameter(key: 'val', value: $value) |
65 | ->getQuery() |
66 | ->getOneOrNullResult(); |
67 | } catch (NonUniqueResultException $e) { |
68 | dd($e->getMessage()); |
69 | } |
70 | } |
71 | } |