- Added a new clone() method to Repository() base class

This commit is contained in:
Dave M. 2023-10-30 19:41:40 +00:00
parent cc741566fb
commit c9d9281c63
2 changed files with 10 additions and 1 deletions

View File

@ -8,7 +8,7 @@ class Field implements \Notes\Annotation {
public string $name; public string $name;
public int $length; public int|string $length;
public int $precision; public int $precision;

View File

@ -144,6 +144,15 @@ class Repository
} }
} }
public function clone(object|array $entity) : bool
{
foreach(Ulmus::resolveEntity($this->entityClass)->getPrimaryKeyField() as $key => $field) {
unset($entity->$key);
}
return $this->save($entity);
}
public function save(object|array $entity, ? array $fieldsAndValue = null, bool $replace = false) : bool public function save(object|array $entity, ? array $fieldsAndValue = null, bool $replace = false) : bool
{ {
if ( is_array($entity) ) { if ( is_array($entity) ) {