amnah\yii2\user\controllers\AuthController::setInfoFacebook PHP Method

setInfoFacebook() protected method

Set info for facebook registration
protected setInfoFacebook ( array $attributes ) : array
$attributes array
return array [$user, $profile]
    protected function setInfoFacebook($attributes)
    {
        /** @var \amnah\yii2\user\models\User $user */
        /** @var \amnah\yii2\user\models\Profile $profile */
        $user = $this->module->model("User");
        $profile = $this->module->model("Profile");
        // set email/username if they are set
        // note: email may be missing if user signed up using a phone number
        if (!empty($attributes["email"])) {
            $user->email = $attributes["email"];
        }
        if (!empty($attributes["username"])) {
            $user->username = $attributes["username"];
        }
        // use facebook name as username as fallback
        if (empty($attributes["email"]) && empty($attributes["username"])) {
            $user->username = str_replace(" ", "_", $attributes["name"]);
        }
        $profile->full_name = $attributes["name"];
        return [$user, $profile];
    }