goaop / goaop-zf2-module

Integration module for Go! AOP Framework and ZF2 Framework
MIT License
6 stars 4 forks source link

Wildcard for excludePaths #2

Closed icanhazstring closed 7 years ago

icanhazstring commented 7 years ago

The excludePaths currently on uses a simple array with multiple paths. Would be nice to be able to provide a wildcard path which gets checked if a path matches a wild card.

Console/Warmup/Zf2WarmupCommond

$enumerator = new Enumerator($options['appDir'], $options['includePaths'], $options['excludePaths']);
$iterator   = $enumerator->enumerate();

This way is would be possible to exclude configs from classes, e.g.:

'excludePaths' => [
   $dir . '/module/**/config'
]

The core problem is the Enumerator from goaop/framework

foreach ($excludePaths as $excludePath) {
    if (strpos($realPath, $excludePath) === 0) {
        return false;
    }
}

@lisachenko maybe this ticket belongs to goaop/framework. but i don't know. Your choice, i would fix this :)

lisachenko commented 7 years ago

Yes, agree. Your idea can be useful for several cases

icanhazstring commented 7 years ago

--Edit-- Updated ticket to be more precise on the problem

lisachenko commented 7 years ago

@icanhazstring maybe we can replace strpos with fnmatch and this will be ok? But need to test path separators, dots and other symbols carefully

icanhazstring commented 7 years ago

@lisachenko will try to provide some tests then and create the fix for goaop/framework

icanhazstring commented 7 years ago

I created pull request in goaop/framework

https://github.com/goaop/framework/pull/300 Tests provided, this should resolve this request.

icanhazstring commented 7 years ago

Closed by goaop/framework#300