Zend certified PHP/Magento developer

Getting information to an admin view page – block, viewmodel, both, etc

Old time Drupal guy here struggling with how to get data to the presentation layer. I have created ui listing and form components to list and edit records but there seems to be a gap in a process to simply list information on a page.

For this I have created a custom controller –

Vendor/Module/Controller/Adminhtml/QueueItem/View.php

and a template –

Vendor/Module/view/adminhtml/templates/queueitem/view.phtml

I am using a layout file that references a ViewModel:

Vendor/Module/view/adminhtml/layout/vendor_queueitem_view.xml

< ?xml version="1.0"?>

    
        
            View Queue Item
        
    
    
        
            
                
                    VendorModuleViewModelQueueItemView
                
            
        
    

My questions:

  • Should I create a Block, a ViewModel or both?
  • Where do I load the data for the model? QueueItem with id = 2 for example
  • How does the above record (queueitem with id = 2) get into the phtml template?

Looking to do this the Magento way. Currently using version 2.2.10 and will be updating to 2.3.x shortly.

thanks in advance.
mikeg