- Issue created by @azinck
- πΊπΈUnited States azinck
As a first step (and to achieve something we needed to do), here's an extremely simplistic patch that at least allows custom_field criteria to be added to the configuration via non-UI means and understood by the fetchAssets call. I realize we could extend or override the service with our own implementation to achieve this but it would mean a lot of duplication of code in the fetchAssets call, which is non-ideal.
With this patch in place we can, for instance, add a line like this to our settings.php to limit the results for our brandfolder_image media type to only assets that have a specific school (or schools) in our Brandfolder instance:
$config['media.type.brandfolder_image']['source_configuration']['brandfolder']['bf_entity_criteria']['allowed']['custom_fields']['School/Center'] = ['Annandale HS'];
I took the opportunity to refactor the existing a code a bit to reduce redundancy. I think further redundancy could be eliminated in the label code, too, but I wasn't 100% sure what all it was doing and didn't want to dig into it too much for the time being.
- Assigned to ndewhurst
- Status changed to Needs review
9 months ago 3:35pm 28 March 2024 - πΊπΈUnited States ndewhurst USA
Thanks azinck. This is a natural feature request. The patch is a good start, and hopefully it's enabling you to achieve what you need with the config-based approach. I'd be fine rolling that code into dev. Do you want to go ahead and create a merge request?
Yes, there's no real need to differentiate "key-based criteria," and we can convert that to a more generic string mapping. This change will allow filetypes to be disallowed, which is fine.
Yes, we could eliminate a few lines of code duplication in label handling when it comes to formatting strings and bundling into query components. I might move that into getLabels. - Status changed to Needs work
9 months ago 3:37pm 28 March 2024