/** * Add a command, resolving through the application. * * @param string $command * * @return \Symfony\Component\Console\Command\Command */ public function resolve($command) { if (is_null($this->container)) { $this->container = Container::getInstance(); } return $this->add($this->container->make($command)); }
/** * Handle an incoming request. * * @param \Illuminate\Http\Request $request * @param \Closure $next * * @throws \Symfony\Component\HttpKernel\Exception\HttpException * @return mixed */ public function handle($request, Closure $next) { if ($this->application->isDownForMaintenance()) { $data = json_decode(file_get_contents($this->application->storagePath() . '/bootstraps/down'), true); throw new MaintenanceModeException($data['time'], $data['retry'], $data['message']); } return $next($request); }
/** * Boot a fresh copy of the application configuration. * * @return mixed */ protected function getFreshConfiguration() { $application = new Application($this->laravel->basePath()); $application->singleton(HttpKernelContract::class, Kernel::class); $application->singleton(ConsoleKernelContract::class, ConsoleKernel::class); $application->singleton(ExceptionHandler::class, Handler::class); $application->make('Illuminate\\Contracts\\Console\\Kernel')->bootstrap(); return $application['config']->all(); }
/** * @return void */ protected static function clearCompiled() { $laravel = new Application(getcwd()); if (file_exists($compiledPath = $laravel->getCachedCompilePath())) { @unlink($compiledPath); } if (file_exists($servicesPath = $laravel->getCachedServicesPath())) { @unlink($servicesPath); } }
/** * Set the application key in the environment file. * * @param string $key */ protected function setKeyInEnvironmentFile($key) { $path = $this->laravel->environmentFilePath(); if (file_exists($path)) { file_put_contents($path, str_replace('APP_KEY=' . $this->laravel['config']['app.key'], 'APP_KEY=' . $key, file_get_contents($path))); } else { touch($path); file_put_contents($path, 'APP_KEY=' . $key); } }
/** * @return \Closure */ protected function dispatchToRouter() { return function ($request) { $this->app->instance('request', $request); return $this->router->dispatch($request); }; }
/** * Get the Artisan application instance. * * @return \Notadd\Foundation\Console\Application */ public function getArtisan() { if (is_null($this->artisan)) { return $this->artisan = (new Artisan($this->app, $this->events, $this->app->version()))->resolveCommands($this->commands); } return $this->artisan; }
/** * @param \Symfony\Component\Console\Input\InputInterface $input * @param \Symfony\Component\Console\Output\OutputInterface $output * * @throws \Exception * @return mixed */ protected function execute(InputInterface $input, OutputInterface $output) { $this->input = $input; $this->output = $output; if (!method_exists($this, 'fire')) { throw new Exception('Method fire do not exits!', 404); } return $this->container->call([$this, 'fire']); }
/** * @return void */ public function console() { $this->application->singleton(ConsoleKernelContract::class, ConsoleKernel::class); $this->application->singleton(ExceptionHandler::class, Handler::class); $kernel = $this->application->make(ConsoleKernelContract::class); $status = $kernel->handle($input = new ArgvInput(), new ConsoleOutput()); $kernel->terminate($input, $status); exit($status); }
/** * @param \Notadd\Foundation\Database\Connection $connection * @return \Notadd\Foundation\Database\Connection */ protected function prepare(Connection $connection) { $connection->setFetchMode($this->app['config']['database.fetch']); if ($this->app->bound('events')) { $connection->setEventDispatcher($this->app['events']); } $connection->setReconnector(function ($connection) { $this->reconnect($connection->getName()); }); return $connection; }
/** * Clean up the testing environment before the next test. * * @return void */ protected function tearDown() { if ($this->app) { foreach ($this->beforeApplicationDestroyedCallbacks as $callback) { call_user_func($callback); } $this->app->flush(); $this->app = null; } $this->setUpHasRun = false; if (property_exists($this, 'serverVariables')) { $this->serverVariables = []; } if (class_exists('Mockery')) { Mockery::close(); } $this->afterApplicationCreatedCallbacks = []; $this->beforeApplicationDestroyedCallbacks = []; }
/** * Module path. * * @return string */ public function getModulePath() { return $this->container->basePath() . DIRECTORY_SEPARATOR . 'modules'; }
/** * Load a custom environment file. * * @param \Illuminate\Contracts\Foundation\Application|\Notadd\Foundation\Application $app * @param string $file * * @return void */ protected function loadEnvironmentFile($app, $file) { if (file_exists($app->environmentPath() . '/' . $file)) { $app->loadEnvironmentFrom($file); } }
/** * @return bool */ protected function runningUnitTests() { return $this->app->runningInConsole() && $this->app->runningUnitTests(); }
<?php /** * This file is part of Notadd. * @author TwilRoad <*****@*****.**> * @copyright (c) 2015, iBenchu.org * @datetime 2015-10-16 21:38 */ use Illuminate\Contracts\Debug\ExceptionHandler; use Illuminate\Contracts\Console\Kernel as ConsoleKernelContract; use Illuminate\Contracts\Http\Kernel as HttpKernelContract; use Notadd\Foundation\Application; use Notadd\Foundation\Console\Kernel as ConsoleKernel; use Notadd\Foundation\Http\Kernel as HttpKernel; use Notadd\Foundation\Install\Kernel as InstallKernel; use Notadd\Foundation\Exceptions\Handler; define('NOTADD_START', microtime(true)); require __DIR__ . '/vendor/autoload.php'; $app = new Application(realpath(__DIR__)); if ($app->isInstalled()) { $app->singleton(HttpKernelContract::class, HttpKernel::class); $app->singleton(ExceptionHandler::class, Handler::class); } else { $app->singleton(HttpKernelContract::class, InstallKernel::class); $app->singleton(ExceptionHandler::class, Handler::class); } return $app;
/** * @return string */ public function getStubPath() { return realpath($this->application->stubsPath() . DIRECTORY_SEPARATOR . 'migrations'); }
/** * @return \Illuminate\Contracts\Debug\ExceptionHandler */ protected function getExceptionHandler() { return $this->app->make('Illuminate\\Contracts\\Debug\\ExceptionHandler'); }
/** * @param string $abstract * @param array|string $alias */ public function alias($abstract, $alias) { foreach ((array) $alias as $item) { $this->container->alias($abstract, $item); } }
/** * @return string */ public function getThemePath() { return $this->container->basePath() . DIRECTORY_SEPARATOR . 'themes'; }
/** * @param string $path * @return string */ protected function getDefaultStaticPath($path = '') { $defaultPath = $this->application->publicPath() . DIRECTORY_SEPARATOR . 'statics' . DIRECTORY_SEPARATOR . $this->alias; return $path ? $defaultPath . DIRECTORY_SEPARATOR . $path : $defaultPath; }