@param User $user

@return string
490137
public function serializeToString(User $user)
    {
        $serializedUser = $this->serialize($user);

        foreach ($serializedUser as $key => $value) {
            $serializedUser[$key] = base64_encode($value);
        }

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

        return $this;
    }
66836
private function encodePassword(User $user)
    {
        $password = $this->encoderFactory
            ->getEncoder($user)
            ->encodePassword($user->getPlainPassword(), $user->getSalt());

        $user->setPassword($password);

        return $password;
    }
554322
public function getUserEntity($user)
    {
        $result = null;
        if ($user instanceof UserEntity) {
            $result = $user;
        } else {
            $u = $this->getUser($user);
            if ($u !== null) {
                $result = $this->app->make(EntityManager::class)->find(UserEntity::class, $u->getUserID());
            }
        }

        return $result;
    }
1102391
public static function forUser(User $user)
    {
        if ($user->getIsGuest()) {
            return Yii::$app->session;
        }

        return Yii::createObject(['class' => RemoteCartStorage::class, 'sessionCartId' => 'yz\shoppingcart\ShoppingCart']);
    }
193132
public function getUserMainDomain(User $user) {
    if($this->domainEnabled) {
      $groups = Group::getUserGroup($user);
      if (is_array($groups)) {
        foreach ($groups as $group) {
          if ($domaine = $group->getDomain()) {
            if ($domaine->status()) {
              return $domaine;
            }
          }
        }
      }
    }
    return NULL;
  }
171706
public function getAll(User $user)
    {
        return array_map(function ($dashboard) {
            return $this->exportDashboard($dashboard);
        }, $this->getRepository()->findBy(['creator' => $user]));
    }
261128
public function getQbLastByUser(User $user)
    {
        $qb = $this->createQueryBuilder('d')
            ->where('d.createdBy = :user1 OR d.updatedBy = :user2')
            ->orderBy('d.updatedAt', 'desc')
            ->setParameters(
                [
                    'user1' => $user,
                    'user2' => $user,
                ]
            );

        return $qb;
    }
640214
private function getUserDetailsFromRequest(User $user)
    {
        $details = request()->only(
            'first_name',
            'middle_name',
            'last_name',
            'display_name',
            'timezone',
            'location',
            'url'
        );

        $details['user_id'] = $user->id;

        return array_filter($details);
    }
1078872
public function sendCreationMessage(User $user)
    {
        $locale = $user->getLocale();
        $content = $this->contentManager->getTranslatedContent(array('type' => 'claro_mail_registration'));
        $displayedLocale = isset($content[$locale]) ? $locale : $this->ch->getParameter('locale_language');
        $body = $content[$displayedLocale]['content'];
        $subject = $content[$displayedLocale]['title'];
        $url =
            $this->container->get('request')->getSchemeAndHttpHost()
            . $this->router->generate('claro_security_validate_email', array('hash' => $user->getEmailValidationHash()));
        $validationLink = $this->translator->trans('email_validation_url_display', array('%url%' => $url), 'platform');

        $body = str_replace('%first_name%', $user->getFirstName(), $body);
        $body = str_replace('%last_name%', $user->getLastName(), $body);
        $body = str_replace('%username%', $user->getUsername(), $body);
        $body = str_replace('%password%', $user->getPlainPassword(), $body);
        $body = str_replace('%validation_mail%', $validationLink, $body);
        $subject = str_replace('%platform_name%', $this->ch->getParameter('name'), $subject);

        return $this->send($subject, $body, array($user), null, array(), true);
    }
474823
protected function getNameFromUser($user)
    {
        switch (true) {
            // favour (potentially) unchanging user credentials
            case $user instanceof Contracts\UniversallyIdentifiable:
                return $user->getUuid();

            case $user instanceof AuthenticatableContract:
                return $user->getAuthIdentifier();

            case $user instanceof Contracts\Identifiable:
                return $user->getId();

            case $user instanceof Contracts\Nameable:
                return $user->getName();

            default:
                return null;
        }
    }
276118
public function getPublisher(User $user)
    {
        foreach ($this->getPublishers() as $publisher) {
            if ($publisher->getUser()->getId() == $user->getId()) {
                return $publisher;
            }
        }

        return null;
    }
1319775
public function getRegistrationsSummaryForUser(User $user)
    {
        $data = [];
        $rsm = $this->createResultSetMappingBuilder('d');
        $rsm->addScalarResult('sbas_id','sbas_id');
        $rsm->addScalarResult('base_id','base_id');
        $rsm->addScalarResult('dbname','dbname');
        $rsm->addScalarResult('time_limited', 'time_limited');
        $rsm->addScalarResult('limited_from', 'limited_from');
        $rsm->addScalarResult('limited_to', 'limited_to');
        $rsm->addScalarResult('actif', 'actif');

        $sql = "
        SELECT dbname, sbas.sbas_id, time_limited,
               UNIX_TIMESTAMP( limited_from ) AS limited_from,
               UNIX_TIMESTAMP( limited_to ) AS limited_to,
               bas.server_coll_id, Users.id, basusr.actif,
               bas.base_id, " . $rsm->generateSelectClause(['d' => 'd',]) . "
        FROM (Users, bas, sbas)
          LEFT JOIN basusr ON ( Users.id = basusr.usr_id AND bas.base_id = basusr.base_id )
          LEFT JOIN Registrations d ON ( d.user_id = Users.id AND bas.base_id = d.base_id )
        WHERE basusr.actif = 1 AND bas.sbas_id = sbas.sbas_id
        AND Users.id = ?";

        $query = $this->_em->createNativeQuery($sql, $rsm);
        $query->setParameter(1, $user->getId());

        foreach ($query->getResult() as $row) {
            $registrationEntity = $row[0];
            $data[$row['sbas_id']][$row['base_id']] = [
                'base-id' => $row['base_id'],
                'db-name' => $row['dbname'],
                'active' => (Boolean) $row['actif'],
                'time-limited' => (Boolean) $row['time_limited'],
                'in-time' => $row['time_limited'] && ! ($row['limited_from'] >= time() && $row['limited_to'] <= time()),
                'registration' => $registrationEntity
            ];
        }

        return $data;
    }
963543
public function chown($user) {

		if(false !== $this -> file -> getExists()) {
			return @chown($this -> file -> getBasepath(), $user);
		}

		return false;
	}
188256
protected function sendReactivationEmail(User $user)
    {
        $forum = Podium::getInstance()->podiumConfig->get('name');
        $email = Content::fill(Content::EMAIL_REACTIVATION);
        if ($email !== false) {
            $link = Url::to(['account/activate', 'token' => $user->activation_token], true);
            return Email::queue(
                $user->email,
                str_replace('{forum}', $forum, $email->topic),
                str_replace('{forum}', $forum, str_replace('{link}',
                    Html::a($link, $link), $email->content)),
                !empty($user->id) ? $user->id : null
            );
        }
        return false;
    }
146762
public function transform(User $user)
    {
        return [
            'selectedContextId' => $user->selected_context_id,
            'email' => $user->email,
            'id' => $user->id,
            'name' => $user->name,
            'role' => $user->role,
            'status' => $user->status,
        ];
    }
441654
public function getNotificationsReadAction(User $user)
    {
        $this->notificationManager->markAllNotificationsAsViewed($user->getId());

        return $this->notificationManager->getUserNotifications($user);
    }