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

RFC: Remove IdentityInterface as type hint on ZF\Rest\Resource #4

Open
weierophinney opened this issue Dec 31, 2019 · 0 comments
Open

Comments

@weierophinney
Copy link
Contributor

Currently, the setIdentity method requires the IdentityInterface (https://github.com/zfcampus/zf-rest/blob/master/src/Resource.php#L82).

This makes a lot of assumptions around what identity means to consuming applications. It makes absolutely no sense in our use case to implement the 15 methods declared in the Zend\MvcAuth\IdentityInterface and is keeping us from using the getIdentity() method on the Resource base class.

I am suggesting that we change:

    /**
     * @param null|IdentityInterface $identity
     * @return self
     */
    public function setIdentity(IdentityInterface $identity = null)
    {
        $this->identity = $identity;
        return $this;
    }

To

    /**
     * @param null|object $identity
     * @return self
     */
    public function setIdentity($identity = null)
    {
        $this->identity = $identity;
        return $this;
    }

This way, I can set our own identity object via the MvcEvent like so

$event->setParam('ZF\MvcAuth\Identity', $authService->getIdentity());

I realize that this was likely done for some other module that performs authentication/authorization if that is the case, I strongly feel those modules should enforce the interface they need instead of the Resource object.


Originally posted by @steverhoades at zfcampus/zf-rest#91

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

1 participant