2015-02-06 20:43:19 +01:00
|
|
|
<?php
|
2016-05-20 12:41:23 +02:00
|
|
|
/**
|
|
|
|
* FireflyServiceProvider.php
|
2020-02-16 13:55:52 +01:00
|
|
|
* Copyright (c) 2019 james@firefly-iii.org
|
2016-05-20 12:41:23 +02:00
|
|
|
*
|
2019-10-02 06:37:26 +02:00
|
|
|
* This file is part of Firefly III (https://github.com/firefly-iii).
|
2016-10-05 06:52:15 +02:00
|
|
|
*
|
2019-10-02 06:37:26 +02: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 08:40:00 +02:00
|
|
|
*
|
2019-10-02 06:37:26 +02:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
2017-10-21 08:40:00 +02:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
2019-10-02 06:37:26 +02:00
|
|
|
* GNU Affero General Public License for more details.
|
2017-10-21 08:40:00 +02:00
|
|
|
*
|
2019-10-02 06:37:26 +02: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 12:41:23 +02:00
|
|
|
*/
|
2017-03-29 21:20:54 +02:00
|
|
|
declare(strict_types=1);
|
2015-02-06 20:43:19 +01:00
|
|
|
|
|
|
|
namespace FireflyIII\Providers;
|
|
|
|
|
2017-02-02 07:35:53 +01: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 19:10:02 +02:00
|
|
|
use FireflyIII\Helpers\Fiscal\FiscalHelper;
|
|
|
|
use FireflyIII\Helpers\Fiscal\FiscalHelperInterface;
|
2017-02-02 07:35:53 +01:00
|
|
|
use FireflyIII\Helpers\Help\Help;
|
|
|
|
use FireflyIII\Helpers\Help\HelpInterface;
|
2018-08-26 18:40:38 +02:00
|
|
|
use FireflyIII\Helpers\Report\NetWorth;
|
|
|
|
use FireflyIII\Helpers\Report\NetWorthInterface;
|
2017-03-29 21:20:54 +02:00
|
|
|
use FireflyIII\Helpers\Report\PopupReport;
|
|
|
|
use FireflyIII\Helpers\Report\PopupReportInterface;
|
2017-02-02 07:35:53 +01:00
|
|
|
use FireflyIII\Helpers\Report\ReportHelper;
|
|
|
|
use FireflyIII\Helpers\Report\ReportHelperInterface;
|
2020-06-07 11:31:01 +02:00
|
|
|
use FireflyIII\Repositories\ObjectGroup\ObjectGroupRepository;
|
|
|
|
use FireflyIII\Repositories\ObjectGroup\ObjectGroupRepositoryInterface;
|
2020-03-22 07:55:57 +01:00
|
|
|
use FireflyIII\Repositories\Telemetry\TelemetryRepository;
|
|
|
|
use FireflyIII\Repositories\Telemetry\TelemetryRepositoryInterface;
|
2019-03-08 05:47:51 +01:00
|
|
|
use FireflyIII\Repositories\TransactionType\TransactionTypeRepository;
|
|
|
|
use FireflyIII\Repositories\TransactionType\TransactionTypeRepositoryInterface;
|
2017-02-02 07:35:53 +01:00
|
|
|
use FireflyIII\Repositories\User\UserRepository;
|
|
|
|
use FireflyIII\Repositories\User\UserRepositoryInterface;
|
2019-10-26 14:42:51 +02:00
|
|
|
use FireflyIII\Services\FireflyIIIOrg\Update\UpdateRequest;
|
|
|
|
use FireflyIII\Services\FireflyIIIOrg\Update\UpdateRequestInterface;
|
2020-04-11 06:42:40 +02:00
|
|
|
use FireflyIII\Services\Password\PwndVerifierV2;
|
2017-08-04 15:48:26 +02:00
|
|
|
use FireflyIII\Services\Password\Verifier;
|
2015-02-11 07:35:10 +01:00
|
|
|
use FireflyIII\Support\Amount;
|
2019-08-10 16:50:37 +02:00
|
|
|
use FireflyIII\Support\ExpandedForm;
|
2019-08-17 10:47:29 +02:00
|
|
|
use FireflyIII\Support\FireflyConfig;
|
2019-08-10 15:09:44 +02:00
|
|
|
use FireflyIII\Support\Form\AccountForm;
|
2019-08-10 16:50:37 +02:00
|
|
|
use FireflyIII\Support\Form\CurrencyForm;
|
|
|
|
use FireflyIII\Support\Form\PiggyBankForm;
|
|
|
|
use FireflyIII\Support\Form\RuleForm;
|
2015-02-11 07:35:10 +01:00
|
|
|
use FireflyIII\Support\Navigation;
|
|
|
|
use FireflyIII\Support\Preferences;
|
|
|
|
use FireflyIII\Support\Steam;
|
2020-03-13 08:02:38 +01:00
|
|
|
use FireflyIII\Support\Telemetry;
|
2020-08-22 16:55:54 +02:00
|
|
|
use FireflyIII\TransactionRules\Engine\RuleEngineInterface;
|
|
|
|
use FireflyIII\TransactionRules\Engine\SearchRuleEngine;
|
2015-02-11 07:35:10 +01:00
|
|
|
use FireflyIII\Validation\FireflyValidator;
|
2020-06-20 10:22:07 +02:00
|
|
|
use Illuminate\Foundation\Application;
|
2015-02-06 20:43:19 +01:00
|
|
|
use Illuminate\Support\ServiceProvider;
|
2015-02-08 01:15:15 +01:00
|
|
|
use Validator;
|
2015-02-06 20:43:19 +01:00
|
|
|
|
2015-02-08 01:15:15 +01:00
|
|
|
/**
|
2018-07-22 18:50:27 +02:00
|
|
|
*
|
2017-11-15 12:25:49 +01:00
|
|
|
* Class FireflyServiceProvider.
|
2018-07-22 18:50:27 +02:00
|
|
|
*
|
|
|
|
* @codeCoverageIgnore
|
2019-08-17 10:47:29 +02:00
|
|
|
*
|
2015-02-08 01:15:15 +01:00
|
|
|
*/
|
2015-02-06 20:43:19 +01:00
|
|
|
class FireflyServiceProvider extends ServiceProvider
|
|
|
|
{
|
2017-12-22 18:32:43 +01:00
|
|
|
/**
|
|
|
|
* Start provider.
|
|
|
|
*/
|
2018-07-22 18:50:27 +02:00
|
|
|
public function boot(): void
|
2015-02-11 07:35:10 +01:00
|
|
|
{
|
|
|
|
Validator::resolver(
|
2019-12-28 09:44:56 +01:00
|
|
|
static function ($translator, $data, $rules, $messages) {
|
2015-02-11 07:35:10 +01:00
|
|
|
return new FireflyValidator($translator, $data, $rules, $messages);
|
|
|
|
}
|
|
|
|
);
|
2015-02-08 01:15:15 +01:00
|
|
|
}
|
2015-02-11 07:35:10 +01:00
|
|
|
|
2015-05-17 10:30:18 +02:00
|
|
|
/**
|
2017-12-22 18:32:43 +01:00
|
|
|
* Register stuff.
|
2018-07-22 18:50:27 +02:00
|
|
|
*
|
2015-05-17 10:30:18 +02:00
|
|
|
*/
|
2018-07-22 18:50:27 +02:00
|
|
|
public function register(): void
|
2015-02-06 20:43:19 +01:00
|
|
|
{
|
|
|
|
$this->app->bind(
|
2017-11-15 10:52:29 +01:00
|
|
|
'preferences',
|
2020-03-13 08:02:38 +01:00
|
|
|
static function () {
|
2017-11-15 10:52:29 +01:00
|
|
|
return new Preferences;
|
|
|
|
}
|
2015-02-06 20:43:19 +01:00
|
|
|
);
|
2016-07-24 18:47:55 +02:00
|
|
|
|
|
|
|
$this->app->bind(
|
2017-11-15 10:52:29 +01:00
|
|
|
'fireflyconfig',
|
2020-03-13 08:02:38 +01:00
|
|
|
static function () {
|
2017-11-15 10:52:29 +01:00
|
|
|
return new FireflyConfig;
|
|
|
|
}
|
2016-07-24 18:47:55 +02:00
|
|
|
);
|
2015-02-06 21:23:14 +01:00
|
|
|
$this->app->bind(
|
2017-11-15 10:52:29 +01:00
|
|
|
'navigation',
|
2020-03-13 08:02:38 +01:00
|
|
|
static function () {
|
2017-11-15 10:52:29 +01:00
|
|
|
return new Navigation;
|
|
|
|
}
|
2015-02-06 21:23:14 +01:00
|
|
|
);
|
2015-02-07 06:49:24 +01:00
|
|
|
$this->app->bind(
|
2017-11-15 10:52:29 +01:00
|
|
|
'amount',
|
2020-03-13 08:02:38 +01:00
|
|
|
static function () {
|
2017-11-15 10:52:29 +01:00
|
|
|
return new Amount;
|
|
|
|
}
|
2015-02-07 06:49:24 +01:00
|
|
|
);
|
2015-02-07 08:23:44 +01:00
|
|
|
|
|
|
|
$this->app->bind(
|
2017-11-15 10:52:29 +01:00
|
|
|
'steam',
|
2020-03-13 08:02:38 +01:00
|
|
|
static function () {
|
2017-11-15 10:52:29 +01:00
|
|
|
return new Steam;
|
|
|
|
}
|
2015-02-07 08:23:44 +01:00
|
|
|
);
|
2015-02-08 01:15:15 +01:00
|
|
|
$this->app->bind(
|
2017-11-15 10:52:29 +01:00
|
|
|
'expandedform',
|
2019-08-10 16:50:37 +02:00
|
|
|
static function () {
|
2017-11-15 10:52:29 +01:00
|
|
|
return new ExpandedForm;
|
|
|
|
}
|
2015-02-08 01:15:15 +01:00
|
|
|
);
|
2015-02-09 07:23:39 +01:00
|
|
|
|
2019-08-10 15:09:44 +02:00
|
|
|
$this->app->bind(
|
|
|
|
'accountform',
|
|
|
|
static function () {
|
|
|
|
return new AccountForm;
|
|
|
|
}
|
|
|
|
);
|
2019-08-10 16:50:37 +02: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 15:09:44 +02:00
|
|
|
|
2020-03-13 08:02:38 +01:00
|
|
|
$this->app->bind(
|
|
|
|
'telemetry',
|
|
|
|
static function () {
|
|
|
|
return new Telemetry;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
2016-12-11 16:02:04 +01:00
|
|
|
// chart generator:
|
2017-02-02 07:35:53 +01:00
|
|
|
$this->app->bind(GeneratorInterface::class, ChartJsGenerator::class);
|
2016-12-11 16:02:04 +01:00
|
|
|
|
2017-01-03 17:02:17 +01:00
|
|
|
|
2016-12-11 16:25:46 +01:00
|
|
|
// other generators
|
2017-02-02 07:35:53 +01:00
|
|
|
$this->app->bind(UserRepositoryInterface::class, UserRepository::class);
|
2019-03-08 05:47:51 +01:00
|
|
|
$this->app->bind(TransactionTypeRepositoryInterface::class, TransactionTypeRepository::class);
|
2020-06-20 10:22:07 +02:00
|
|
|
|
2017-02-02 07:35:53 +01:00
|
|
|
$this->app->bind(AttachmentHelperInterface::class, AttachmentHelper::class);
|
2016-12-25 12:55:22 +01:00
|
|
|
|
2020-06-20 10:22:07 +02: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 16:55:54 +02: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 21:20:54 +02:00
|
|
|
// more generators:
|
|
|
|
$this->app->bind(PopupReportInterface::class, PopupReport::class);
|
2017-02-02 07:35:53 +01:00
|
|
|
$this->app->bind(HelpInterface::class, Help::class);
|
|
|
|
$this->app->bind(ReportHelperInterface::class, ReportHelper::class);
|
2017-02-17 06:42:36 +01:00
|
|
|
$this->app->bind(FiscalHelperInterface::class, FiscalHelper::class);
|
2019-10-26 14:42:51 +02:00
|
|
|
$this->app->bind(UpdateRequestInterface::class, UpdateRequest::class);
|
2020-03-22 07:55:57 +01:00
|
|
|
$this->app->bind(TelemetryRepositoryInterface::class, TelemetryRepository::class);
|
2019-10-26 14:42:51 +02:00
|
|
|
|
2017-08-04 15:46:52 +02:00
|
|
|
// password verifier thing
|
2020-04-11 06:42:40 +02:00
|
|
|
$this->app->bind(Verifier::class, PwndVerifierV2::class);
|
2018-04-10 21:18:38 +02:00
|
|
|
|
2018-08-26 18:40:38 +02:00
|
|
|
// net worth thing.
|
|
|
|
$this->app->bind(NetWorthInterface::class, NetWorth::class);
|
2015-02-06 20:43:19 +01:00
|
|
|
}
|
2015-03-29 08:14:32 +02:00
|
|
|
}
|