Psecio\Gatekeeper\Gatekeeper::init PHP Метод

init() публичный статический Метод

Initialize the Gatekeeper instance, set up environment file and PDO connection
public static init ( string $envPath = null, array $config = [], DataSource $datasource = null, $logger = null )
$envPath string Environment file path (defaults to CWD)
$config array Configuration settings [optional]
$datasource DataSource Custom datasource provider
    public static function init($envPath = null, array $config = array(), \Psecio\Gatekeeper\DataSource $datasource = null, $logger = null)
    {
        $result = self::loadConfig($config, $envPath);
        if ($datasource === null) {
            $datasource = self::buildDataSource($config, $result);
        }
        self::$datasource = $datasource;
        if (isset($config['throttle']) && $config['throttle'] === false) {
            self::disableThrottle();
        }
        self::setLogger($logger);
    }

Usage Example

Пример #1
0
 *
 * These definitions will be available in the app's controllers etc.
 */
use function DI\object;
use GuzzleHttp\Client;
use GuzzleHttp\ClientInterface;
use Monolog\ErrorHandler;
use Monolog\Handler\BrowserConsoleHandler;
use Monolog\Handler\StreamHandler;
use Psecio\Gatekeeper\Gatekeeper;
use SitePoint\Rauth;
use Tamtamchik\SimpleFlash\Flash;
use Tamtamchik\SimpleFlash\TemplateFactory;
use Tamtamchik\SimpleFlash\Templates;
use Psr\Log\LoggerInterface as Logger;
Gatekeeper::init(__DIR__ . '/../../');
Gatekeeper::disableThrottle();
$user = null;
if (isset($_SESSION['user'])) {
    $user = Gatekeeper::findUserByUsername($_SESSION['user']);
    if (!$user) {
        session_destroy();
        unset($_SESSION['user']);
        header('Location: /');
        die;
    }
}
if (getenv('INTL') == 'true') {
    $language = getenv('INTL_LANG');
    putenv("LANGUAGE=" . $language);
    setlocale(LC_ALL, $language);
All Usage Examples Of Psecio\Gatekeeper\Gatekeeper::init