-
Notifications
You must be signed in to change notification settings - Fork 379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for JsonManifestVersionStrategy #1525
Add support for JsonManifestVersionStrategy #1525
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks a lot for this contribution! cool idea to support this feature.
i am not super sure if the path / resolvedPath are always the file path or if they can be the cache path as well.
Templating/LazyFilterRuntime.php
Outdated
return rtrim(mb_substr($path, 0, $start), '?'); | ||
} | ||
} elseif ($this->jsonManifest) { | ||
$asset = array_search($path, $this->jsonManifest, true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
searching a potentially long unsorted array is inefficient.
you could array_flip the array in the constructor and then do an array_key_exists
and a simple key lookup instead for better performance. i guess both keys and values in json manifest should be unique.
Templating/LazyFilterRuntime.php
Outdated
} elseif ($this->jsonManifest) { | ||
$asset = array_search($path, $this->jsonManifest, true); | ||
if ($asset) { | ||
return $asset; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we be sure that the path from the manifest is right both for when the image needs to be generated and when it already exists?
i will fix the cs failures in the 2.x branch to be clean there. |
the 2.x branch is green again. please rebase your branch on 2.x |
…ub.com/skepp/LiipImagineBundle into json_manifest_version_strategy_support
Thank you for your helpful review! Updated PR accordingly.
I've not done a deep dive into the caching mechanism, but according to https://github.com/liip/LiipImagineBundle/blob/2.x/Resources/doc/asset-versioning.rst?plain=1#L10-L19 |
i rebased and squashed the commits in #1529 |
This PR adds in support for JsonManifestVersionStrategy that is available in Symfony.
In a JSON manifest, we have a key => value structure where the key is the original filepath, and the value the versioned filestring, e.g:
Similar to
StaticVersionStrategy
that loads it's configuration from the container, this reads the JSON Manifest file definedThe LazyFilterRuntime has been extended to load the JSON Manifest file contents, and the various methods within to handle both Static & Json versioning.
Note that the current 2.x branch has unrelated failing CI.
I don't think this PR breaks current implementations although test coverage for AssetsVersionCompilerPass currently is lacking.