/** * register the provider */ public function register() { $session = new SessionManager(Config::get('stroge.session'), App::make('crypt')); $session->extend('cookie', function (array $configs = []) { $lifetime = Arr::get($configs, 'cookie.lifetime', 1800); $cookie = App::make('cookie'); return new CookieSessionHandler($cookie, $lifetime); }); $session->extend('database', function (array $configs = []) { $table = Arr::get($configs, 'database.table'); $base = App::make('database.base'); return new DatabaseSessionHandler($base, $table); }); $session->extend('file', function (array $configs = []) { $filesystem = Stroge::disk('local'); $path = Arr::get($configs, 'file.path', RESOURCE . 'sessions/'); return new FileSessionHandler($filesystem, $path); }); $session->extend('cache', function () { return App::make('cache'); }); $this->singleton('session', function () use($session) { return $session; }); $this->singleton('session.stroge', function () { $driver = Config::get('stroge.session.driver'); return App::make('session')->driver($driver); }); }
/** * dispatch the controller * * @throws ControllerException * @return \Anonym\Components\Route\Controller */ public function dispatch() { $name = $this->generateClassName($this->namespace, $this->class); // the controller instance $controller = App::make($name); if ($controller instanceof Controller) { // register the parameters $controller->setParameters(ParameterBag::getParameters()); // return the instance return $controller; } else { throw new ControllerException(sprintf('%s is not a controller', $name)); } }
/** * register the provider * * @return mixed */ public function register() { Paginator::setCurrentPageFinder(function () { if (isset($_GET['page'])) { $page = first(GUMP::xss_clean([$_GET['page']])); return $page; } else { return 1; } }); $request = App::make('http.request'); Paginator::setRequestPathFinder(function () use($request) { if ($request instanceof Request) { return $request->getBaseWithoutQuery(); } }); }
/** * Sınıfı başlatır ve session ve cookie objelerini atar */ public function __construct() { $this->setSession(App::make('session.stroge')); $this->setCookie(new Cookie()); }
/** * create a new instance and register database instance */ public function __construct() { $this->setBase(App::make('database.base')); $this->setOrm(new Element($this->getBase())); $this->table($this->findConnectedTable()); }
/** * get the registered error bag * * @param string $get * @return \Anonym\Support\ErrorBag|array */ function errors($get = null) { $instance = App::make('error.bag'); if ('instance' === $get) { return $instance; } return $instance->getErrors(); }