const chalk = require('chalk');
const jhipsterUtils = require('../utils');

module.exports = class {
    addBlockContentToFile(fullPath, content, needleTag) {
        try {
            jhipsterUtils.rewriteFile(
                {
                    file: fullPath,
                    needle: needleTag,
                    splicable: [content]
                },
                this
            );
        } catch (e) {
            this.log(
                chalk.yellow('\nUnable to find ') +
                fullPath +
                chalk.yellow(' or missing required jhipster-needle. Content not added to JHipster app.\n')
            );
            this.debug('Error:', e);
        }
    }
};

@@ -102,58 +102,132 @@
     
-addBlockContentToFile(fullPath, content, needleT
+constructor(generator) %7B%0A        this.generator = generator;%0A    %7D%0A%0A    addBlockContentToFile(rewriteFileModel, errorMess
 ag
+e
 ) %7B%0A
@@ -323,24 +323,37 @@
   file: 
-fullPath
+rewriteFileModel.file
 ,%0A      
@@ -378,17 +378,31 @@
 le: 
+rewriteFileModel.
 needle
-Tag
 ,%0A  
@@ -434,17 +434,34 @@
 le: 
-%5Bcontent%5D
+rewriteFileModel.splicable
 %0A   
@@ -496,16 +496,26 @@
     this
+.generator
 %0A       
@@ -564,17 +564,71 @@
 this.log
-(
+NeedleNotFound(e, errorMessage, rewriteFileModel.file);
 %0A       
@@ -624,32 +624,199 @@
 e);%0A        
+%7D%0A
     
+%7D%0A%0A
     
+logNeedleNotFound(exception, message, fullPath) %7B%0A        if (!message) %7B%0A            message = 'Content not added to file';%0A        %7D%0A        this.generator.log(
 chalk.yellow
@@ -848,23 +848,16 @@
         
-   
-    
 fullPath
@@ -868,23 +868,16 @@
         
-   
-    
 chalk.ye
@@ -881,17 +881,17 @@
 .yellow(
-'
+%60
  or miss
@@ -924,46 +924,330 @@
 le. 
-Content not added to JHipster app.%5Cn')
+$%7Bmessage%7D%5Cn%60));%0A        this.generator.debug('Error:', exception);%0A    %7D%0A%0A    generateFileModelWithPath(aPath, aFile, needleTag, ...content) %7B%0A        return Object.assign(this.generateFileModel(aFile, needleTag, ...content), %7B path: aPath %7D);%0A    %7D%0A%0A    generateFileModel(aFile, needleTag, ...content) %7B%0A        return %7B
 %0A   
@@ -1247,34 +1247,44 @@
 n %7B%0A            
-);
+file: aFile,
 %0A            thi
@@ -1284,32 +1284,57 @@
     
-this.debug('Error:', e);
+needle: needleTag,%0A            splicable: content
 %0A   
@@ -1335,22 +1335,23 @@
 nt%0A        %7D
+;
 %0A    %7D%0A%7D;%0A

Define constructor and add generateFileModel