Using Class loader in WordPress boilerplate

Thanks Paul, you led me to the solution.

What I did

In class-mypluging-admin.php, I added this:

/**
 * Additional arguments for this plugin.
 *
 * @since    1.0.0
 * @access   private
 * @var      array $args The current arguments of this plugin.
 */
private $args;

/**
 * Initialize the class and set its properties.
 *
 * @since    1.0.0
 * @param      string    $plugin_name       The name of this plugin.
 * @param      string    $version    The version of this plugin.
 * @param      array     $args  The additional arguments of this plugin.
 */
public function __construct( $plugin_name, $version, $args = null ) {

    $this->plugin_name = $plugin_name;
    $this->version = $version;
    $this->args = $args;

}

Then for the functions in class-mypluging-admin.php

function some_function( $views ) {
    
    $post_type = $this->args['post_type'];

...

}

In class-mypluging.php, I do this:

foreach($post_types as $post_type)
{
    $args = array(
        'post_type' => $post_type,
    );
    
    $plugin_admin = new MyPlugin_Admin( $this->get_plugin_name(), $this->get_version(), $args );    

$this->loader->add_action("views_edit-{$post_type}", $plugin_admin, 'some_function');   

}

And it works! Is that the correct way to do this?