refactor: inject ExpressionLanguage singleton using DI

This commit is contained in:
Michael Thomas
2024-03-07 13:00:57 -05:00
parent 438f602961
commit bee219ebf7
21 changed files with 122 additions and 164 deletions

View File

@@ -19,6 +19,7 @@
* 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/>.
*/
declare(strict_types=1);
namespace FireflyIII\Providers;
@@ -69,9 +70,11 @@ use FireflyIII\Support\Preferences;
use FireflyIII\Support\Steam;
use FireflyIII\TransactionRules\Engine\RuleEngineInterface;
use FireflyIII\TransactionRules\Engine\SearchRuleEngine;
use FireflyIII\TransactionRules\Expressions\ActionExpressionLanguageProvider;
use FireflyIII\Validation\FireflyValidator;
use Illuminate\Foundation\Application;
use Illuminate\Support\ServiceProvider;
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;
/**
* Class FireflyServiceProvider.
@@ -200,6 +203,16 @@ class FireflyServiceProvider extends ServiceProvider
}
);
// rule expression language
$this->app->singleton(
ExpressionLanguage::class,
static function () {
$expressionLanguage = new ExpressionLanguage();
$expressionLanguage->registerProvider(new ActionExpressionLanguageProvider());
return $expressionLanguage;
}
);
$this->app->bind(
RuleEngineInterface::class,
static function (Application $app) {