Cachet is now a Laravel 5 app

This commit is contained in:
Joseph Cohen
2015-03-20 18:30:45 -06:00
parent 7cfa158e68
commit b4ac66d727
338 changed files with 4164 additions and 4114 deletions

View File

@@ -0,0 +1,35 @@
<?php
namespace CachetHQ\Cachet\Providers;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @return void
*/
public function boot()
{
//
}
/**
* Register any application services.
*
* This service provider is a great spot to register your various container
* bindings with the application. As you can see, we are registering our
* "Registrar" implementation here. You can add your own bindings too!
*
* @return void
*/
public function register()
{
$this->app->bind(
'Illuminate\Contracts\Auth\Registrar',
'CachetHQ\Cachet\Services\Registrar'
);
}
}

View File

@@ -0,0 +1,33 @@
<?php namespace CachetHQ\Cachet\Providers;
use Illuminate\Bus\Dispatcher;
use Illuminate\Support\ServiceProvider;
class BusServiceProvider extends ServiceProvider
{
/**
* Bootstrap any application services.
*
* @param \Illuminate\Bus\Dispatcher $dispatcher
*
* @return void
*/
public function boot(Dispatcher $dispatcher)
{
$dispatcher->mapUsing(function ($command) {
return Dispatcher::simpleMapping(
$command, 'CachetHQ\Cachet\Commands', 'CachetHQ\Cachet\Handlers\Commands'
);
});
}
/**
* Register any application services.
*
* @return void
*/
public function register()
{
//
}
}

View File

@@ -0,0 +1,22 @@
<?php namespace CachetHQ\Cachet\Providers;
use Illuminate\Support\ServiceProvider;
class ConfigServiceProvider extends ServiceProvider
{
/**
* Overwrite any vendor / package configuration.
*
* This service provider is intended to provide a convenient location for you
* to overwrite any "vendor" or package configuration that you may want to
* modify before the application handles the incoming request / command.
*
* @return void
*/
public function register()
{
config([
//
]);
}
}

View File

@@ -0,0 +1,41 @@
<?php
namespace CachetHQ\Cachet\Providers;
use CachetHQ\Cachet\Console\Commands\FixPermissionsCommand;
use CachetHQ\Cachet\Console\Commands\OneClickDeployCommand;
use Illuminate\Support\ServiceProvider;
class ConsoleServiceProvider extends ServiceProvider
{
/**
* Boot the service provider.
*
* @return void
*/
public function boot()
{
//
}
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->app->singleton('CachetHQ\Cachet\Console\Commands\FixPermissionsCommand', function ($app) {
$storageDirectory = storage_path();
$databaseDirectory = base_path('database');
$databasePath = $app->config->get('database.connections.sqlite.database');
$databaseDefault = $app->config->get('database.default');
return new FixPermissionsCommand($storageDirectory, $databaseDirectory, $databasePath, $databaseDefault);
});
$this->app->singleton('CachetHQ\Cachet\Console\Commands\OneClickDeployCommand', function ($app) {
return new OneClickDeployCommand($app->environment('heroku'));
});
}
}

View File

@@ -0,0 +1,32 @@
<?php namespace CachetHQ\Cachet\Providers;
use Illuminate\Contracts\Events\Dispatcher as DispatcherContract;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
class EventServiceProvider extends ServiceProvider
{
/**
* The event handler mappings for the application.
*
* @var array
*/
protected $listen = [
'event.name' => [
'EventListener',
],
];
/**
* Register any other events for your application.
*
* @param \Illuminate\Contracts\Events\Dispatcher $events
*
* @return void
*/
public function boot(DispatcherContract $events)
{
parent::boot($events);
//
}
}

View File

@@ -0,0 +1,53 @@
<?php
namespace CachetHQ\Cachet\Providers;
use CachetHQ\Cachet\Facades\Setting;
use Illuminate\Database\QueryException;
use Illuminate\Support\ServiceProvider;
class LoadConfigServiceProvider extends ServiceProvider
{
/**
* Boot the service provider.
*
* @return void
*/
public function boot()
{
$appDomain = $appLocale = null;
try {
// Get app custom configuration.
$appDomain = Setting::get('app_domain');
$appLocale = Setting::get('app_locale');
} catch (QueryException $e) {
// Don't throw any errors, we may not be setup yet.
}
// Set the Segment.com settings.
$segmentRepository = $this->app->make('CachetHQ\Cachet\Segment\RepositoryInterface');
try {
$this->app->config->set('cachethq/segment::write_key', $segmentRepository->fetch());
} catch (\GuzzleHttp\Exception\ConnectException $e) {
// We may not have any connection. Let's not cry about it.
}
// Override default app values.
$this->app->config->set('app.url', $appDomain ?: $this->app->config->get('app.url'));
$this->app->config->set('app.locale', $appLocale ?: $this->app->config->get('app.locale'));
// Set custom lang.
$this->app->translator->setLocale($appLocale);
}
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
//
}
}

View File

