2015-03-20 18:30:45 -06:00
|
|
|
<?php
|
|
|
|
|
2015-04-19 08:52:39 +01:00
|
|
|
/*
|
|
|
|
* This file is part of Cachet.
|
|
|
|
*
|
2015-07-06 17:37:01 +01:00
|
|
|
* (c) Alt Three Services Limited
|
2015-04-19 08:52:39 +01:00
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
2015-12-07 22:12:45 +00:00
|
|
|
namespace CachetHQ\Cachet\Foundation\Providers;
|
2015-03-20 18:30:45 -06:00
|
|
|
|
2015-12-24 15:44:06 +00:00
|
|
|
use AltThree\Bus\Dispatcher;
|
2016-05-05 16:47:41 +01:00
|
|
|
use CachetHQ\Cachet\Bus\Middleware\UseDatabaseTransactions;
|
2015-11-07 13:15:28 +00:00
|
|
|
use CachetHQ\Cachet\Dates\DateFactory;
|
2015-03-20 18:30:45 -06:00
|
|
|
use Illuminate\Support\ServiceProvider;
|
2015-06-12 22:44:57 +01:00
|
|
|
use Illuminate\Support\Str;
|
2015-03-20 18:30:45 -06:00
|
|
|
|
2016-05-05 16:47:41 +01:00
|
|
|
/**
|
|
|
|
* This is the app service provider.
|
|
|
|
*
|
|
|
|
* @author James Brooks <james@alt-three.com>
|
|
|
|
* @author Joe Cohen <joe@alt-three.com>
|
|
|
|
* @author Graham Campbell <graham@alt-three.com>
|
|
|
|
*/
|
2015-03-20 18:30:45 -06:00
|
|
|
class AppServiceProvider extends ServiceProvider
|
|
|
|
{
|
2015-06-12 22:37:46 +01:00
|
|
|
/**
|
|
|
|
* Boot the service provider.
|
|
|
|
*
|
2015-12-24 15:44:06 +00:00
|
|
|
* @param \AltThree\Bus\Dispatcher $dispatcher
|
2015-06-12 22:37:46 +01:00
|
|
|
*/
|
|
|
|
public function boot(Dispatcher $dispatcher)
|
|
|
|
{
|
|
|
|
$dispatcher->mapUsing(function ($command) {
|
2016-01-05 02:38:07 +00:00
|
|
|
return Dispatcher::simpleMapping($command, 'CachetHQ\Cachet\Bus', 'CachetHQ\Cachet\Bus\Handlers');
|
2015-06-12 22:37:46 +01:00
|
|
|
});
|
2015-06-12 22:46:41 +01:00
|
|
|
|
2016-05-05 16:47:41 +01:00
|
|
|
$dispatcher->pipeThrough([UseDatabaseTransactions::class]);
|
|
|
|
|
2015-06-12 22:44:57 +01:00
|
|
|
Str::macro('canonicalize', function ($url) {
|
|
|
|
return preg_replace('/([^\/])$/', '$1/', $url);
|
|
|
|
});
|
2015-06-12 22:37:46 +01:00
|
|
|
}
|
|
|
|
|
2015-03-20 18:30:45 -06:00
|
|
|
/**
|
2015-05-28 19:46:54 +01:00
|
|
|
* Register the service provider.
|
2015-08-30 22:42:38 +01:00
|
|
|
*
|
|
|
|
* @return void
|
2015-03-20 18:30:45 -06:00
|
|
|
*/
|
|
|
|
public function register()
|
|
|
|
{
|
2015-11-07 13:15:28 +00:00
|
|
|
$this->registerDateFactory();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Register the date factory.
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
protected function registerDateFactory()
|
|
|
|
{
|
|
|
|
$this->app->singleton(DateFactory::class, function ($app) {
|
|
|
|
$appTimezone = $app->config->get('app.timezone');
|
|
|
|
$cacheTimezone = $app->config->get('cachet.timezone');
|
|
|
|
|
|
|
|
return new DateFactory($appTimezone, $cacheTimezone);
|
|
|
|
});
|
2015-03-20 18:30:45 -06:00
|
|
|
}
|
|
|
|
}
|