0

I want to create a block inside my custom module that will render the output from a controller class. I also want to pass an argument to the block based on which list it should work.

This is the block class.

/**
* Provides a 'Jobs By User' block.
*
* @Block(
*   id = "jobsbyauthor",
*   admin_label = @Translation("Jobs By User"),
* )
*/
class JobsByAuthorBlock extends BlockBase {   
  public function build() {
    $list = \Drupal\jobs\Controller\JobsController::jobsByUser();   
    return $list;
  }  
}

How can I achieve this?

Browse other questions tagged or ask your own question.