- Added a new clone() method to Repository() base class
This commit is contained in:
		
							parent
							
								
									cc741566fb
								
							
						
					
					
						commit
						c9d9281c63
					
				| @ -8,7 +8,7 @@ class Field implements \Notes\Annotation { | ||||
| 
 | ||||
|     public string $name; | ||||
|      | ||||
|     public int $length; | ||||
|     public int|string $length; | ||||
| 
 | ||||
|     public int $precision; | ||||
| 
 | ||||
|  | ||||
| @ -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) ) { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user