Allow access to the Reference name and the resolved asset#18
Allow access to the Reference name and the resolved asset#18dlundgren wants to merge 1 commit intoassetic-php:masterfrom
Conversation
|
@dlundgren thanks for your contribution. Would you be able to provide a use case for why it would be needed to access the name and asset directly? |
|
I have something similar to WordPress' wp_enqueue_style and wp_enqueue_script that allows the assets to be registered and used as needed. In my tests, the deeper the references are, the more likely I was to end up with duplicated content. So I was using the reference name to deduplicate the reference from deeper in the collection, without triggering the asset resolution when it's not needed. I think I was using the asset object to replace the reference in some spots, but I no longer see that code in my repo, so I can probably ask for that later if needed. |
|
@dlundgren would you be willing to provide a code example of how you're using these methods? @bennothommo can you think of any reason why we should have any private properties or methods in this library at all instead of just protected ones? |
|
@LukeTowers |
|
@dlundgren any updates on this? |
|
Thanks for reminding me about this, I'm still looking at using this, but I've been working on other aspects of my project at the moment. Here is the relevant code I'm using. The https://gist.github.com/dlundgren/64c9d6892d3a465f9e52fbdada317973 |
While working on deduplication of assets in my own library, I found that I had to use a full copy of the
AssetReferenceclass. Since theresolvemethod andnameproperties are private, extending the class is not possible, and there are no methods available to retrieve just theassetornameof the Reference.I'd like to add the following to the
AssetReferenceclass:getNamereturns thenameof the referencegetAssetreturns the result ofresolve