/**
  * Setup the seeds.
  *
  * @param \Illuminate\Contracts\Foundation\Application $app
  *
  * @return void
  */
 protected function setupSeeds(Application $app)
 {
     $source = realpath(__DIR__ . '/../database/seeds/');
     if ($app instanceof LaravelApplication && $app->runningInConsole()) {
         $this->publishes([$source => database_path('seeds')], 'seeds');
     }
 }
Example #2
0
File: Secure.php Project: mlanin/go
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if (!$request->secure() && $this->app->environment() === 'production') {
         return redirect()->secure($request->getRequestUri());
     }
     return $next($request);
 }
Example #3
0
 /**
  * Determine if the app is running in the console.
  *
  * To allow testing this will return false the environment is testing.
  *
  * @return bool
  */
 public function isRunningInConsole()
 {
     if ($this->app->environment('testing')) {
         return false;
     }
     return $this->app->runningInConsole();
 }
 /**
  * Instanciate and execute all functions as blade extends
  *
  * @param Application $app The current application
  */
 public static function attach(Application $app)
 {
     /** @var \Illuminate\View\Compilers\BladeCompiler $blade */
     $blade = $app->make('view')->getEngineResolver()->resolve('blade')->getCompiler();
     $config = $app->make('config');
     $class = new static();
     if (!isset($class->directivesFile)) {
         $class->directivesFile = __DIR__ . '/../directives.php';
     }
     $blacklist = isset($class->blacklist) ? $class->blacklist : $config->get('blade_extensions.blacklist');
     $directives = isset($class->directives) ? $class->directives : $app->make('files')->getRequire($class->directivesFile);
     $overrides = isset($class->overrides) ? $class->overrides : $config->get('blade_extensions.overrides', []);
     foreach ($overrides as $method => $override) {
         if (!isset($directives[$method])) {
             continue;
         }
         if (isset($override['pattern'])) {
             $directives[$method]['pattern'] = $override['pattern'];
         }
         if (isset($override['replacement'])) {
             $directives[$method]['replacement'] = $override['replacement'];
         }
     }
     foreach ($directives as $name => $directive) {
         $method = 'directive' . ucfirst($name);
         if (is_array($blacklist) && in_array($name, $blacklist, true) || !method_exists($class, $method)) {
             continue;
         }
         $blade->extend(function ($value) use($class, $method, $directive, $app, $blade) {
             return $class->{$method}($value, $directive['pattern'], $directive['replacement'], $app, $blade);
         });
     }
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->app->isDownForMaintenance()) {
         throw new HttpException(503);
     }
     return $next($request);
 }
Example #6
0
 /**
  * Send through our custom router
  *
  * @param $request
  *
  * @return Response
  */
 protected function sendRequestThroughRouter($request)
 {
     $this->app->instance('request', $request);
     return (new Pipeline($this->app))->send($request)->through($this->middleware)->then(function ($request) {
         return $this->router->dispatch($this->alexaRequest);
     });
 }
 function let(Application $app, ContainerInterface $container)
 {
     $container->addPackage('mvalim/package')->shouldBeCalled();
     $app->make('Mvalim\\PackageUtils\\Container')->willReturn($container);
     $this->beAnInstanceOf('spec\\Mvalim\\PackageUtils\\Providers\\CorrectProviderStub');
     $this->beConstructedWith($app);
 }
 /**
  * Bootstrap the given application.
  *
  * @param  \Illuminate\Contracts\Foundation\Application  $app
  * @return void
  */
 public function bootstrap(Application $app)
 {
     //Detect the domain
     $app->detectDomain();
     //Overrides the storage path if the domain staorge path exists
     $app->useStoragePath($app->domainStoragePath());
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure                 $next
  * @return void|mixed
  */
 public function handle(Request $request, Closure $next)
 {
     if (!$this->app->isDownForMaintenance()) {
         return $next($request);
     }
     if ($request->segment(1) == 'admin') {
         return $next($request);
     }
     if (in_array($request->getClientIp(), $this->config->get('streams::maintenance.ip_whitelist', []))) {
         return $next($request);
     }
     /* @var UserInterface $user */
     $user = $this->guard->user();
     if ($user && $user->isAdmin()) {
         return $next($request);
     }
     if ($user && $this->authorizer->authorize('streams::maintenance.access')) {
         return $next($request);
     }
     if (!$user && $this->config->get('streams::maintenance.auth')) {
         /* @var Response|null $response */
         $response = $this->guard->onceBasic();
         if (!$response) {
             return $next($request);
         }
         $response->setContent(view('streams::errors.401'));
         return $response;
     }
     abort(503);
 }
 /**
  * Setup the migrations.
  *
  * @param \Illuminate\Contracts\Foundation\Application $app
  *
  * @return void
  */
 protected function setupMigrations(Application $app)
 {
     $source = realpath(__DIR__ . '/../database/migrations/');
     if (class_exists('Illuminate\\Foundation\\Application', false) && $app->runningInConsole()) {
         $this->publishes([$source => database_path('migrations')], 'migrations');
     }
 }
Example #11
0
 /**
  * Copy migration to resources
  *
  * @param Application $app
  */
 private function initMigration(Application $app)
 {
     if ($app instanceof \Illuminate\Foundation\Application && $app->runningInConsole()) {
         $migrationPath = realpath(__DIR__ . '/../database/migrations');
         $this->publishes([$migrationPath => database_path('migrations')]);
     }
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->app->isDownForMaintenance()) {
         return new Response('Be right back!', 503);
     }
     return $next($request);
 }
 /**
  * @param EventManager           $manager
  * @param EntityManagerInterface $em
  * @param Reader                 $reader
  */
 public function addSubscribers(EventManager $manager, EntityManagerInterface $em, Reader $reader = null)
 {
     $subscriber = new TranslatableListener();
     $subscriber->setTranslatableLocale($this->application->getLocale());
     $subscriber->setDefaultLocale($this->repository->get('app.locale'));
     $this->addSubscriber($subscriber, $manager, $reader);
 }
