2015-02-06 13:43:19 -06:00
|
|
|
<?php
|
2016-05-20 05:41:23 -05:00
|
|
|
/**
|
|
|
|
* FireflyServiceProvider.php
|
2020-02-16 06:55:52 -06:00
|
|
|
* Copyright (c) 2019 james@firefly-iii.org
|
2016-05-20 05:41:23 -05:00
|
|
|
*
|
2019-10-01 23:37:26 -05:00
|
|
|
* This file is part of Firefly III (https://github.com/firefly-iii).
|
2016-10-04 23:52:15 -05:00
|
|
|
*
|
2019-10-01 23:37:26 -05:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as
|
|
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
|
|
* License, or (at your option) any later version.
|
2017-10-21 01:40:00 -05:00
|
|
|
*
|
2019-10-01 23:37:26 -05:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
2017-10-21 01:40:00 -05:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2019-10-01 23:37:26 -05:00
|
|
|
* GNU Affero General Public License for more details.
|
2017-10-21 01:40:00 -05:00
|
|
|
*
|
2019-10-01 23:37:26 -05:00
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2016-05-20 05:41:23 -05:00
|
|
|
*/
|
2017-03-29 14:20:54 -05:00
|
|
|
declare(strict_types=1);
|
2015-02-06 13:43:19 -06:00
|
|
|
|
|
|
|
namespace FireflyIII\Providers;
|
|
|
|
|
2019-02-13 10:38:41 -06:00
|
|
|
use FireflyIII\Exceptions\FireflyException;
|
2017-02-02 00:35:53 -06:00
|
|
|
use FireflyIII\Generator\Chart\Basic\ChartJsGenerator;
|
|
|
|
use FireflyIII\Generator\Chart\Basic\GeneratorInterface;
|
|
|
|
use FireflyIII\Helpers\Attachments\AttachmentHelper;
|
|
|
|
use FireflyIII\Helpers\Attachments\AttachmentHelperInterface;
|
2019-06-21 12:10:02 -05:00
|
|
|
use FireflyIII\Helpers\Fiscal\FiscalHelper;
|
|
|
|
use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
|
2017-02-02 00:35:53 -06:00
|
|
|
use FireflyIII\Helpers\Help\Help;
|
|
|
|
use FireflyIII\Helpers\Help\HelpInterface;
|
2018-08-26 11:40:38 -05:00
|
|
|
use FireflyIII\Helpers\Report\NetWorth;
|
|
|
|
use FireflyIII\Helpers\Report\NetWorthInterface;
|
2017-03-29 14:20:54 -05:00
|
|
|
use FireflyIII\Helpers\Report\PopupReport;
|
|
|
|
use FireflyIII\Helpers\Report\PopupReportInterface;
|
2017-02-02 00:35:53 -06:00
|
|
|
use FireflyIII\Helpers\Report\ReportHelper;
|
|
|
|
use FireflyIII\Helpers\Report\ReportHelperInterface;
|
2020-06-07 04:31:01 -05:00
|
|
|
use FireflyIII\Repositories\ObjectGroup\ObjectGroupRepository;
|
|
|
|
use FireflyIII\Repositories\ObjectGroup\ObjectGroupRepositoryInterface;
|
2020-03-22 01:55:57 -05:00
|
|
|
use FireflyIII\Repositories\Telemetry\TelemetryRepository;
|
|
|
|
use FireflyIII\Repositories\Telemetry\TelemetryRepositoryInterface;
|
2019-03-07 22:47:51 -06:00
|
|
|
use FireflyIII\Repositories\TransactionType\TransactionTypeRepository;
|
|
|
|
use FireflyIII\Repositories\TransactionType\TransactionTypeRepositoryInterface;
|
2017-02-02 00:35:53 -06:00
|
|
|
use FireflyIII\Repositories\User\UserRepository;
|
|
|
|
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
2018-03-25 02:00:45 -05:00
|
|
|
use FireflyIII\Services\Currency\ExchangeRateInterface;
|
2019-10-26 07:42:51 -05:00
|
|
|
use FireflyIII\Services\FireflyIIIOrg\Update\UpdateRequest;
|
|
|
|
use FireflyIII\Services\FireflyIIIOrg\Update\UpdateRequestInterface;
|
2018-04-10 14:18:38 -05:00
|
|
|
use FireflyIII\Services\IP\IpifyOrg;
|
|
|
|
use FireflyIII\Services\IP\IPRetrievalInterface;
|
2020-04-10 23:42:40 -05:00
|
|
|
use FireflyIII\Services\Password\PwndVerifierV2;
|
2017-08-04 08:48:26 -05:00
|
|
|
use FireflyIII\Services\Password\Verifier;
|
2015-02-11 00:35:10 -06:00
|
|
|
use FireflyIII\Support\Amount;
|
2019-08-10 09:50:37 -05:00
|
|
|
use FireflyIII\Support\ExpandedForm;
|
2019-08-17 03:47:29 -05:00
|
|
|
use FireflyIII\Support\FireflyConfig;
|
2019-08-10 08:09:44 -05:00
|
|
|
use FireflyIII\Support\Form\AccountForm;
|
2019-08-10 09:50:37 -05:00
|
|
|
use FireflyIII\Support\Form\CurrencyForm;
|
|
|
|
use FireflyIII\Support\Form\PiggyBankForm;
|
|
|
|
use FireflyIII\Support\Form\RuleForm;
|
2015-02-11 00:35:10 -06:00
|
|
|
use FireflyIII\Support\Navigation;
|
|
|
|
use FireflyIII\Support\Preferences;
|
|
|
|
use FireflyIII\Support\Steam;
|
2020-03-13 02:02:38 -05:00
|
|
|
use FireflyIII\Support\Telemetry;
|
2020-08-22 09:55:54 -05:00
|
|
|
use FireflyIII\TransactionRules\Engine\RuleEngineInterface;
|
|
|
|
use FireflyIII\TransactionRules\Engine\SearchRuleEngine;
|
2015-02-11 00:35:10 -06:00
|
|
|
use FireflyIII\Validation\FireflyValidator;
|
2020-06-20 03:22:07 -05:00
|
|
|
use Illuminate\Foundation\Application;
|
2015-02-06 13:43:19 -06:00
|
|
|
use Illuminate\Support\ServiceProvider;
|
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
|
|
|
/**
|
2018-07-22 11:50:27 -05:00
|
|
|
*
|
2017-11-15 05:25:49 -06:00
|
|
|
* Class FireflyServiceProvider.
|
2018-07-22 11:50:27 -05:00
|
|
|
*
|
|
|
|
* @codeCoverageIgnore
|
2019-08-17 03:47:29 -05:00
|
|
|
*
|
2015-02-07 18:15:15 -06:00
|
|
|
*/
|
2015-02-06 13:43:19 -06:00
|
|
|
class FireflyServiceProvider extends ServiceProvider
|
|
|
|
{
|
2017-12-22 11:32:43 -06:00
|
|
|
/**
|
|
|
|
* Start provider.
|
|
|
|
*/
|
2018-07-22 11:50:27 -05:00
|
|
|
public function boot(): void
|
2015-02-11 00:35:10 -06:00
|
|
|
{
|
|
|
|
Validator::resolver(
|
2019-12-28 02:44:56 -06:00
|
|
|
static function ($translator, $data, $rules, $messages) {
|
2015-02-11 00:35:10 -06:00
|
|
|
return new FireflyValidator($translator, $data, $rules, $messages);
|
|
|
|
}
|
|
|
|
);
|
2015-02-07 18:15:15 -06:00
|
|
|
}
|
2015-02-11 00:35:10 -06:00
|
|
|
|
2015-05-17 03:30:18 -05:00
|
|
|
/**
|
2017-12-22 11:32:43 -06:00
|
|
|
* Register stuff.
|
2018-07-22 11:50:27 -05:00
|
|
|
*
|
2015-05-17 03:30:18 -05:00
|
|
|
*/
|
2018-07-22 11:50:27 -05:00
|
|
|
public function register(): void
|
2015-02-06 13:43:19 -06:00
|
|
|
{
|
|
|
|
$this->app->bind(
|
2017-11-15 03:52:29 -06:00
|
|
|
'preferences',
|
2020-03-13 02:02:38 -05:00
|
|
|
static function () {
|
2017-11-15 03:52:29 -06:00
|
|
|
return new Preferences;
|
|
|
|
}
|
2015-02-06 13:43:19 -06:00
|
|
|
);
|
2016-07-24 11:47:55 -05:00
|
|
|
|
|
|
|
$this->app->bind(
|
2017-11-15 03:52:29 -06:00
|
|
|
'fireflyconfig',
|
2020-03-13 02:02:38 -05:00
|
|
|
static function () {
|
2017-11-15 03:52:29 -06:00
|
|
|
return new FireflyConfig;
|
|
|
|
}
|
2016-07-24 11:47:55 -05:00
|
|
|
);
|
2015-02-06 14:23:14 -06:00
|
|
|
$this->app->bind(
|
2017-11-15 03:52:29 -06:00
|
|
|
'navigation',
|
2020-03-13 02:02:38 -05:00
|
|
|
static function () {
|
2017-11-15 03:52:29 -06:00
|
|
|
return new Navigation;
|
|
|
|
}
|
2015-02-06 14:23:14 -06:00
|
|
|
);
|
2015-02-06 23:49:24 -06:00
|
|
|
$this->app->bind(
|
2017-11-15 03:52:29 -06:00
|
|
|
'amount',
|
2020-03-13 02:02:38 -05:00
|
|
|
static function () {
|
2017-11-15 03:52:29 -06:00
|
|
|
return new Amount;
|
|
|
|
}
|
2015-02-06 23:49:24 -06:00
|
|
|
);
|
2015-02-07 01:23:44 -06:00
|
|
|
|
|
|
|
$this->app->bind(
|
2017-11-15 03:52:29 -06:00
|
|
|
'steam',
|
2020-03-13 02:02:38 -05:00
|
|
|
static function () {
|
2017-11-15 03:52:29 -06:00
|
|
|
return new Steam;
|
|
|
|
}
|
2015-02-07 01:23:44 -06:00
|
|
|
);
|
2015-02-07 18:15:15 -06:00
|
|
|
$this->app->bind(
|
2017-11-15 03:52:29 -06:00
|
|
|
'expandedform',
|
2019-08-10 09:50:37 -05:00
|
|
|
static function () {
|
2017-11-15 03:52:29 -06:00
|
|
|
return new ExpandedForm;
|
|
|
|
}
|
2015-02-07 18:15:15 -06:00
|
|
|
);
|
2015-02-09 00:23:39 -06:00
|
|
|
|
2019-08-10 08:09:44 -05:00
|
|
|
$this->app->bind(
|
|
|
|
'accountform',
|
|
|
|
static function () {
|
|
|
|
return new AccountForm;
|
|
|
|
}
|
|
|
|
);
|
2019-08-10 09:50:37 -05:00
|
|
|
$this->app->bind(
|
|
|
|
'currencyform',
|
|
|
|
static function () {
|
|
|
|
return new CurrencyForm;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->app->bind(
|
|
|
|
'piggybankform',
|
|
|
|
static function () {
|
|
|
|
return new PiggyBankForm;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->app->bind(
|
|
|
|
'ruleform',
|
|
|
|
static function () {
|
|
|
|
return new RuleForm;
|
|
|
|
}
|
|
|
|
);
|
2019-08-10 08:09:44 -05:00
|
|
|
|
2020-03-13 02:02:38 -05:00
|
|
|
$this->app->bind(
|
|
|
|
'telemetry',
|
|
|
|
static function () {
|
|
|
|
return new Telemetry;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2016-12-11 09:02:04 -06:00
|
|
|
// chart generator:
|
2017-02-02 00:35:53 -06:00
|
|
|
$this->app->bind(GeneratorInterface::class, ChartJsGenerator::class);
|
2016-12-11 09:02:04 -06:00
|
|
|
|
2017-01-03 10:02:17 -06:00
|
|
|
|
2016-12-11 09:25:46 -06:00
|
|
|
// other generators
|
2017-02-02 00:35:53 -06:00
|
|
|
$this->app->bind(UserRepositoryInterface::class, UserRepository::class);
|
2019-03-07 22:47:51 -06:00
|
|
|
$this->app->bind(TransactionTypeRepositoryInterface::class, TransactionTypeRepository::class);
|
2020-06-20 03:22:07 -05:00
|
|
|
|
2017-02-02 00:35:53 -06:00
|
|
|
$this->app->bind(AttachmentHelperInterface::class, AttachmentHelper::class);
|
2016-12-25 05:55:22 -06:00
|
|
|
|
2020-06-20 03:22:07 -05:00
|
|
|
|
|
|
|
$this->app->bind(
|
|
|
|
ObjectGroupRepositoryInterface::class,
|
|
|
|
static function (Application $app) {
|
|
|
|
/** @var ObjectGroupRepository $repository */
|
|
|
|
$repository = app(ObjectGroupRepository::class);
|
|
|
|
if ($app->auth->check()) {
|
|
|
|
$repository->setUser(auth()->user());
|
|
|
|
}
|
|
|
|
|
|
|
|
return $repository;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2020-08-22 09:55:54 -05:00
|
|
|
$this->app->bind(
|
|
|
|
RuleEngineInterface::class,
|
|
|
|
static function (Application $app) {
|
|
|
|
/** @var SearchRuleEngine $engine */
|
|
|
|
$engine = app(SearchRuleEngine::class);
|
|
|
|
if ($app->auth->check()) {
|
|
|
|
$engine->setUser(auth()->user());
|
|
|
|
}
|
|
|
|
|
|
|
|
return $engine;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2017-03-29 14:20:54 -05:00
|
|
|
// more generators:
|
|
|
|
$this->app->bind(PopupReportInterface::class, PopupReport::class);
|
2017-02-02 00:35:53 -06:00
|
|
|
$this->app->bind(HelpInterface::class, Help::class);
|
|
|
|
$this->app->bind(ReportHelperInterface::class, ReportHelper::class);
|
2017-02-16 23:42:36 -06:00
|
|
|
$this->app->bind(FiscalHelperInterface::class, FiscalHelper::class);
|
2019-10-26 07:42:51 -05:00
|
|
|
$this->app->bind(UpdateRequestInterface::class, UpdateRequest::class);
|
2020-03-22 01:55:57 -05:00
|
|
|
$this->app->bind(TelemetryRepositoryInterface::class, TelemetryRepository::class);
|
2019-10-26 07:42:51 -05:00
|
|
|
|
2020-06-20 03:22:07 -05:00
|
|
|
$class = (string) config(sprintf('firefly.cer_providers.%s', (string) config('firefly.cer_provider')));
|
2019-02-13 10:38:41 -06:00
|
|
|
if ('' === $class) {
|
2019-01-01 09:32:22 -06:00
|
|
|
throw new FireflyException('Invalid currency exchange rate provider. Cannot continue.');
|
|
|
|
}
|
|
|
|
$this->app->bind(ExchangeRateInterface::class, $class);
|
2017-08-04 08:46:52 -05:00
|
|
|
|
|
|
|
// password verifier thing
|
2020-04-10 23:42:40 -05:00
|
|
|
$this->app->bind(Verifier::class, PwndVerifierV2::class);
|
2018-04-10 14:18:38 -05:00
|
|
|
|
|
|
|
// IP thing:
|
|
|
|
$this->app->bind(IPRetrievalInterface::class, IpifyOrg::class);
|
2018-08-26 11:40:38 -05:00
|
|
|
|
|
|
|
// net worth thing.
|
|
|
|
$this->app->bind(NetWorthInterface::class, NetWorth::class);
|
2015-02-06 13:43:19 -06:00
|
|
|
}
|
2015-03-29 01:14:32 -05:00
|
|
|
}
|