public function __construct($params = array(), Application $app, Http $http) { $this->app = $app; $this->http = $http; // when using REST api OPTIONS needs to return successful if ('OPTIONS' == $this->http->method()) { status_header(200); wp_send_json_success('authorised'); } $this->mergeSettings($params); $this->beforeAuth(); add_action($this->action, array($this, 'authenticate'), 1); if (did_action($this->action)) { $this->authenticate(); } }
/** * Register the service provider. * * @return void */ public function register() { $this->registerEloquent(); $this->app->instance('env', defined('WPKIT_ENV') ? WPKIT_ENV : (defined('WP_DEBUG') ? 'local' : 'production')); $this->app->instance('http', \WPKit\Core\Http::capture()); $this->app->alias('http', 'WPKit\\Core\\Http'); $this->app->bind('router', 'WPKit\\Core\\Router'); $this->app->instance('session', $this->app->make('WPKit\\Core\\Session', ['app' => $this->app])); $this->app->alias('session', 'WPKit\\Core\\Session'); $this->app->instance('notifier', $this->app->make('WPKit\\Core\\Notifier', ['app' => $this->app])); $this->app->alias('notifier', 'WPKit\\Core\\Notifier'); $this->app->instance('invoker', $this->app->make('WPKit\\Core\\Invoker', ['app' => $this->app])); $this->app->alias('invoker', 'WPKit\\Core\\Invoker'); $this->app->singleton('Illuminate\\Contracts\\Debug\\ExceptionHandler', 'WPKit\\Core\\ExceptionHandler'); $this->app->singleton('errors', function () { return session_flashed('__validation_errors', []); }); $_GLOBALS['errors'] = $this->app['errors']; }