@@ -0,0 +1,43 @@
<?php
namespace CachetHQ\Cachet\Providers;
use Illuminate\Support\ServiceProvider;
class RepositoryServiceProvider extends ServiceProvider
{
/**
* Boot the service provider.
*
* @return void
*/
public function boot()
{
//
}
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->app->bind(
'CachetHQ\Cachet\Repositories\Component\ComponentRepository',
'CachetHQ\Cachet\Repositories\Component\EloquentComponentRepository'
);
$this->app->bind(
'CachetHQ\Cachet\Repositories\Incident\IncidentRepository',
'CachetHQ\Cachet\Repositories\Incident\EloquentIncidentRepository'
);
$this->app->bind(
'CachetHQ\Cachet\Repositories\Metric\MetricRepository',
'CachetHQ\Cachet\Repositories\Metric\EloquentMetricRepository'
);
$this->app->bind(
'CachetHQ\Cachet\Repositories\MetricPoint\MetricPointRepository',
'CachetHQ\Cachet\Repositories\MetricPoint\EloquentMetricPointRepository'
);
}
}

View File

@@ -0,0 +1,63 @@
<?php namespace CachetHQ\Cachet\Providers;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Routing\Router;
class RouteServiceProvider extends ServiceProvider
{
/**
* This namespace is applied to the controller routes in your routes file.
*
* In addition, it is set as the URL generator's root namespace.
*
* @var string
*/
protected $namespace = 'CachetHQ\Cachet\Http\Controllers';
/**
* Define your route model bindings, pattern filters, etc.
*
* @param \Illuminate\Routing\Router $router
*
* @return void
*/
public function boot(Router $router)
{
parent::boot($router);
$this->registerBindings();
}
/**
* Register model bindings.
*
* @return void
*/
protected function registerBindings()
{
$this->app->router->model('component', 'CachetHQ\Cachet\Models\Component');
$this->app->router->model('component_group', 'CachetHQ\Cachet\Models\ComponentGroup');
$this->app->router->model('incident', 'CachetHQ\Cachet\Models\Incident');
$this->app->router->model('incident_template', 'CachetHQ\Cachet\Models\IncidentTemplate');
$this->app->router->model('metric', 'CachetHQ\Cachet\Models\Metric');
$this->app->router->model('metric_point', 'CachetHQ\Cachet\Models\MetricPoint');
$this->app->router->model('setting', 'CachetHQ\Cachet\Models\Setting');
$this->app->router->model('user', 'CachetHQ\Cachet\Models\User');
}
/**
* Define the routes for the application.
*
* @param \Illuminate\Routing\Router $router
*
* @return void
*/
public function map(Router $router)
{
$router->group(['namespace' => $this->namespace], function (Router $router) {
foreach (glob(app_path('Http//Routes').'/*.php') as $file) {
$this->app->make('CachetHQ\\Cachet\\Http\\Routes\\'.basename($file, '.php'))->map($router);
}
});
}
}

View File

@@ -0,0 +1,37 @@
<?php
namespace CachetHQ\Cachet\Providers;
use CachetHQ\Cachet\Segment\CacheRepository;
use CachetHQ\Cachet\Segment\HttpRepository;
use GuzzleHttp\Client;
use Illuminate\Support\ServiceProvider;
class SegmentApiServiceProvider extends ServiceProvider
{
/**
* Boot the service provider.
*
* @return void
*/
public function boot()
{
//
}
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->app->singleton('CachetHQ\Cachet\Segment\RepositoryInterface', function () {
$url = 'https://gist.githubusercontent.com/jbrooksuk/5de24bc1cf90fb1a3d57/raw/cachet.json';
$guzzleClient = new Client();
$client = new HttpRepository($guzzleClient, $url);
return new CacheRepository($client);
});
}
}

View File

@@ -0,0 +1,32 @@
<?php
namespace CachetHQ\Cachet\Providers;
use CachetHQ\Cachet\Config\Repository;
use CachetHQ\Cachet\Models\Setting as SettingModel;
use Illuminate\Support\ServiceProvider;
class SettingsServiceProvider extends ServiceProvider
{
/**
* Boot the service provider.
*
* @return void
*/
public function boot()
{
//
}
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->app->bindShared('setting', function () {
return new Repository(new SettingModel());
});
}
}

View File

@@ -0,0 +1,34 @@
<?php
namespace CachetHQ\Cachet\Providers;
use Illuminate\Support\ServiceProvider;
class ViewComposerServiceProvider extends ServiceProvider
{
/**
* Boot the service provider.
*
* @return void
*/
public function boot()
{
//
}
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->app->view->composer('*', 'CachetHQ\Cachet\Composers\LoggedUserComposer');
$this->app->view->composer('index', 'CachetHQ\Cachet\Composers\IndexComposer');
$this->app->view->composer('dashboard.*', 'CachetHQ\Cachet\Composers\DashboardComposer');
$this->app->view->composer([
'setup',
'dashboard.settings.app-setup',
], 'CachetHQ\Cachet\Composers\TimezoneLocaleComposer');
}
}