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

setUser() public method

Sets the user for this user setting.
public setUser ( Sulu\Component\Security\Authentication\UserInterface $user ) : UserSetting
$user Sulu\Component\Security\Authentication\UserInterface
return UserSetting
    public function setUser(UserInterface $user)
    {
        $this->user = $user;
        return $this;
    }

Usage Example

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::setUser