Example #14
0
 /**
  * Bootstrap the given application.
  *
  * @param  \Illuminate\Contracts\Foundation\Application  $app
  *
  * @return void
  */
 public function bootstrap(Application $app)
 {
     $items = [];
     $app->instance('config', $config = new Repository($items));
     $this->loadConfigurationFiles($app, $config);
     mb_internal_encoding('UTF-8');
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->app->isDownForMaintenance() && !in_array($request->getClientIp(), ['127.0.0.1'])) {
         throw new HttpException(503);
     }
     return $next($request);
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  *
  * @throws \Symfony\Component\HttpKernel\Exception\HttpException
  */
 public function handle(Request $request, Closure $next)
 {
     if ($this->app->isDownForMaintenance() && !in_array($request->getClientIp(), config('maintenance.ips', [])) && (config('maintenance.bypass_with_cookie', false) === false || config('maintenance.cookie_name', '') === '' || !$request->hasCookie(config('maintenance.cookie_name')))) {
         throw new HttpException(503);
     }
     return $next($request);
 }
Example #17
0
 /**
  * Create a new instance of Storytelling.
  *
  * @param  \Illuminate\Contracts\Foundation\Application  $app
  */
 public function __construct($app)
 {
     $this->app = $app;
     if (method_exists($this, 'initiate')) {
         $app->call([$this, 'initiate']);
     }
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  *
  * @throws \Symfony\Component\HttpKernel\Exception\HttpException
  */
 public function handle($request, Closure $next)
 {
     if ($this->app->isDownForMaintenance() && $this->app->environment() != 'testing') {
         throw new HttpException(503, 'Server is currently undergoing maintenance. We should be ' . 'back up shortly.');
     }
     return $next($request);
 }
 public function boot(Application $app)
 {
     $source = realpath(__DIR__ . '/migrations/');
     if ($app->runningInConsole()) {
         $this->publishes([$source => database_path('migrations')], 'migrations');
     }
 }
Example #20
0
 public function __construct(Application $app)
 {
     $providers_classes = config('preview.screenshot_providers');
     foreach ($providers_classes as $class) {
         $this->providers[] = $app->make($class);
     }
 }
Example #21
0
 /**
  * Register the git client class.
  *
  * @param \Illuminate\Contracts\Foundation\Application $app
  *
  * @return void
  */
 protected function registerGitlib(Application $app)
 {
     $app->singleton('gitlib', function ($app) {
         return new BaseClient(null);
     });
     $app->alias('gitlib', BaseClient::class);
 }
Example #22
0
 /**
  * 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));
 }
Example #23
0
 public function subscribe(Dispatcher $event)
 {
     if (static::$called) {
         return;
     }
     // only actively do something in case the default cache driver has been changed
     if ($this->settings->get('hyn.cache.driver', 'file') != 'file') {
         /** @var \Illuminate\Contracts\Config\Repository $config */
         $config = $this->application->make('config');
         $cacheConfig = ['driver' => $this->settings->get('hyn.cache.driver')];
         switch ($this->settings->get('hyn.cache.driver')) {
             case 'database':
                 $merge = ['table' => $this->settings->get('hyn.cache.table', 'cache'), 'connection' => $this->settings->get('hyn.cache.connection')];
                 break;
             case 'redis':
                 $merge = ['connection' => $this->settings->get('hyn.cache.connection')];
                 break;
             case 'memcached':
                 // @todo..
                 break;
             default:
                 $merge = [];
         }
         // merges driver specific settings into the config
         $cacheConfig = array_merge($cacheConfig, $merge);
         // sets the cache store
         $config->set('cache.stores.hyn-cache', $cacheConfig);
         $config->set('cache.driver', 'hyn-cache');
     }
 }
 public function __construct(Application $app, Factory $snapshot_factory, $table = 'snapshots_player')
 {
     $this->app = $app;
     $this->connection = $app->make('db');
     $this->snapshot_factory = $snapshot_factory;
     $this->table = $table;
 }
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request $request
  * @param  \Closure                 $next
  * @return mixed
  *
  * @throws \Symfony\Component\HttpKernel\Exception\HttpException
  */
 public function handle($request, Closure $next)
 {
     if ($this->app->isDownForMaintenance()) {
         throw new HttpException(503, null, null, ['Retry-After' => 900]);
     }
     return $next($request);
 }
 public function __construct($memcached, Application $app)
 {
     $this->memcached = $memcached;
     //force expiry to be in seconds from minutes
     $this->sessionExpiry = $app->make('config')->get('session.lifetime') * 60;
     $this->sessionPrefix = $app->make('config')->get('session.cookie');
 }
