LiipImagineBundle
LiipImagineBundle copied to clipboard
add CacheManagerInterface.php that will allow CacheManager.php to be …
…decorated.
Q | A |
---|---|
Branch? | 2.0 |
Bug fix? | no |
New feature? | yes |
BC breaks? | no I think |
Deprecations? | no |
Tests pass? | yes |
Fixed tickets | |
License | MIT |
Doc PR |
Coverage increased (+0.04%) to 83.692% when pulling 217a86aef50cc15725f286eef0edf803e6741f52 on Warxcell:cache_manager_interface into 469b178413e0ee02593f0a6ba5d267463b95b0a4 on liip:2.x.
can you remove all the formatting changes from the PR? also can you briefly explain the specific use case you want to achieve with this change? ie. for what use case do you want to decorate the CacheManger?
Don't remember - I think I decided to go with Adapter Pattern in my case, but I think it's useful anyway. :)
Basically I needed to add $runtimeConfig
for particular path
, globally - not just for one file. So to avoid Repeat-Your-Self I could decorate CacheManager and do
if(stripos($path, 'XXX') !== false) {
$runtimeConfig['YY'] = ['xxx' => 'xxx']
}
return $this->decorated->getBrowserPath($path, $filter, $runtimeConfig.... );`
ok .. as long as there is a use-case I am fine adding an interface :)
The CacheManager
has two responsibilities.
The first one, for the isStored
, store
, remove
and resolve
methods, is to find the right resolver and call the same method this resolver.
The second one, for the getBrowserPath
, getRuntimePath
and generateUrl
, is to get an URL or a path.
I see here a nice opportunity to split CacheManager
.
The code is quite complex, but I would start with introducing some kind of ResolverManagerInterface
to move the first responsibility out of CacheManager
.
i like the suggestion of @fbourigault - do you want to split the interface in the way he suggested @Warxcell ?