LiipImagineBundle icon indicating copy to clipboard operation
LiipImagineBundle copied to clipboard

add CacheManagerInterface.php that will allow CacheManager.php to be …

Open Warxcell opened this issue 4 years ago • 7 comments

…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

Warxcell avatar Jan 18 '21 07:01 Warxcell

Coverage Status

Coverage increased (+0.04%) to 83.692% when pulling 217a86aef50cc15725f286eef0edf803e6741f52 on Warxcell:cache_manager_interface into 469b178413e0ee02593f0a6ba5d267463b95b0a4 on liip:2.x.

coveralls avatar Jan 18 '21 07:01 coveralls

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?

lsmith77 avatar Feb 08 '21 15:02 lsmith77

Don't remember - I think I decided to go with Adapter Pattern in my case, but I think it's useful anyway. :)

Warxcell avatar Feb 08 '21 15:02 Warxcell

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.... );`

Warxcell avatar Feb 08 '21 21:02 Warxcell

ok .. as long as there is a use-case I am fine adding an interface :)

lsmith77 avatar Feb 08 '21 22:02 lsmith77

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.

fbourigault avatar Feb 16 '21 21:02 fbourigault

i like the suggestion of @fbourigault - do you want to split the interface in the way he suggested @Warxcell ?

dbu avatar Oct 05 '21 08:10 dbu