Example #27
0
 /**
  * Register a view file namespace.
  *
  * @param  string  $path
  * @param  string  $namespace
  * @return void
  */
 protected function loadViewsFrom($path, $namespace)
 {
     if (is_dir($appPath = $this->app->basePath() . '/resources/views/vendor/' . $namespace)) {
         $this->app['view']->addNamespace($namespace, $appPath);
     }
     $this->app['view']->addNamespace($namespace, $path);
 }
 /**
  * Register the application service providers.
  *
  * @param  array  $providers
  * @return void
  */
 public function load(array $providers)
 {
     $manifest = $this->loadManifest();
     // First we will load the service manifest, which contains information on all
     // service providers registered with the application and which services it
     // provides. This is used to know which services are "deferred" loaders.
     if ($this->shouldRecompile($manifest, $providers)) {
         $manifest = $this->compileManifest($providers);
     }
     // If the application is running in the console, we will not lazy load any of
     // the service providers. This is mainly because it's not as necessary for
     // performance and also so any provided Artisan commands get registered.
     if ($this->app->runningInConsole()) {
         $manifest['eager'] = $manifest['providers'];
     }
     // Next, we will register events to load the providers for each of the events
     // that it has requested. This allows the service provider to defer itself
     // while still getting automatically loaded when a certain event occurs.
     foreach ($manifest['when'] as $provider => $events) {
         $this->registerLoadEvents($provider, $events);
     }
     // We will go ahead and register all of the eagerly loaded providers with the
     // application so their services can be registered with the application as
     // a provided service. Then we will set the deferred service list on it.
     foreach ($manifest['eager'] as $provider) {
         $this->app->register($this->createProvider($provider));
     }
     $this->app->setDeferredServices($manifest['deferred']);
 }
 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure                 $next
  *
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     if ($this->app->isDownForMaintenance()) {
         return new Response($this->view->make('maintenance')->render(), 503);
     }
     return $next($request);
 }
 /**
  * Bootstrap the given application.
  *
  * @param  \Illuminate\Contracts\Foundation\Application  $app
  *
  * @return void
  */
 public function bootstrap(Application $app)
 {
     $app->make('orchestra.memory')->extend('user', function ($app, $name) {
         $handler = new UserMetaRepository($name, [], $app);
         return new UserMetaProvider($handler);
     });
 }