Sulu\Bundle\SecurityBundle\Entity\UserSetting::setKey PHP Method

setKey() public method

Sets the key for this user setting.
public setKey ( string $key ) : UserSetting
$key string
return UserSetting
    public function setKey($key)
    {
        $this->key = $key;
        return $this;
    }

Usage Example

コード例 #1
0
 public function testIndexAction()
 {
     $client = $this->createAuthenticatedClient();
     $client->request('GET', '/admin/');
     // required because test user does not exist otherwise
     $userSetting = new UserSetting();
     $userSetting->setKey('test');
     $userSetting->setValue(json_encode(['key' => 'value']));
     $userSetting->setUser($this->getTestUser());
     $this->em->persist($userSetting);
     $this->em->flush();
     $client->request('GET', '/admin/');
     $this->assertContains('"settings":{"test":{"key":"value"}}', $client->getResponse()->getContent());
 }
All Usage Examples Of Sulu\Bundle\SecurityBundle\Entity\UserSetting::setKey