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

This commit is contained in:
mcndave committed 2023-10-30 19:41:40 +00:00
1 parent cc741566fb
commit c9d9281c63
2 files changed
+10 -1

No files matched your search

+1 -1
View File
@@ -8,7 +8,7 @@ class Field implements \Notes\Annotation {
public string $name;
public int $length;
public int|string $length;
public int $precision;
+9
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
{
if ( is_array($entity) ) {