i have the entity below in Api Platform and i want to know if there is an idiomatic way to get all of the critical question of the logged user (an normal user logged with the jwt token) without using processor or custom operation.
<?php
namespace AppEntity;
use DoctrineORMMapping as ORM;
#[ORMTable(name: 'critical_question')]
#[ORMIndex(name: 'fk_criticals_question_user1_idx', columns: ['user_id'])]
#[ORMIndex(name: 'fk_criticals_question_question1_idx', columns: ['question_id'])]
#[ORMEntity]
class CriticalQuestion
{
#[ORMColumn(name: 'id', type: 'integer', nullable: false)]
#[ORMId]
#[ORMGeneratedValue(strategy: 'IDENTITY')]
private int $id;
#[ORMColumn(name: 'correct_times', type: 'integer', nullable: false)]
private int $correctTimes;
#[ORMManyToOne(targetEntity: Question::class)]
#[ORMJoinColumn(name: 'question_id', referencedColumnName: 'id')]
#[ORMJoinColumn(name: 'question_id', referencedColumnName: 'id')]
private Question $question;
#[ORMJoinColumn(name: 'user_id', referencedColumnName: 'id')]
#[ORMManyToOne(targetEntity: User::class)]
#[ORMJoinColumn(name: 'user_id', referencedColumnName: 'id')]
private User $user;
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @param int $id
*/
public function setId(int $id): void
{
$this->id = $id;
}
/**
* @return Question
*/
public function getQuestion(): Question
{
return $this->question;
}
/**
* @param Question $question
*/
public function setQuestion(Question $question): void
{
$this->question = $question;
}
/**
* @return int
*/
public function getCorrectTimes(): int
{
return $this->correctTimes;
}
}
I just want to know if there is a simple way to do it, because i used it for speed up the process of building API but for most of the use case that i have in my application i use custom operation with custom repositories, or in some cases i used processor.
Unfortunately the documentation is not that well explaining topics, or maybe it’s just my problem.