Replies: 2 comments 2 replies
-
When its too complicated to use links (we can't cover all use cases) use: |
Beta Was this translation helpful? Give feedback.
0 replies
-
Yes @soyuka I used it. I found a solution on the third file, but not understand why works! uriTemplate: '/company/{id}/employee/{employeeId}/tasks',
uriVariables: [
'id' => new Link(fromClass: Company::class, toProperty: 'employee', security: "is_granted('manage', employee)"),
'employeeId' => new Link(fromClass: CompanyEmployee::class, toProperty: 'employee'),
],
stateOptions: new Options(handleLinks: [CompanyEmployeeTask::class, 'handleLinks']), public static function handleLinks(QueryBuilder $queryBuilder, array $uriVariables, QueryNameGeneratorInterface $queryNameGenerator, array $context): void
{
$queryBuilder
->join($queryBuilder->getRootAliases()[0].'.employees', 'e')
->andWhere('e.company = :companyId')
->andWhere('e.id = :employeeId')
->setParameter('companyId', $uriVariables['id'])
->setParameter('employeeId', $uriVariables['employeeId'])
;
} This is very strange to use employee on this level |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I’m trying to manage level 3 sub-resources. I’m having trouble finding a solution.
The context with this 3 files:
What params I need to add in the third file (CompanyEmployeeTasks.php) to manage the Company?
It's not possible to do this nesting?
I can manage the collection of CompanyEmployeeTask with a:
But the IRI of the Get can't be generated with this error:
Unable to generate an IRI for the item of type "App\\Entity\\CompanyEmployeeTask"
In first I write on CompanyEmployeeTask:
But I have the logic error:
Can't get a way to read the property "company" in class "App\\Entity\\CompanyEmployeeTask"
If anyone have more informations, it can be a pleasure!
Beta Was this translation helpful? Give feedback.
All reactions