From 5f95859bcd2d0bd56400b8cd304ca2e93df9775f Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Wed, 23 Dec 2020 09:21:15 +0200 Subject: [PATCH 1/4] delete orm metadata service --- application/Espo/Core/Loaders/OrmMetadata.php | 50 ------------------- 1 file changed, 50 deletions(-) delete mode 100644 application/Espo/Core/Loaders/OrmMetadata.php diff --git a/application/Espo/Core/Loaders/OrmMetadata.php b/application/Espo/Core/Loaders/OrmMetadata.php deleted file mode 100644 index 4623bb10df..0000000000 --- a/application/Espo/Core/Loaders/OrmMetadata.php +++ /dev/null @@ -1,50 +0,0 @@ -entityManager = $entityManager; - } - - public function load() : Metadata - { - return $this->entityManager->getMetadata(); - } -} From 9642f9ae41e3798ecd24238269c3d16ae9ee9e78 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Wed, 23 Dec 2020 09:32:51 +0200 Subject: [PATCH 2/4] entity manager factory --- .../Espo/Core/Loaders/EntityManager.php | 64 ++---------- .../Espo/Core/ORM/EntityManagerFactory.php | 97 +++++++++++++++++++ 2 files changed, 103 insertions(+), 58 deletions(-) create mode 100644 application/Espo/Core/ORM/EntityManagerFactory.php diff --git a/application/Espo/Core/Loaders/EntityManager.php b/application/Espo/Core/Loaders/EntityManager.php index a990e0616a..d9dc496d27 100644 --- a/application/Espo/Core/Loaders/EntityManager.php +++ b/application/Espo/Core/Loaders/EntityManager.php @@ -30,73 +30,21 @@ namespace Espo\Core\Loaders; use Espo\Core\{ - Utils\Config, - InjectableFactory, + ORM\EntityManagerFactory, ORM\EntityManager as EntityManagerService, - ORM\RepositoryFactory, - ORM\EntityFactory, - ORM\Helper, - ORM\MetadataDataProvider, -}; - -use Espo\{ - ORM\Metadata as OrmMetadata, }; class EntityManager implements Loader { - protected $config; - protected $injectableFactory; - protected $metadataDataProvider; + protected $entityManagerFactory; - public function __construct( - Config $config, - InjectableFactory $injectableFactory, - MetadataDataProvider $metadataDataProvider - ) { - $this->config = $config; - $this->injectableFactory = $injectableFactory; - $this->metadataDataProvider = $metadataDataProvider; + public function __construct(EntityManagerFactory $entityManagerFactory) + { + $this->entityManagerFactory = $entityManagerFactory; } public function load() : EntityManagerService { - $entityFactory = $this->injectableFactory->create(EntityFactory::class); - - $repositoryFactory = $this->injectableFactory->createWith(RepositoryFactory::class, [ - 'entityFactory' => $entityFactory, - ]); - - $helper = $this->injectableFactory->create(Helper::class); - - $config = $this->config; - - $params = [ - 'host' => $config->get('database.host'), - 'port' => $config->get('database.port'), - 'dbname' => $config->get('database.dbname'), - 'user' => $config->get('database.user'), - 'charset' => $config->get('database.charset', 'utf8'), - 'password' => $config->get('database.password'), - 'driver' => $config->get('database.driver'), - 'platform' => $config->get('database.platform'), - 'sslCA' => $config->get('database.sslCA'), - 'sslCert' => $config->get('database.sslCert'), - 'sslKey' => $config->get('database.sslKey'), - 'sslCAPath' => $config->get('database.sslCAPath'), - 'sslCipher' => $config->get('database.sslCipher'), - ]; - - $metadata = new OrmMetadata($this->metadataDataProvider); - - $entityManager = $this->injectableFactory->createWith(EntityManagerService::class, [ - 'params' => $params, - 'metadata' => $metadata, - 'repositoryFactory' => $repositoryFactory, - 'entityFactory' => $entityFactory, - 'helper' => $helper, - ]); - - return $entityManager; + return $this->entityManagerFactory->create(); } } diff --git a/application/Espo/Core/ORM/EntityManagerFactory.php b/application/Espo/Core/ORM/EntityManagerFactory.php new file mode 100644 index 0000000000..67ef69d876 --- /dev/null +++ b/application/Espo/Core/ORM/EntityManagerFactory.php @@ -0,0 +1,97 @@ +config = $config; + $this->injectableFactory = $injectableFactory; + $this->metadataDataProvider = $metadataDataProvider; + } + + public function create() : EntityManager + { + $entityFactory = $this->injectableFactory->create(EntityFactory::class); + + $repositoryFactory = $this->injectableFactory->createWith(RepositoryFactory::class, [ + 'entityFactory' => $entityFactory, + ]); + + $helper = $this->injectableFactory->create(Helper::class); + + $config = $this->config; + + $params = [ + 'host' => $config->get('database.host'), + 'port' => $config->get('database.port'), + 'dbname' => $config->get('database.dbname'), + 'user' => $config->get('database.user'), + 'charset' => $config->get('database.charset', 'utf8'), + 'password' => $config->get('database.password'), + 'driver' => $config->get('database.driver'), + 'platform' => $config->get('database.platform'), + 'sslCA' => $config->get('database.sslCA'), + 'sslCert' => $config->get('database.sslCert'), + 'sslKey' => $config->get('database.sslKey'), + 'sslCAPath' => $config->get('database.sslCAPath'), + 'sslCipher' => $config->get('database.sslCipher'), + ]; + + $metadata = new Metadata($this->metadataDataProvider); + + $entityManager = $this->injectableFactory->createWith(EntityManager::class, [ + 'params' => $params, + 'metadata' => $metadata, + 'repositoryFactory' => $repositoryFactory, + 'entityFactory' => $entityFactory, + 'helper' => $helper, + ]); + + return $entityManager; + } +} From e43265fe57e691032f9cdd3dc8bf463224312385 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Wed, 23 Dec 2020 09:33:19 +0200 Subject: [PATCH 3/4] gruntfile fix --- Gruntfile.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 90be173ab4..1ea77f9f43 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -315,11 +315,11 @@ module.exports = function (grunt) { }); grunt.registerTask("unit-tests-run", function() { - cp.execSync("vendor/bin/phpunit --bootstrap=./vendor/autoload.php ./tests/unit", {stdio: 'inherit'}); + cp.execSync("vendor/bin/phpunit ./tests/unit", {stdio: 'inherit'}); }); grunt.registerTask("integration-tests-run", function() { - cp.execSync("vendor/bin/phpunit --bootstrap=./vendor/autoload.php ./tests/integration", {stdio: 'inherit'}); + cp.execSync("vendor/bin/phpunit ./tests/integration", {stdio: 'inherit'}); }); grunt.registerTask("zip", function() { From 713ecb3be7e6041fc8a5bc2e38aa4e66a51ef003 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Fri, 25 Dec 2020 14:02:42 +0200 Subject: [PATCH 4/4] fix orm select builder --- application/Espo/ORM/QueryParams/SelectBuilder.php | 1 + 1 file changed, 1 insertion(+) diff --git a/application/Espo/ORM/QueryParams/SelectBuilder.php b/application/Espo/ORM/QueryParams/SelectBuilder.php index f810ac9f84..b9cea30cb5 100644 --- a/application/Espo/ORM/QueryParams/SelectBuilder.php +++ b/application/Espo/ORM/QueryParams/SelectBuilder.php @@ -30,6 +30,7 @@ namespace Espo\ORM\QueryParams; use InvalidArgumentException; +use RuntimeException; class SelectBuilder implements Builder {