2015-02-06 13:43:19 -06:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace FireflyIII\Providers;
|
|
|
|
|
2015-05-01 01:29:41 -05:00
|
|
|
use App;
|
2015-05-01 11:44:49 -05:00
|
|
|
use FireflyIII\Models\Account;
|
2015-02-11 00:35:10 -06:00
|
|
|
use FireflyIII\Support\Amount;
|
|
|
|
use FireflyIII\Support\ExpandedForm;
|
|
|
|
use FireflyIII\Support\Navigation;
|
|
|
|
use FireflyIII\Support\Preferences;
|
|
|
|
use FireflyIII\Support\Steam;
|
|
|
|
use FireflyIII\Validation\FireflyValidator;
|
2015-02-06 13:43:19 -06:00
|
|
|
use Illuminate\Support\ServiceProvider;
|
2015-05-01 11:44:49 -05:00
|
|
|
use Route;
|
2015-05-01 01:29:41 -05:00
|
|
|
use Twig;
|
2015-05-01 11:44:49 -05:00
|
|
|
use Twig_SimpleFilter;
|
|
|
|
use Twig_SimpleFunction;
|
2015-05-01 01:29:41 -05:00
|
|
|
use TwigBridge\Extension\Loader\Functions;
|
2015-02-07 18:15:15 -06:00
|
|
|
use Validator;
|
2015-02-06 13:43:19 -06:00
|
|
|
|
2015-02-07 18:15:15 -06:00
|
|
|
/**
|
|
|
|
* Class FireflyServiceProvider
|
|
|
|
*
|
|
|
|
* @package FireflyIII\Providers
|
|
|
|
*/
|
2015-02-06 13:43:19 -06:00
|
|
|
class FireflyServiceProvider extends ServiceProvider
|
|
|
|
{
|
2015-02-11 00:35:10 -06:00
|
|
|
public function boot()
|
|
|
|
{
|
|
|
|
Validator::resolver(
|
|
|
|
function ($translator, $data, $rules, $messages) {
|
|
|
|
return new FireflyValidator($translator, $data, $rules, $messages);
|
|
|
|
}
|
|
|
|
);
|
2015-05-01 11:44:49 -05:00
|
|
|
/*
|
|
|
|
* Default Twig configuration:
|
|
|
|
*/
|
|
|
|
$config = App::make('config');
|
|
|
|
Twig::addExtension(new Functions($config));
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Amount::format
|
|
|
|
*/
|
|
|
|
$filter = new Twig_SimpleFilter(
|
|
|
|
'formatAmount', function ($string) {
|
|
|
|
return App::make('amount')->format($string);
|
|
|
|
}, ['is_safe' => ['html']]
|
|
|
|
);
|
|
|
|
Twig::addFilter($filter);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Amount::formatJournal
|
|
|
|
*/
|
|
|
|
$filter = new Twig_SimpleFilter(
|
|
|
|
'formatJournal', function ($journal) {
|
|
|
|
return App::make('amount')->formatJournal($journal);
|
|
|
|
}, ['is_safe' => ['html']]
|
|
|
|
);
|
|
|
|
Twig::addFilter($filter);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Steam::balance()
|
|
|
|
*/
|
|
|
|
|
|
|
|
$filter = new Twig_SimpleFilter(
|
|
|
|
'balance', function (Account $account = null) {
|
|
|
|
if (is_null($account)) {
|
|
|
|
return 'NULL';
|
|
|
|
}
|
|
|
|
|
|
|
|
return App::make('amount')->format(App::make('steam')->balance($account));
|
|
|
|
//return App::make('steam')->balance($account);
|
|
|
|
},['is_safe' => ['html']]
|
|
|
|
);
|
|
|
|
Twig::addFilter($filter);
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Current active route.
|
|
|
|
*/
|
|
|
|
$filter = new Twig_SimpleFilter(
|
|
|
|
'activeRoute', function ($string) {
|
|
|
|
if (Route::getCurrentRoute()->getName() == $string) {
|
|
|
|
return 'active';
|
|
|
|
}
|
|
|
|
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
);
|
|
|
|
Twig::addFilter($filter);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Amount::getCurrencyCode()
|
|
|
|
*/
|
|
|
|
$function = new Twig_SimpleFunction(
|
|
|
|
'getCurrencyCode', function () {
|
|
|
|
return App::make('amount')->getCurrencyCode();
|
|
|
|
}
|
|
|
|
);
|
|
|
|
Twig::addFunction($function);
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* env
|
|
|
|
*/
|
|
|
|
$function = new Twig_SimpleFunction(
|
|
|
|
'env', function ($a, $b) {
|
|
|
|
return env($a, $b);
|
|
|
|
}
|
|
|
|
);
|
|
|
|
Twig::addFunction($function);
|
2015-05-01 01:29:41 -05:00
|
|
|
|
2015-02-07 18:15:15 -06:00
|
|
|
}
|
2015-02-11 00:35:10 -06:00
|
|
|
|
2015-02-06 13:43:19 -06:00
|
|
|
public function register()
|
|
|
|
{
|
2015-05-01 01:29:41 -05:00
|
|
|
|
|
|
|
|
2015-02-06 13:43:19 -06:00
|
|
|
$this->app->bind(
|
|
|
|
'preferences', function () {
|
2015-02-11 00:35:10 -06:00
|
|
|
return new Preferences;
|
2015-02-06 13:43:19 -06:00
|
|
|
}
|
|
|
|
);
|
2015-02-06 14:23:14 -06:00
|
|
|
$this->app->bind(
|
|
|
|
'navigation', function () {
|
2015-02-11 00:35:10 -06:00
|
|
|
return new Navigation;
|
2015-02-06 14:23:14 -06:00
|
|
|
}
|
|
|
|
);
|
2015-02-06 23:49:24 -06:00
|
|
|
$this->app->bind(
|
|
|
|
'amount', function () {
|
2015-02-11 00:35:10 -06:00
|
|
|
return new Amount;
|
2015-02-06 23:49:24 -06:00
|
|
|
}
|
|
|
|
);
|
2015-02-07 01:23:44 -06:00
|
|
|
|
|
|
|
$this->app->bind(
|
|
|
|
'steam', function () {
|
2015-02-11 00:35:10 -06:00
|
|
|
return new Steam;
|
2015-02-07 01:23:44 -06:00
|
|
|
}
|
|
|
|
);
|
2015-02-07 18:15:15 -06:00
|
|
|
$this->app->bind(
|
|
|
|
'expandedform', function () {
|
2015-02-11 00:35:10 -06:00
|
|
|
return new ExpandedForm;
|
2015-02-07 18:15:15 -06:00
|
|
|
}
|
|
|
|
);
|
2015-02-09 00:23:39 -06:00
|
|
|
|
|
|
|
$this->app->bind('FireflyIII\Repositories\Account\AccountRepositoryInterface', 'FireflyIII\Repositories\Account\AccountRepository');
|
2015-02-22 02:46:21 -06:00
|
|
|
$this->app->bind('FireflyIII\Repositories\Budget\BudgetRepositoryInterface', 'FireflyIII\Repositories\Budget\BudgetRepository');
|
2015-02-22 09:19:32 -06:00
|
|
|
$this->app->bind('FireflyIII\Repositories\Category\CategoryRepositoryInterface', 'FireflyIII\Repositories\Category\CategoryRepository');
|
2015-02-09 00:23:39 -06:00
|
|
|
$this->app->bind('FireflyIII\Repositories\Journal\JournalRepositoryInterface', 'FireflyIII\Repositories\Journal\JournalRepository');
|
2015-02-25 08:19:14 -06:00
|
|
|
$this->app->bind('FireflyIII\Repositories\Bill\BillRepositoryInterface', 'FireflyIII\Repositories\Bill\BillRepository');
|
2015-02-25 12:32:33 -06:00
|
|
|
$this->app->bind('FireflyIII\Repositories\PiggyBank\PiggyBankRepositoryInterface', 'FireflyIII\Repositories\PiggyBank\PiggyBankRepository');
|
2015-04-05 13:47:19 -05:00
|
|
|
$this->app->bind('FireflyIII\Repositories\Currency\CurrencyRepositoryInterface', 'FireflyIII\Repositories\Currency\CurrencyRepository');
|
2015-04-28 01:58:01 -05:00
|
|
|
$this->app->bind('FireflyIII\Repositories\Tag\TagRepositoryInterface', 'FireflyIII\Repositories\Tag\TagRepository');
|
2015-02-27 04:09:23 -06:00
|
|
|
$this->app->bind('FireflyIII\Support\Search\SearchInterface', 'FireflyIII\Support\Search\Search');
|
2015-02-22 09:19:32 -06:00
|
|
|
|
2015-03-07 02:21:06 -06:00
|
|
|
|
2015-04-07 12:58:49 -05:00
|
|
|
$this->app->bind('FireflyIII\Helpers\Help\HelpInterface', 'FireflyIII\Helpers\Help\Help');
|
2015-03-07 02:21:06 -06:00
|
|
|
$this->app->bind('FireflyIII\Helpers\Reminders\ReminderHelperInterface', 'FireflyIII\Helpers\Reminders\ReminderHelper');
|
2015-02-23 13:25:48 -06:00
|
|
|
$this->app->bind('FireflyIII\Helpers\Report\ReportHelperInterface', 'FireflyIII\Helpers\Report\ReportHelper');
|
|
|
|
$this->app->bind('FireflyIII\Helpers\Report\ReportQueryInterface', 'FireflyIII\Helpers\Report\ReportQuery');
|
|
|
|
|
2015-05-01 01:29:41 -05:00
|
|
|
|
2015-02-06 13:43:19 -06:00
|
|
|
}
|
|
|
|
|
2015-03-29 01:14:32 -05:00
|
|
|
}
|