public function get($wantedPackageVersions, $wantedLocales)
    {
        $packageVersions = array_values(array_unique($this->getPackageVersions($wantedPackageVersions)));
        $locales = array_values(array_unique($this->getLocales($wantedLocales)));
        $qb = $this->createQueryBuilder('s');
        if (count($packageVersions) === 1) {
            $qb->andWhere('s.packageVersion = :packageVersion')->setParameter('packageVersion', $packageVersions[0]);
        } else {
            $or = $qb->expr()->orX();
            foreach ($packageVersions as $i => $pv) {
                $or->add("s.packageVersion = :packageVersion$i");
                $qb->setParameter("packageVersion$i", $pv);
            }
            $qb->andWhere($or);
        }
        if (count($locales) === 1) {
            $qb->andWhere('s.locale = :locale');
            $qb->setParameter('locale', $locales[0]);
        } else {
            $or = $qb->expr()->orX();
            foreach ($locales as $i => $l) {
                $or->add("s.locale = :locale$i");
                $qb->setParameter("locale$i", $l);
            }
            $qb->andWhere($or);
        }

        $result = $qb->getQuery()->getResult();
        /* @var StatsEntity[] $result */
        $missingLocalesForPackageVersions = [];
        foreach ($packageVersions as $packageVersion) {
            foreach ($locales as $locale) {
                $found = false;
                foreach ($result as $stats) {
                    if ($stats->getPackageVersion()->getID() === $packageVersion->getID() && $stats->getLocale()->getID() === $locale->getID()) {
                        $found = true;
                        break;
                    }
                }
                if ($found === false) {
                    if (!isset($missingLocalesForPackageVersions[$packageVersion->getID()])) {
                        $missingLocalesForPackageVersions[$packageVersion->getID()] = ['packageVersion' => $packageVersion, 'locales' => []];
                    }
                    $missingLocalesForPackageVersions[$packageVersion->getID()]['locales'][] = $locale;
                }
            }
        }
        foreach ($missingLocalesForPackageVersions as $missingLocalesForPackageVersion) {
            $result = array_merge($result, $this->build($missingLocalesForPackageVersion['packageVersion'], $missingLocalesForPackageVersion['locales']));
        }

        return array_values($result);
    }
public function get($wantedPackageVersions, $wantedLocales)
    {
        $packageVersions = array_values(array_unique($this->getPackageVersions($wantedPackageVersions)));
        $locales = array_values(array_unique($this->getLocales($wantedLocales)));
        $qb = $this->createQueryBuilder('s');
        if (count($packageVersions) === 1) {
            $qb->andWhere('s.packageVersion = :packageVersion')->setParameter('packageVersion', $packageVersions[0]);
        } else {
            $or = $qb->expr()->orX();
            foreach ($packageVersions as $i => $pv) {
                $or->add("s.packageVersion = :packageVersion$i");
                $qb->setParameter("packageVersion$i", $pv);
            }
            $qb->andWhere($or);
        }
        if (count($locales) === 1) {
            $qb->andWhere('s.locale = :locale');
            $qb->setParameter('locale', $locales[0]);
        } else {
            $or = $qb->expr()->orX();
            foreach ($locales as $i => $l) {
                $or->add("s.locale = :locale$i");
                $qb->setParameter("locale$i", $l);
            }
            $qb->andWhere($or);
        }

        $result = $qb->getQuery()->getResult();
        /* @var StatsEntity[] $result */
        $missingLocalesForPackageVersions = [];
        foreach ($packageVersions as $packageVersion) {
            foreach ($locales as $locale) {
                $found = false;
                foreach ($result as $stats) {
                    if ($stats->getPackageVersion()->getID() === $packageVersion->getID() && $stats->getLocale()->getID() === $locale->getID()) {
                        $found = true;
                        break;
                    }
                }
                if ($found === false) {
                    if (!isset($missingLocalesForPackageVersions[$packageVersion->getID()])) {
                        $missingLocalesForPackageVersions[$packageVersion->getID()] = ['packageVersion' => $packageVersion, 'locales' => []];
                    }
                    $missingLocalesForPackageVersions[$packageVersion->getID()]['locales'][] = $locale;
                }
            }
        }
        foreach ($missingLocalesForPackageVersions as $missingLocalesForPackageVersion) {
            $result = array_merge($result, $this->build($missingLocalesForPackageVersion['packageVersion'], $missingLocalesForPackageVersion['locales']));
        }

        return array_values($result);
    }
public function get ( $ wantedPackageVersions , $ wantedLocales ) { $ packageVersions = array_values ( array_unique ( $ this -> getPackageVersions ( $ wantedPackageVersions ) ) ) ; $ locales = array_values ( array_unique ( $ this -> getLocales ( $ wantedLocales ) ) ) ; $ qb = $ this -> createQueryBuilder ( 's' ) ; if ( count ( $ packageVersions ) === 1 ) { $ qb -> andWhere ( 's.packageVersion = :packageVersion' ) -> setParameter ( 'packageVersion' , $ packageVersions [ 0 ] ) ; } else { $ or = $ qb -> expr ( ) -> orX ( ) ; foreach ( $ packageVersions as $ i => $ pv ) { $ or -> add ( "s.packageVersion = :packageVersion$i" ) ; $ qb -> setParameter ( "packageVersion$i" , $ pv ) ; } $ qb -> andWhere ( $ or ) ; } if ( count ( $ locales ) === 1 ) { $ qb -> andWhere ( 's.locale = :locale' ) ; $ qb -> setParameter ( 'locale' , $ locales [ 0 ] ) ; } else { $ or = $ qb -> expr ( ) -> orX ( ) ; foreach ( $ locales as $ i => $ l ) { $ or -> add ( "s.locale = :locale$i" ) ; $ qb -> setParameter ( "locale$i" , $ l ) ; } $ qb -> andWhere ( $ or ) ; } $ result = $ qb -> getQuery ( ) -> getResult ( ) ; /* @var StatsEntity[] $result */ $ missingLocalesForPackageVersions = [ ] ; foreach ( $ packageVersions as $ packageVersion ) { foreach ( $ locales as $ locale ) { $ found = false ; foreach ( $ result as $ stats ) { if ( $ stats -> getPackageVersion ( ) -> getID ( ) === $ packageVersion -> getID ( ) && $ stats -> getLocale ( ) -> getID ( ) === $ locale -> getID ( ) ) { $ found = true ; break ; } } if ( $ found === false ) { if ( ! isset ( $ missingLocalesForPackageVersions [ $ packageVersion -> getID ( ) ] ) ) { $ missingLocalesForPackageVersions [ $ packageVersion -> getID ( ) ] = [ 'packageVersion' => $ packageVersion , 'locales' => [ ] ] ; } $ missingLocalesForPackageVersions [ $ packageVersion -> getID ( ) ] [ 'locales' ] [ ] = $ locale ; } } } foreach ( $ missingLocalesForPackageVersions as $ missingLocalesForPackageVersion ) { $ result = array_merge ( $ result , $ this -> build ( $ missingLocalesForPackageVersion [ 'packageVersion' ] , $ missingLocalesForPackageVersion [ 'locales' ] ) ) ; } return array_values ( $ result ) ; }
Get some stats about one or more package versions and one or more locales.

@param PackageVersionEntity|PackageVersionEntity[]|array|array[array] $wantedPackageVersions
@param LocaleEntity|LocaleEntity[]|string|string[] $wantedLocales

@return StatsEntity[]
Get some stats about one or more package versions and one or more locales .