mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-28 23:16:03 +00:00
entity factory create with additional attributes
This commit is contained in:
@@ -77,6 +77,14 @@ class EntityFactory implements EntityFactoryInterface
|
||||
}
|
||||
|
||||
public function create(string $entityType): Entity
|
||||
{
|
||||
return $this->createInternal($entityType);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ?array<string, mixed> $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<string, mixed> $attributeDefs
|
||||
* @internal
|
||||
* @noinspection PhpUnused
|
||||
*/
|
||||
public function createWithAdditionalAttributes(string $entityType, array $attributeDefs): Entity
|
||||
{
|
||||
return $this->createInternal($entityType, $attributeDefs);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return class-string<Entity>
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user