Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get Contact person from assigned fe_user #80

Open
X-Tender opened this issue May 27, 2020 · 4 comments
Open

How to get Contact person from assigned fe_user #80

X-Tender opened this issue May 27, 2020 · 4 comments
Assignees

Comments

@X-Tender
Copy link

Hi,

When I create a Person I can assign it to a fe_user. But how do I get the Person from the fe_user? I hoped to find an additional option in the fe_user wehre I can assign a Person so when I get the currently logged in fe_user I can also access the Person data.

@extcode
Copy link
Owner

extcode commented May 28, 2020

Hi. Can you explain what you're trying to solve?
Do you need the contact data in the controller or a view?

@extcode extcode self-assigned this May 28, 2020
@X-Tender
Copy link
Author

Yes, I achieved it currently via a extended FrontUser Model whre I add a custom field with the foreign table tx_contacts_domain_model_contact so now I can do:

$user = $this->frontendUserRepository->findByUid($GLOBALS['TSFE']->fe_user->user['uid']);
 \TYPO3\CMS\Extbase\Utility\DebuggerUtility::var_dump($user->getContact()->getAddresses());

I thought this would be already included in the extension.
Or how would you get the assigned contact from a FrontendUser?

@X-Tender
Copy link
Author

X-Tender commented Jun 2, 2020

I ran into an another problem.
I create a new Contact in my controller and now I would like to assign a fe_user to the contact.
In the typo3 BE its not a problem, there's the Dropdown but there is no setUser method in the Contact model.
Is it possible without building a sql and set the uid of the fe_user column manualy?

@X-Tender
Copy link
Author

X-Tender commented Jun 9, 2020

So thats how I make this currently happen

$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable('tx_contacts_domain_model_contact');
$queryBuilder
    ->update('tx_contacts_domain_model_contact')
    ->where(
        $queryBuilder->expr()->eq('uid', $queryBuilder->createNamedParameter($newContact->getUid()))
    )
    ->set('fe_user', $user->getUid())
    ->execute();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants