Esempio n. 1
0
 /**
  * Set the site_id of the model.
  *
  * If a site is currently active then it is used, otherwise the default site is used.
  *
  * @param Model $model
  *
  * @return void
  */
 public function creating(Model $model)
 {
     if ($model instanceof SingleSiteInterface) {
         $site = $this->router->getActiveSite() ?: $this->site->findDefault();
         $model->{SingleSiteInterface::ATTR_SITE} = $site ? $site->getId() : null;
     }
 }
 /**
  * @return void
  */
 public function boot(Router $router)
 {
     $site = $router->getActiveSite();
     $this->app->singleton(Repositories\Asset::class, function () {
         return new Repositories\Asset(new Models\Asset(), new Models\AssetVersion());
     });
     $this->app->singleton(Repositories\Page::class, function () use($site) {
         return new Repositories\Page(new Models\Page(), $site);
     });
     $this->app->singleton(Repositories\PageVersion::class, function () {
         return new Repositories\PageVersion(new Models\PageVersion());
     });
     $this->app->singleton(Repositories\Person::class, function () use($site) {
         return new Repositories\Person(new Models\Person(), $site);
     });
     $this->app->singleton(Repositories\Group::class, function () {
         return new Repositories\Group();
     });
     $this->app->singleton(Repositories\Tag::class, function () use($site) {
         return new Repositories\Tag(new Models\Tag(), $site);
     });
     $this->app->singleton(Repositories\Template::class, function () {
         return new Repositories\Template(new Models\Template());
     });
     $this->app->singleton(Repositories\URL::class, function () use($site) {
         return new Repositories\URL(new Models\URL(), $site);
     });
 }
Esempio n. 3
0
 public function register()
 {
     $this->app->singleton(BoomCMSRouter::class, function () {
         $router = new BoomCMSRouter($this->app);
         $router->routeHostname($this->app->make(Request::class)->getHttpHost());
         return $router;
     });
 }
Esempio n. 4
0
 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  *
  * @return mixed
  */
 public function handle(Request $request, Closure $next)
 {
     $response = $this->router->process($request->route()->getParameter('location'));
     if ($response) {
         return $response;
     }
     return $next($request);
 }
 /**
  * Bootstrap any application services.
  *
  * @return void
  */
 public function boot(Guard $guard, Store $session, Router $router)
 {
     $activePage = $router->getActivePage();
     $this->app->singleton(Editor::class, function () use($guard, $session, $activePage) {
         $default = $guard->check() && $activePage && $guard->user()->can('toolbar', $activePage) ? Editor::EDIT : Editor::DISABLED;
         return new Editor($session, $default);
     });
 }
Esempio n. 6
0
 /**
  * @param Router $router
  * @param Gate   $gate
  */
 public function __construct(Router $router, Guard $guard, Gate $gate)
 {
     $this->page = $router->getActivePage();
     $this->gate = $gate;
     $this->guard = $guard;
 }