Create automatic action from a subtask event

The automatic action does not work on subtasks so I’ m not making an automatic action at all anymore. Currently my code is not in a plugin because I haven’t figured out how to achieve what I need that way. I have directly modified the change() function of the SubtaskStatusController in the Kanboard source code, see below. What I need is to be able to write a plugin that overrides the change() function of the SubtaskStatusController given a certain condition. This is similar to this request here which doesn’t look like it was resolved.

My adapted change function:

public function change()

{
    $task = $this->getTask();
    $subtask = $this->getSubtask($task);
    $fragment = $this->request->getStringParam('fragment');
   
    //debug statements
    error_log("current status:".$subtask['status']);

    $projectid = $this->request->getIntegerParam('project_id');
    error_log("project id: ".$projectid);

    $user=$this->helper->user->getFullName();
    error_log("full name: ".$user);

    $id=$this->helper->user->getId();
    error_log("user id: ".$id);

    $project_role = $this->helper->projectRole->getProjectUserRole($projectid);
    error_log("project_role: ".$project_role);
    
    // only change the status from complete to not started if user is project manager
    switch($subtask['status']){
        
        case 0:
            $status = $this->subtaskStatusModel->toggleStatus($subtask['id']);
            $subtask['status'] = $status;
            break;
        case 1:
            $status = $this->subtaskStatusModel->toggleStatus($subtask['id']);
            $subtask['status'] = $status;
            break;
        case 2:
            if ($project_role == Role::PROJECT_MANAGER){
                $status = $this->subtaskStatusModel->toggleStatus($subtask['id']);
                $subtask['status'] = $status;
            }
            break;
        default:
            error_log("Subtask status not recognised.");
            break;
    }

    if ($fragment === 'table') {
        $html = $this->renderTable($task);
    } elseif ($fragment === 'rows') {
        $html = $this->renderRows($task);
    } else {
        $html = $this->helper->subtask->renderToggleStatus($task, $subtask);
    }

    $this->response->html($html);
}

}