php - TYPO3: How to implement a virtual attribute based on a relationship table?
Get the solution ↓↓↓My question is simpler to what the title suggests, it's the most succinct way I've managed to word it...
What I want to do is: My Project entity is linked to User through a MM table. At the same time, Users are linked to multiple Companies. In theproject-user-mm
table, I've added a field calleduser_company
, which stores a reference to the User's Company through which they are involved with the Project.
I think that this reference to the Company belongs in the Project-User relationship table instead of to the Project table directly because the Project-Company relationship is implicit through the User. Am I correct?
What I want to achive is that at the higher level (Extbase), whenever I callProject->getCompanies
, it fetches all the companies: each company from eachproject-user-mm
table. I don't need any other method (e.g.set
,add
,remove
, ...), since it wouldn't make sense to use them, because the Companies are retrieved implicitly from the relationships with the Users.
What would be the most idiomatic way to do this with TYPO3?
- In the
Project
Model: Besides thegetCompanies
method, do I need acompanies
attribute? - In the
Project
TCA: do I need acompanies
column? In the case that I do, what type should it be?none
? Or maybe another one? This is the trickiest part, I think - In the database: do I just need to put the
user_company
field in theproject-user-mm
table? Or do I also need to put acompanies
field in theproject
table?
Sorry for the extensive post but I wanted to be as clear as possible in my explanation. I would appreciate a lot the help since I cannot find any similar examples online. Thank you in advance!
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: string literal contains an unescaped line break
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Similar questions
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.