From d83d3982cdea79359fab496fa07d2232dc2f35ed Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Tue, 27 Jul 2021 17:01:48 +0300 Subject: [PATCH] refactoring --- .../Espo/Core/ORM/RepositoryFactory.php | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/application/Espo/Core/ORM/RepositoryFactory.php b/application/Espo/Core/ORM/RepositoryFactory.php index 36965bbdf4..1e59a09299 100644 --- a/application/Espo/Core/ORM/RepositoryFactory.php +++ b/application/Espo/Core/ORM/RepositoryFactory.php @@ -29,6 +29,9 @@ namespace Espo\Core\ORM; +use Espo\Core\Binding\BindingContainerBuilder; +use Espo\Core\Binding\ContextualBinder; + use Espo\Core\{ InjectableFactory, Utils\ClassFinder, @@ -75,9 +78,18 @@ class RepositoryFactory implements RepositoryFactoryInterface $className = $this->defaultClassName; } - return $this->injectableFactory->createWith($className, [ - 'entityFactory' => $this->entityFactory, - 'entityType' => $entityType, - ]); + return $this->injectableFactory->createWithBinding( + $className, + BindingContainerBuilder::create() + ->bindInstance(EntityFactoryInteface::class, $this->entityFactory) + ->bindInstance(EntityFactory::class, $this->entityFactory) + ->inContext( + $className, + function (ContextualBinder $binder) use ($entityType) { + $binder->bindValue('$entityType', $entityType); + } + ) + ->build() + ); } }