firefly-iii/app/lib/FireflyIII/FF3ServiceProvider.php

117 lines
3.1 KiB
PHP
Raw Normal View History

<?php
namespace FireflyIII;
2014-12-06 14:48:23 -06:00
use FireflyIII\Shared\Toolkit\Date;
use FireflyIII\Shared\Toolkit\Filter;
use FireflyIII\Shared\Toolkit\Form;
use FireflyIII\Shared\Toolkit\Navigation;
use FireflyIII\Shared\Toolkit\Reminders;
use FireflyIII\Shared\Toolkit\Steam;
use FireflyIII\Shared\Validation\FireflyValidator;
2014-11-21 04:12:22 -06:00
use Illuminate\Foundation\AliasLoader;
use Illuminate\Support\ServiceProvider;
/**
* Class FF3ServiceProvider
*
* @package FireflyIII
*/
class FF3ServiceProvider extends ServiceProvider
{
public function boot()
{
$this->app->validator->resolver(
function ($translator, $data, $rules, $messages) {
return new FireflyValidator($translator, $data, $rules, $messages);
}
);
}
2014-11-21 04:12:22 -06:00
/**
* Return the services bla bla.
*
* @return array
*/
public function provides()
{
return ['reminders', 'filters', 'datekit', 'navigation'];
}
/**
* Triggered automatically by Laravel
*/
public function register()
{
// FORMAT:
#$this->app->bind('Interface', 'Class');
2014-12-14 13:40:02 -06:00
$this->registerFacades();
$this->registerInterfaces();
$this->registerAliases();
2014-12-14 13:40:02 -06:00
}
public function registerFacades()
{
2014-11-21 04:12:22 -06:00
$this->app->bind(
'reminders', function () {
2014-12-14 13:40:02 -06:00
return new Reminders;
}
2014-11-21 04:12:22 -06:00
);
$this->app->bind(
'filter', function () {
2014-12-14 13:40:02 -06:00
return new Filter;
}
2014-11-21 04:12:22 -06:00
);
$this->app->bind(
'datekit', function () {
2014-12-14 13:40:02 -06:00
return new Date;
}
2014-11-21 04:12:22 -06:00
);
$this->app->bind(
'navigation', function () {
2014-12-14 13:40:02 -06:00
return new Navigation;
}
2014-11-21 04:12:22 -06:00
);
$this->app->bind(
'ffform', function () {
2014-12-14 13:40:02 -06:00
return new Form;
}
2014-11-21 04:12:22 -06:00
);
$this->app->bind(
2014-12-06 14:48:23 -06:00
'steam', function () {
2014-12-14 13:40:02 -06:00
return new Steam;
}
);
2014-12-14 13:40:02 -06:00
}
2014-12-14 13:40:02 -06:00
public function registerInterfaces()
{
// preferences:
$this->app->bind('FireflyIII\Shared\Preferences\PreferencesInterface', 'FireflyIII\Shared\Preferences\Preferences');
// registration and user mail:
$this->app->bind('FireflyIII\Shared\Mail\RegistrationInterface', 'FireflyIII\Shared\Mail\Registration');
2014-12-07 08:37:53 -06:00
// reports
$this->app->bind('FireflyIII\Report\ReportInterface', 'FireflyIII\Report\Report');
2014-12-14 13:40:02 -06:00
}
2014-12-07 08:37:53 -06:00
2014-12-14 13:40:02 -06:00
public function registerAliases()
{
2014-11-21 04:12:22 -06:00
// Shortcut so developers don't need to add an Alias in app/config/app.php
$this->app->booting(
function () {
$loader = AliasLoader::getInstance();
$loader->alias('Reminders', 'FireflyIII\Shared\Facade\Reminders');
$loader->alias('Filter', 'FireflyIII\Shared\Facade\Filter');
$loader->alias('DateKit', 'FireflyIII\Shared\Facade\DateKit');
$loader->alias('Navigation', 'FireflyIII\Shared\Facade\Navigation');
$loader->alias('FFForm', 'FireflyIII\Shared\Facade\FFForm');
$loader->alias('Steam', 'FireflyIII\Shared\Facade\Steam');
2014-11-21 04:12:22 -06:00
}
);
}
}