public function getGroupedTargets(?Application $application = null): array
    {
        $environments = $this->getEntityManager()
            ->getRepository(Environment::class)
            ->findAll();

        if ($application) {
            $findBy = ['application' => $application];
        } else {
            $findBy = [];
        }

        $targets = $this->findBy($findBy);

        usort($environments, $this->environmentSorter());
        usort($targets, $this->targetSorter());

        $sorted = [];
        foreach ($environments as $environment) {
            $sorted[$environment->id()] = [
                'environment' => $environment,
                'targets' => [],
            ];
        }

        foreach ($targets as $target) {
            $id = $target->environment()->id();
            $sorted[$id]['targets'][] = $target;
        }

        return array_filter($sorted, function ($e) {
            return count($e['targets']) !== 0;
        });
    }
public function getGroupedTargets(?Application $application = null): array
    {
        $environments = $this->getEntityManager()
            ->getRepository(Environment::class)
            ->findAll();

        if ($application) {
            $findBy = ['application' => $application];
        } else {
            $findBy = [];
        }

        $targets = $this->findBy($findBy);

        usort($environments, $this->environmentSorter());
        usort($targets, $this->targetSorter());

        $sorted = [];
        foreach ($environments as $environment) {
            $sorted[$environment->id()] = [
                'environment' => $environment,
                'targets' => [],
            ];
        }

        foreach ($targets as $target) {
            $id = $target->environment()->id();
            $sorted[$id]['targets'][] = $target;
        }

        return array_filter($sorted, function ($e) {
            return count($e['targets']) !== 0;
        });
    }
public function getGroupedTargets ( ? Application $ application = null ) : array { $ environments = $ this -> getEntityManager ( ) -> getRepository ( Environment :: class ) -> findAll ( ) ; if ( $ application ) { $ findBy = [ 'application' => $ application ] ; } else { $ findBy = [ ] ; } $ targets = $ this -> findBy ( $ findBy ) ; usort ( $ environments , $ this -> environmentSorter ( ) ) ; usort ( $ targets , $ this -> targetSorter ( ) ) ; $ sorted = [ ] ; foreach ( $ environments as $ environment ) { $ sorted [ $ environment -> id ( ) ] = [ 'environment' => $ environment , 'targets' => [ ] , ] ; } foreach ( $ targets as $ target ) { $ id = $ target -> environment ( ) -> id ( ) ; $ sorted [ $ id ] [ 'targets' ] [ ] = $ target ; } return array_filter ( $ sorted , function ( $ e ) { return count ( $ e [ 'targets' ] ) !== 0 ; } ) ; }
Get all targets sorted into environments.

@param Application|null $application

@return array
Get all targets sorted into environments .