eZ\Publish\Core\MVC\Symfony\Security\User\Identity::setInformation PHP Method

setInformation() public method

Registers an information in the identity.
public setInformation ( string $informationName, scalar $informationValue )
$informationName string
$informationValue scalar
    public function setInformation($informationName, $informationValue)
    {
        $this->identityInfo[$informationName] = $informationValue;
        $this->resetHash();
    }

Usage Example

Example #1
0
 /**
  * @covers eZ\Publish\Core\MVC\Symfony\Security\User\Identity::__construct
  * @covers eZ\Publish\Core\MVC\Symfony\Security\User\Identity::setInformation
  * @covers eZ\Publish\Core\MVC\Symfony\Security\User\Identity::getHash
  */
 public function testGetHash()
 {
     $identity = new Identity();
     $identity->setInformation('foo', 'bar');
     $hash1 = $identity->getHash();
     $this->assertInternalType('string', $hash1);
     $identity->setInformation('truc', 'muche');
     $hash2 = $identity->getHash();
     $this->assertInternalType('string', $hash2);
     $this->assertTrue($hash1 !== $hash2);
     $identity->setInformation('number', 123);
     $hash3 = $identity->getHash();
     $this->assertInternalType('string', $hash3);
     $this->assertTrue($hash3 !== $hash1);
     $this->assertTrue($hash3 !== $hash2);
     $identity->replaceInformation(array('foo' => 'bar'));
     $this->assertSame($hash1, $identity->getHash());
 }