Saving form data in a custom Magento2 table

I have a form that links to a controller and my goal is to save the data in my custom folder. vendor_module_table

public function execute ()
{
$ post = (array) $ this-> getRequest () -> getPost ();

if (! empty ($ post)) {
$ customerId = $ post['customer_id'];
$ make = $ post['make_id'];
$ model = $ post['model_id'];
$ year = $ post['year_id'];

# to do - add an insert
$ this-> messageManager-> addSuccessMessage (& # 39; Success! & # 39;);

$ resultRedirect = $ this-> resultFactory-> create (ResultFactory :: TYPE_REDIRECT);
$ resultRedirect-> setUrl (& # 39; / module / controller / add & # 39;);

return $ resultRedirect;
}

$ this -> _ view-> loadLayout ();
$ this -> _ view-> renderLayout ();
}

I came across some online articles on the way forward. My problem with the solution provided is that they all use object manager – and that seems to me a bad practice. Especially when M2 is based on Symfony, where I can simply call a pre-built save / add function to my controller in connection with my listing and it works. Has Magento2 adapted something for this?

For example. code of my Symfony project:

if ($ form-> isSubmitted () && $ form-> isValid ()) {
$ em = $ this-> getDoctrine () -> getManager ();

# define non-form fields
$ category-> setApproved (0);
$ category-> setCreatedTs (new  DateTime ());

try {
# Here's how Symfony saves data in a table
$ em-> persist ($ category);
$ em-> flush ();

$ this-> addFlash ('success', 'Category subject to revision.');
} catch (Exception $ e) {
$ this-> addFlash ("danger") Something has switched though, please try again. $ e-> getMessage (). - & # 39; - & # 39; . $ e-> getCode ());
}

return $ this-> redirectToRoute (& # 39; category_list & # 39;);
}