diff --git a/application/Espo/Core/ORM/EntityFactory.php b/application/Espo/Core/ORM/EntityFactory.php index bc1e04e795..944c4c9c0d 100644 --- a/application/Espo/Core/ORM/EntityFactory.php +++ b/application/Espo/Core/ORM/EntityFactory.php @@ -77,6 +77,14 @@ class EntityFactory implements EntityFactoryInterface } public function create(string $entityType): Entity + { + return $this->createInternal($entityType); + } + + /** + * @param ?array $attributeDefs + */ + private function createInternal(string $entityType, ?array $attributeDefs = null): Entity { $className = $this->getClassName($entityType); @@ -90,6 +98,10 @@ class EntityFactory implements EntityFactoryInterface throw new RuntimeException("Entity '$entityType' is not defined in metadata."); } + if ($attributeDefs) { + $defs['attributes'] = array_merge($defs['attributes'] ?? [], $attributeDefs); + } + $relations = $this->injectableFactory->createWithBinding( RDBRelations::class, BindingContainerBuilder::create() @@ -123,6 +135,16 @@ class EntityFactory implements EntityFactoryInterface return $entity; } + /** + * @param array $attributeDefs + * @internal + * @noinspection PhpUnused + */ + public function createWithAdditionalAttributes(string $entityType, array $attributeDefs): Entity + { + return $this->createInternal($entityType, $attributeDefs); + } + /** * @return class-string */