| Conditions | 2 |
| Paths | 2 |
| Total Lines | 37 |
| Code Lines | 27 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 6 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 17 | public function findByUserAndViewContext(UserInterface $user, ViewContext $viewContext): array |
||
| 18 | { |
||
| 19 | $subquery = $this->getEntityManager()->createQuery( |
||
| 20 | sprintf( |
||
| 21 | 'SELECT ts.id |
||
| 22 | FROM %s ts |
||
| 23 | JOIN %s ut WITH ts.id = ut.tutorial_step_id |
||
| 24 | WHERE ut.user = :user |
||
| 25 | AND ts.module = :module |
||
| 26 | AND ts.view = :view', |
||
| 27 | TutorialStep::class, |
||
| 28 | UserTutorial::class |
||
| 29 | ) |
||
| 30 | )->setParameters([ |
||
| 31 | 'user' => $user, |
||
| 32 | 'module' => $viewContext->getModule()->value, |
||
| 33 | 'view' => $viewContext->getViewIdentifier(), |
||
| 34 | ]); |
||
| 35 | |||
| 36 | $result = $subquery->getOneOrNullResult(); |
||
| 37 | |||
| 38 | if (!$result) { |
||
| 39 | return []; |
||
| 40 | } |
||
| 41 | |||
| 42 | |||
| 43 | return $this->getEntityManager()->createQuery( |
||
| 44 | sprintf( |
||
| 45 | 'SELECT ts FROM %s ts |
||
| 46 | WHERE ts.module = :module |
||
| 47 | AND ts.view = :view', |
||
| 48 | TutorialStep::class |
||
| 49 | ) |
||
| 50 | )->setParameters([ |
||
| 51 | 'module' => $viewContext->getModule()->value, |
||
| 52 | 'view' => $viewContext->getViewIdentifier(), |
||
| 53 | ])->getResult(); |
||
| 54 | } |
||
| 70 |