I am using Drupal 9 and I am somewhat of a newbie.
I have created a custom entity into which I wish to log the date and number of image downloads. I can use the entity’s form to create entries but I need to do it programmatically, when the user triggers a download action from the site. The only thing known at that point is the user id and the number of images in the download. How do I tell my module to create an entity record, being as I am triggering it from a function. When using the form in debug mode, I can see the variables being passed through but I have no idea as to how to get that data into the database. My function currently gets the number of images but nothing else.
Do I need to create a hook and if so, how do I trigger that from the download function?
I appreciate any advice anyone can give.