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

123 lines
3.5 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-27 10:21:15 -06:00
$this->app->bind('FireflyIII\Report\ReportQueryInterface', 'FireflyIII\Report\ReportQuery');
$this->app->bind('FireflyIII\Report\ReportHelperInterface', 'FireflyIII\Report\ReportHelper');
$this->app->bind('FireflyIII\Helper\TransactionJournal\HelperInterface', 'FireflyIII\Helper\TransactionJournal\Helper');
2014-12-21 03:54:25 -06:00
// chart
$this->app->bind('FireflyIII\Chart\ChartInterface', 'FireflyIII\Chart\Chart');
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
}
);
}
}