Skip to content

Conversation

@kachar
Copy link
Contributor

@kachar kachar commented Apr 29, 2015

$auth = $sm->get('zfcuser_auth_service');

if ($auth->hasIdentity()) {       // Mapper is called here
    $user = $auth->getIdentity(); // instead of here
    // ...
}
// Zend\Authentication\AuthenticationService

public function hasIdentity()
{
    return !$this->getStorage()->isEmpty();  // Mapper reads the data inside the isEmpty check
}

public function getIdentity()
{
    $storage = $this->getStorage();

    if ($storage->isEmpty()) {
        return null;
    }

    return $storage->read(); // Here we are using already cached data
}

What do you think about this proposal?

@kachar kachar changed the title IsEmpty check in storage should not trigger additional read from the mapper IsEmpty check in storage should not trigger reading from the mapper Apr 29, 2015
@Danielss89 Danielss89 added this to the 1.4.0 milestone Dec 12, 2015
Danielss89 added a commit that referenced this pull request Dec 12, 2015
IsEmpty check in storage should not trigger reading from the mapper
@Danielss89 Danielss89 merged commit 6e286ef into ZF-Commons:1.x Dec 12, 2015
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

Successfully merging this pull request may close these issues.

2 participants