[TYPO3-extbase] Query Language: Filter on child objects

DirkHo dirk_studivz at web.de
Wed Aug 12 08:04:36 CEST 2015


Hi Markus,

thanks for your fast response.

Probably you got me wrong. What I want to do is the following:

class League extends... {
     /**
      * @var ... @injection ...
      */
     protected $leagueRepository;

     /**
      * @var ...\Competition>
      */
     private $competitions;

     public function listAction() {
          $league = $this->leagueRepository->findAll();
          $this->view->assign('league', $league);
     }
}

class Competition extends ... {
     /**
      * @var ...\MatchDay>
      */
     private $matchDays;
}

class MatchDay extends ... {
     /**
      * @var ...\Match>
      */
     private $matchs;
}

class Match extends ... {
     /**
      * @var ...\Bet>
      */
     private $bets;
}

class Bet extends ... {
     /**
      * @var ...\FeUser>
      */
     private $bettor;
}

In the listAction of class League I want to add a filter, e.g.

          $league = $this->leagueRepository
  			->filterByCompetitionMatchDayMatchBetBettor($intBettorId)
			->findAll();

Or is my problem that I do eager fetching (probably this makes no sense 
when I have some bettors and several matches)? How could I lazy fetch a 
league, its competitions, matchdays, matches and the bets of a single 
user? How would this work in my case?

Would be nice if you could help me. I again checked my extension 
development book but there I didn't find a solution for that.

Thanks and kind regards,

Dirk

Am 11.08.2015 um 21:50 schrieb Markus Guenther:
> Hi dirk it is a bit late. So I just write a short message from the phone.
>
> If you have a model with the relation to the frontendUser you are able
> to call something like
>
> $bets = $this->betRepository->findByFrontendUser($user);
>
> This can be modified in the controller or just assigned to the view. If
> this does not help you.
>
> Ask the guys in the extbase channel on slack.
>
> Greets Markus
>
>
> https://forger.typo3.org/slack
>
> Von meinem iPhone gesendet
>
> Am 11.08.2015 um 21:07 schrieb DirkHo <dirk_studivz at web.de
> <mailto:dirk_studivz at web.de>>:
>
>> Hi all,
>>
>> I'm just writing my first extension and have a question where I found
>> no google answer for. Hopefully you can and are willing to help me:
>>
>> I create a sports bet extension (nothing commercial, in german it's
>> "Tippspiel"). My Model looks as follows: Several leagues can be
>> created, each league has at least one competition, each competition
>> has at least one match day, each match day contains one match and
>> every match may have several bets. Each bet belongs to one customer.
>>
>> Currently I iterate over every league, every competition, every
>> matchday, every match and every bet in fluid and output it.
>>
>> What I now want to do is to filter the bets to show only those bets
>> belonging to the current frontend user. Is it possible to filter the
>> objects to only show those that belong to that user? So that I still
>> can iterate starting with the leagues but only matches are shown that
>> have bets from that user and as child objects only the bets of that user?
>>
>> Thanks and kind regards,
>>
>> Dirk
>> _______________________________________________
>> TYPO3-team-extbase mailing list
>> TYPO3-team-extbase at lists.typo3.org
>> <mailto:TYPO3-team-extbase at lists.typo3.org>
>> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-team-extbase



More information about the TYPO3-team-extbase mailing list