response->format = \yii\web\Response::FORMAT_JSON; return [ 'return' => $responseType, 'alert' => [ 'type' => self::getAlertClass($responseType), 'message' => 'Vous ne pouvez pas modifier un bon de livraison déjà validé.' ] ]; } private static function getAlertClass(string $responseType) { $class = ''; if($responseType == self::RESPONSE_TYPE_SUCCESS) { $class = 'success'; } elseif($responseType == self::RESPONSE_TYPE_ERROR) { $class = 'danger'; } return $class; } }