public function populateUser(UserInterface $user) { $user->setName($user->getName() . ' (dummy)'); }
/** * Creates a new session for the provided user and saves it in the storage. * * @param UserInterface $user * @param Authentication\Info $authenticationInfo * @throws Exception\MissingComponentException * @return Session */ public function createSession(UserInterface $user, Authentication\Info $authenticationInfo) { $sessionIdGenerator = $this->getSessionIdGenerator(); if (!$sessionIdGenerator) { throw new GeneralException\MissingDependencyException('session ID generator'); } $serializer = $this->getUserSerializer(); if (!$serializer) { throw new GeneralException\MissingDependencyException('user serializer'); } $storage = $this->getStorageWithCheck(); $sessionId = $sessionIdGenerator->generateId(array($user->getId())); $serializedUserData = $serializer->serialize($user); $dateTimeUtil = $this->getDateTimeUtil(); $now = $dateTimeUtil->createDateTime(); $expire = $dateTimeUtil->createExpireDateTime($now, $this->getSessionExpireInterval()); $session = new Session(array(Session::FIELD_ID => $sessionId, Session::FIELD_USER_ID => $user->getId(), Session::FIELD_CREATE_TIME => $now, Session::FIELD_MODIFY_TIME => $now, Session::FIELD_AUTHENTICATION_TIME => $authenticationInfo->getTime(), Session::FIELD_EXPIRATION_TIME => $expire, Session::FIELD_AUTHENTICATION_METHOD => $authenticationInfo->getMethod(), Session::FIELD_USER_DATA => $serializedUserData)); $storage->saveSession($session); return $session; }
public function getUserInfoData(UserInterface $user) { return $user->toArray(); }