public function __construct(Application $app) { $this->app = $app; $this->app->bindShared('package.publish', function () { return new Publish(); }); $commands = ['package.publish']; $events = $this->app['events']; $events->listen('artisan.start', function ($artisan) use($commands) { $artisan->resolveCommands($commands); }); }
/** * Register all available paths into the laravel system * * @param \Illuminate\Contracts\Foundation\Application $app * @return Directory */ public function registerPaths($app) { // only register if tenant directory exists if ($this->base()) { /* * critical priority, load vendors */ if ($this->vendor() && File::exists($this->vendor() . 'autoload.php')) { File::requireOnce($this->vendor() . 'autoload.php'); } /* * highest priority, load service providers; or possible custom code before any other include from tenant */ if ($this->providers() && File::exists($this->providers())) { File::requireOnce($this->providers()); } /* * mediocre priority, load additional config files */ if ($this->config() && File::isDirectory($this->config())) { foreach (File::allFiles($this->config()) as $path) { $key = File::name($path); $app['config']->set($key, array_merge(require $path, $app['config']->get($key, []))); } } /* * lowest priority load view directory */ if ($this->views() && File::isDirectory($this->views())) { $app['view']->addLocation($this->views()); } // set cache if (File::isDirectory($this->cache())) { $app['config']->set('cache.prefix', "{$app['config']->get('cache.prefix')}-{$this->website->id}"); } // @TODO we really can't use cache yet for application cache // replaces lang directory if ($this->lang() && File::isDirectory($this->lang())) { $path = $this->lang(); $app->bindShared('translation.loader', function ($app) use($path) { return new FileLoader($app['files'], $path); }); $app->bindShared('translator', function ($app) { $translator = new Translator($app['translation.loader'], $app['config']['app.locale']); $translator->setFallback($app['config']['app.fallback_locale']); return $translator; }); } // identify a possible routes.php file if ($this->routes() && File::exists($this->routes())) { File::requireOnce($this->routes()); } } return $this; }