99 "github.com/dfeyer/flow-debugproxy/logger"
1010 "github.com/dfeyer/flow-debugproxy/pathmapperfactory"
1111 "github.com/dfeyer/flow-debugproxy/pathmapping"
12+ "github.com/dfeyer/flow-debugproxy/xdebugproxy"
1213
1314 "bytes"
1415 "fmt"
3738)
3839
3940func init () {
40- p := & PathMapper {}
41+ p := & PathMapperFactory {}
4142 pathmapperfactory .Register (framework , p )
4243}
4344
@@ -48,20 +49,23 @@ func regexpFilename() *regexp.Regexp {
4849 return regexpFilename__Unix
4950}
5051
52+ type PathMapperFactory struct {}
53+
54+ func (p * PathMapperFactory ) Create (c * config.Config , l * logger.Logger , m * pathmapping.PathMapping ) xdebugproxy.XDebugProcessorPlugin {
55+ return & PathMapper {
56+ config : c ,
57+ logger : l ,
58+ pathMapping : m ,
59+ }
60+ }
61+
5162// PathMapper handle the mapping between real code and proxy
5263type PathMapper struct {
5364 config * config.Config
5465 logger * logger.Logger
5566 pathMapping * pathmapping.PathMapping
5667}
5768
58- // Initialize the path mapper dependencies
59- func (p * PathMapper ) Initialize (c * config.Config , l * logger.Logger , m * pathmapping.PathMapping ) {
60- p .config = c
61- p .logger = l
62- p .pathMapping = m
63- }
64-
6569// ApplyMappingToTextProtocol change file path in xDebug text protocol
6670func (p * PathMapper ) ApplyMappingToTextProtocol (message []byte ) ([]byte , error ) {
6771 return p .doTextPathMapping (message ), nil
@@ -109,7 +113,9 @@ func (p *PathMapper) getCachePath(base, filename string) string {
109113 context := p .config .Context
110114 if strings .Contains (context , "/" ) {
111115 contextParts := strings .Split (context , "/" )
112- contextParts [1 ] = "SubContext" + contextParts [1 ]
116+ for i := 1 ; i < len (contextParts ); i ++ {
117+ contextParts [i ] = "SubContext" + contextParts [i ]
118+ }
113119 context = strings .Join (contextParts , "/" )
114120 }
115121 cachePath = strings .Replace (cachePath , "@context@" , context , 1 )
0 commit comments