Behaviors dependent on application type

I have a model that is used both in Web Application (frontend) and Console Application. For the usage in the frontend the model has attached Timestamp and Blameable behaviors. However when used by Console App for background tasks these behaviors are unwanted.

To meet these requirements I’ve added a condition to the behaviors() method checking the class of the Application:

public function behaviors()


    $behaviors = [

        'softDelete' => 'common\behaviors\SoftDeleteBehavior',


    if (get_class(Yii::$app) != 'yii\console\Application') {

        $behaviors = array_merge($behaviors, [

            'timestamp' => 'yii\behaviors\TimestampBehavior',

            'blameable' => 'yii\behaviors\BlameableBehavior',



    return $behaviors;


Would you approve of this approach or am I overlooking some shortcomings?