1313namespace App \Entity ;
1414
1515use App \FilterList \FilterLists ;
16+ use App \FilterList \FilterSources ;
1617use Doctrine \Bundle \DoctrineBundle \Repository \ServiceEntityRepository ;
1718use Doctrine \DBAL \ArrayParameterType ;
1819use Doctrine \Persistence \ManagerRegistry ;
@@ -31,11 +32,13 @@ public function __construct(
3132 /**
3233 * @return list<FilterListEntry>
3334 */
34- public function getEntriesInList (FilterLists $ list ): array
35+ public function getEntriesInList (FilterLists $ list, FilterSources $ source ): array
3536 {
3637 return $ this ->createQueryBuilder ('fl ' )
3738 ->where ('fl.list = :list ' )
39+ ->andWhere ('fl.source = :source ' )
3840 ->setParameter ('list ' , $ list )
41+ ->setParameter ('source ' , $ source )
3942 ->getQuery ()
4043 ->getResult ();
4144 }
@@ -47,29 +50,31 @@ public function getPackageVersionsFlaggedAsMalwareForPackage(Package $package):
4750 {
4851 return $ this ->createQueryBuilder ('fl ' )
4952 ->where ('fl.packageName = :packageName ' )
50- ->andWhere ('fl.list IN (:lists) ' )
53+ ->andWhere ('fl.list = :malware ' )
5154 ->setParameter ('packageName ' , $ package ->getName ())
52- ->setParameter ('lists ' , FilterLists::malwareListsValues (), ArrayParameterType:: STRING )
55+ ->setParameter ('malware ' , FilterLists::MALWARE )
5356 ->getQuery ()
5457 ->getResult ();
5558 }
5659
5760 /**
5861 * @return list<FilterListEntry>
5962 */
60- public function getPackageEntries (string $ packageName ): array
63+ public function getPackageEntries (string $ packageName, FilterLists $ list ): array
6164 {
6265 return $ this ->createQueryBuilder ('fl ' )
6366 ->where ('fl.packageName = :packageName ' )
67+ ->andWhere ('fl.list = :list ' )
6468 ->setParameter ('packageName ' , $ packageName )
69+ ->setParameter ('list ' , $ list )
6570 ->getQuery ()
6671 ->getResult ();
6772 }
6873
6974 /**
7075 * @param array<string> $packageNames
7176 *
72- * @return array<string, non-empty-list<array{version: string, list: string, reason: string|null, publicId: string|null}>>
77+ * @return array<string, non-empty-list<array{version: string, list: string, reason: string|null, publicId: string|null, source: string }>>
7378 */
7479 public function getAllPackageEntriesMap (array $ packageNames ): array
7580 {
@@ -86,6 +91,7 @@ public function getAllPackageEntriesMap(array $packageNames): array
8691 'list ' => $ entry ->getList ()->value ,
8792 'reason ' => $ entry ->getReason (),
8893 'publicId ' => $ entry ->getPublicId (),
94+ 'source ' => $ entry ->getSource ()->value ,
8995 ];
9096 }
9197
0 commit comments