/** * @param array $token * @param array $config */ public function __construct($token, $config = []) { if (empty($config['scenario'])) { $config['scenario'] = self::SCENARIO_DEFAULT; } if (empty($token) || !is_string($token)) { throw new InvalidParamException('Password reset token cannot be blank.'); } parent::__construct($config); $this->user = User::findByPasswordResetToken($token, $this->isNewUserScenario() ? User::STATUS_NEW : User::STATUS_ACTIVE); if (!$this->user) { throw new InvalidParamException('Wrong password reset token.'); } $this->token = $token; }
/** * @inheritdoc */ public function __construct($id = null, $config = null) { parent::__construct($config); if ($id) { // one user if ($user = UserRecord::findById($id)) { $this->user = $user; } else { throw new UserNotFoundException(); } } else { // all users $this->users = UserRecord::find(); } }