// Check if the passed position data is a new position or an existing position.
$position = $this->getManager()->getRepository(OrderDetail::class)->find($id); if(!$position instanceof OrderDetail){ $position = newOrderDetail(); $attribute = newOrderDetailAttribute(); $position->setAttribute($attribute); $this->getManager()->persist($position); }