106 if ( $priority < self::MIN_PRIORITY || $priority > self::MAX_PRIORITY ) {
107 throw new InvalidArgumentException(
'Invalid priority' );
110 if ( isset( $data[
'copyFrom'] ) ) {
111 $from = $data[
'copyFrom'];
113 throw new InvalidArgumentException(
'Invalid copyFrom' );
116 'provider' => $from->provider,
118 'userInfo' => $from->userInfo,
119 'persisted' => $from->persisted,
120 'remembered' => $from->remembered,
121 'forceHTTPS' => $from->forceHTTPS,
122 'metadata' => $from->providerMetadata,
123 'idIsSafe' => $from->idIsSafe,
124 'forceUse' => $from->forceUse,
133 'persisted' =>
false,
134 'remembered' =>
true,
135 'forceHTTPS' =>
false,
145 throw new InvalidArgumentException(
'Invalid session ID' );
148 if ( $data[
'userInfo'] !==
null && !$data[
'userInfo'] instanceof
UserInfo ) {
149 throw new InvalidArgumentException(
'Invalid userInfo' );
152 if ( !$data[
'provider'] && $data[
'id'] ===
null ) {
153 throw new InvalidArgumentException(
154 'Must supply an ID when no provider is given'
158 if ( $data[
'metadata'] !==
null && !is_array( $data[
'metadata'] ) ) {
159 throw new InvalidArgumentException(
'Invalid metadata' );
162 $this->provider = $data[
'provider'];
163 if ( $data[
'id'] !==
null ) {
164 $this->
id = $data[
'id'];
165 $this->idIsSafe = $data[
'idIsSafe'];
166 $this->
forceUse = $data[
'forceUse'] && $this->provider;
168 $this->
id = $this->provider->getManager()->generateSessionId();
169 $this->idIsSafe =
true;
172 $this->priority = (int)$priority;
173 $this->userInfo = $data[
'userInfo'];
174 $this->persisted = (bool)$data[
'persisted'];
175 if ( $data[
'provider'] !==
null ) {
176 if ( $this->userInfo !==
null && !$this->userInfo->isAnon() && $this->userInfo->isVerified() ) {
177 $this->remembered = (bool)$data[
'remembered'];
179 $this->providerMetadata = $data[
'metadata'];
181 $this->
forceHTTPS = (bool)$data[
'forceHTTPS'];