Set user.

@param \Claroline\CoreBundle\Entity\User $user

@return ReturnReceipt
188797
public function setUser(\Claroline\CoreBundle\Entity\User $user)
    {
        $this->user = $user;

        return $this;
    }
1152162
public function setUser(User $user)
    {
        $this->user = $user;

        unset($_SESSION[self::class][$this->getConfig()->getEntityID()]['user']);

        $_SESSION[self::class][$this->getConfig()->getEntityID()]['user'] = $this->user->toArray();
        $this->setRole($this->user->getCurrentRole());
        $this->setLocalUsername($this->user->getLocalUsername());

        return $this;
    }
1249440
public function resetPassword(User $user)
    {
        $newPassword = uniqid(time(), true);
        $user->setPassword($newPassword);
        $this->save($user);

        return $newPassword;
    }
456597
public function setUser($user)
    {

        // Clear cache
        $this->user = null;

        // Find element
        if (!$user = $this->findUserElement($user)) {
            // Clear property / cache
            $this->userId = $this->user = null;
        } else {
            // Set property
            $this->userId = $user->getId();

            // Set cache
            $this->user = $user;
        }

        return $this;
    }
245006
public function setUser($user)
    {
        if ($user instanceof User) {
            $this->_user = $user;
            return true;
        }
        $this->_user = null;
        return false;
    }
150826
public function setUser($user)
    {
        $regex = '`^' . self::$_regexUser . '$`i';

        if (preg_match_all($regex, $user, $matches) !== 1) {

            throw new InvalidArgumentException('User must match ' . $regex);
        }

        $this->_user = $user;
    }
1186197
public function forUser($user)
    {
        $callback = function () use ($user)
        {
            return $user;
        };

        return new static(
            $this->container, $callback, $this->abilities,
            $this->policies, $this->beforeCallbacks, $this->afterCallbacks
        );
    }
303066
public function connectUserWithExistingCustomer($user, $customer)
    {
        $result = false;
        if ($user->getEmail() === $customer->getEmail()) {
            \call_user_func(
                [$customer->getAttribute(), 'set' . ucfirst($user->getType()) . 'Identity'],
                $user->getId()
            );
            $result = $this->udapteCustomerAttributes($customer);
        }

        return $result;
    }
225231
public function setUser(\Neobazaar\Entity\User $user = null)
    {
        $this->user = $user;
    
        return $this;
    }
1310034
public function refresh(User $user)
    {
        if ($user['id'] == $this->session['user']['id']) {
            $this->loginByRecord($user);
        }

        return $this;
    }
73800
public function setUser(array $user)
    {
        if (in_array('user', $this->persistantMap)) {
            $this->store->set('user', $user);
        }

        $this->user = $user;
        return $this;
    }
169393
public function to(User $user)
    {
        $this->user = $user;
        $this->request['touser'] = $user['wechatOpenId'];

        return $this;
    }
815493
public function setUser(array $user)
    {
        $this->user = array_intersect_key(
            $user,
            array_flip($this->getUserAttributes())
        );

        return $this;
    }
701028
public function removeUser(User $user)
    {
        if ($this->users->contains($user)) {
            $this->users->removeElement($user);
        }

        return $this;
    }
1280921
public static function createFromUser(User $user): self
    {
        $message = new self();
        $message->setId($user->getId());
        $message->setFirstName($user->getFirstName());
        $message->setLastName($user->getLastName());
        $message->setEmail($user->getEmail());
        $message->setCompanyId($user->getCompanyId());

        return $message;
    }
283118
public function setUser(User $user)
    {
        // Check if user is currently active one
        $isCurrent = ($user->getId() === $this->getMainUser()->getId());
        // Switch identity
        $this->getUser()->switchIdentity($user->identity);
        if (!$isCurrent) {
            Yii::$app->getSession()->set('main_user', $this->getMainUser()->getId());
        } else {
            Yii::$app->getSession()->remove('main_user');
        }
    }
639178
public function updateUser(User $user)
    {
        $request = $user->toJson();
        $this->client->put(sprintf('/v2/user/%s', $user->getId()), $request);
    }