Foysal Vai
Foysal Vai

Reputation: 1363

ZF 2 with zfcuser

I am using zfcuser module of ZF 2. I would like to catch the provider name (like facebook,google,twitter) in VIEW. How can I get this ?? I searched a lot in google but could not find.

Upvotes: 0

Views: 109

Answers (1)

Crisp
Crisp

Reputation: 11447

You can test if the user is connected to a provider by calling the scnUserProvider view helper in your view.

It needs a user entity as its first parameter, which you can get from ZfcUsers zfcUserIdentity view helper

(I'm assuming you're displaying this info about the current user, to the current user, otherwise you'll need to provide your view with the user entity in question)

Second parameter is the name of the provider to test against (like facebook,google,twitter)

The provider returns either a provider entity, or false if the user isn't connected to the provider.

So, in your user view, you'd do something like this ...

<?php if ($twitter = $this->scnUserProvider($this->zfcUserIdentity(), 'twitter')) : ?>
    <div>
        <p>Connected with : Twitter</p>
        <p>Id used: <?= $twitter->getProviderId(); ?></p>
    </div>
<?php endif; ?>

Upvotes: 1

Related Questions