User ID in application

A replace to

    // @todo we need the user id somehow here
    $userId  = 0;

Why don't use a variable and method to store user identifier in application?
The method can be overried in child classes and variable set in doExecute() method.