<?php

/*
 * This file is part of the AuthStack project.
 *
 * (c) Buckhill Ltd <development@buckhill.co.uk>
 *
 * This source file is subject to the Buckhill license that is bundled
 * with this source code in the file LICENSE.
 *
 */

namespace AuthStack\AuthProfile\Provider;

use AuthStack\AuthProfile\Services\ProfileManager;
use Illuminate\Support\ServiceProvider;

class ProfileManagerProvider extends ServiceProvider
{
    public function register()
    {
        $this->app->singleton('ProfileManager', function($app)
        {
            if(function_exists('session'))
            {
                return ProfileManager::fromArray(session('profiles', []), session('active', []));
            }

            return ProfileManager::fromArray([], []);
        });
    }
}