/**
  * 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);
     });
 }
 /**
  * register the provider
  *
  * @return mixed
  */
 public function register()
 {
     App::bind('route.not.found', function () {
         App::abort(404, 'Page Not Found');
     });
     App::bind('route.middleware.failed', function () {
         throw new MiddlewareException('You can\'t access here, your authority is incorrect');
     });
 }
Example #3
0
 /**
  * createa new instance and register version
  *
  * @param Application $application the instance of anonym application
  * @param int $version the version of anonym console application
  */
 public function __construct(Application $application, $version = 2)
 {
     // register console to facades and more!
     $console = $this;
     App::singleton('console', function () use($console) {
         return $console;
     });
     parent::__construct($application, $version);
 }
 /**
  * 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());
 }
Example #7
0
 /**
  *  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());
 }
Example #8
0
 /**
  * throw an http exception with given datas
  *
  * @param int $code
  * @param string $message
  * @param array $headers
  * @throws HttpException
  */
 function abort($code = 503, $message = '', array $headers = [])
 {
     App::abort($code, $message, $headers);
 }